Integrated sandbox functionality directly into the application so that there is no need for two independent applications for both the normal and sandbox version.

git-svn-id: file:///svn-source/pmgr/branches/single_site_sandbox_20090905@838 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-09-06 04:28:29 +00:00
parent 7a2034aea0
commit 740bcbedc0
8 changed files with 71 additions and 16 deletions

View File

@@ -251,24 +251,32 @@ class AppController extends Controller {
array('controller' => 'tenders', 'action' => 'deposit'), null,
'SITE', $this->op_area);
if (sandbox()) {
$url_components = array('plugin', 'controller', 'action', 'named');
if (devbox()) {
/* $sources = ConnectionManager::sourceList(); */
/* $db = ConnectionManager::getDataSource($sources[0])->config['database']; */
/* $this->sideMenuAreaName($db, 'SANDBOX', $this->std_area); */
$this->sideMenuAreaName('DevBox', 'SANDBOX', $this->std_area);
$this->addSideMenuLink('Rebuild DevBox',
array('controller' => 'util', 'action' => 'rebuild_devbox'), null,
'SANDBOX');
}
elseif (sandbox()) {
$this->addSideMenuLink('Rebuild Sandbox',
array('controller' => 'util', 'action' => 'rebuild_sandbox'), null,
'SANDBOX');
$this->addSideMenuLink('Leave Sandbox',
((empty($_SERVER['HTTPS']) ? 'http://' : 'https://') .
$_SERVER['SERVER_NAME'] .
preg_replace("%^/([^/]+)\.sand%", "/$1", $_SERVER['REQUEST_URI'])),
null,
'SANDBOX');
array('sand_route' => false)
+ array_intersect_key($this->params, array_flip($url_components))
+ $this->params['pass'],
null, 'SANDBOX');
}
else {
$this->addSideMenuLink('Enter Sandbox',
((empty($_SERVER['HTTPS']) ? 'http://' : 'https://') .
$_SERVER['SERVER_NAME'] .
preg_replace("%^/([^/]+)%", "/$1.sand", $_SERVER['REQUEST_URI'])),
null,
'SANDBOX');
array('sand_route' => true)
+ array_intersect_key($this->params, array_flip($url_components))
+ $this->params['pass'],
null, 'SANDBOX');
}
// REVISIT <AP>: 20090824
@@ -297,8 +305,11 @@ class AppController extends Controller {
function beforeFilter() {
$this->params['user'] = $this->Permission->User->currentUser();
$this->params['dev'] = $this->Option->enabled('dev');
$this->params['admin'] = $this->Option->enabled('admin');
$this->params['dev'] = devbox();
if ($this->params['dev'] && !$this->Option->enabled('dev'))
$this->redirect("/");
if (!$this->params['dev'])
Configure::write('debug', '0');