Changed the custom route variables, so that the dev route could set the admin flag and not screw up the routing. The AppController now checks the routing params to set the dev/admin flags.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@545 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-08-13 16:43:07 +00:00
parent 4be4224742
commit 9d716532bb
3 changed files with 35 additions and 19 deletions

View File

@@ -39,22 +39,38 @@ class AppController extends Controller {
var $components = array('DebugKit.Toolbar');
function sideMenuLinks() {
return array(
array('name' => 'Common', 'header' => true),
array('name' => 'Site Map', 'url' => array('controller' => 'maps', 'action' => 'view', 1)),
array('name' => 'Units', 'url' => array('controller' => 'units', 'action' => 'index')),
array('name' => 'Leases', 'url' => array('controller' => 'leases', 'action' => 'index')),
array('name' => 'Customers', 'url' => array('controller' => 'customers', 'action' => 'index')),
array('name' => 'Accounts', 'url' => array('controller' => 'accounts', 'action' => 'index')),
array('name' => 'Deposits', 'url' => array('controller' => 'transactions', 'action' => 'deposit')),
array('name' => 'Debug', 'header' => true),
array('name' => 'Un-Nuke', 'url' => '#', 'htmlAttributes' =>
array('onclick' => '$(".pr-section").show(); return false;')),
array('name' => 'Contacts', 'url' => array('controller' => 'contacts', 'action' => 'index')),
array('name' => 'Ledgers', 'url' => array('controller' => 'ledgers', 'action' => 'index')),
array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger')),
//array('name' => 'RESET DATA', 'url' => array('controller' => 'accounts', 'action' => 'reset_data')),
);
$menu = array();
$menu[] = array('name' => 'Common', 'header' => true);
$menu[] = array('name' => 'Site Map', 'url' => array('controller' => 'maps', 'action' => 'view', 1));
$menu[] = array('name' => 'Units', 'url' => array('controller' => 'units', 'action' => 'index'));
$menu[] = array('name' => 'Leases', 'url' => array('controller' => 'leases', 'action' => 'index'));
$menu[] = array('name' => 'Customers', 'url' => array('controller' => 'customers', 'action' => 'index'));
$menu[] = array('name' => 'Deposits', 'url' => array('controller' => 'transactions', 'action' => 'deposit'));
if ($this->params['admin']) {
$menu[] = array('name' => 'Admin', 'header' => true);
$menu[] = array('name' => 'Accounts', 'url' => array('controller' => 'accounts', 'action' => 'index'));
$menu[] = array('name' => 'Contacts', 'url' => array('controller' => 'contacts', 'action' => 'index'));
$menu[] = array('name' => 'Ledgers', 'url' => array('controller' => 'ledgers', 'action' => 'index'));
$menu[] = array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger'));
}
if ($this->params['dev']) {
$menu[] = array('name' => 'Development', 'header' => true);
$menu[] = array('name' => 'Un-Nuke', 'url' => '#', 'htmlAttributes' =>
array('onclick' => '$(".pr-section").show(); return false;'));
$menu[] = array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger'));
//array('name' => 'RESET DATA', 'url' => array('controller' => 'accounts', 'action' => 'reset_data'));
}
return $menu;
}
function beforeFilter() {
$this->params['dev'] =
(!empty($this->params['dev_route']));
$this->params['admin'] =
(!empty($this->params['admin_route']) || !empty($this->params['dev_route']));
}
function beforeRender() {

View File

@@ -39,7 +39,7 @@ App::import('Core', 'Helper');
class AppHelper extends Helper {
function url($url = null, $full = false) {
foreach(array('admin', 'dev') AS $mod) {
foreach(array('admin_route', 'dev_route') AS $mod) {
if (isset($this->params[$mod]) && is_array($url) && !isset($url[$mod]))
$url[$mod] = $this->params[$mod];
}

View File

@@ -38,14 +38,14 @@ Router::connect('/', array('controller' => 'maps', 'action' => 'view', '1'));
* Route for admin functionality
*/
Router::connect('/admin/:controller/:action/*',
array('action' => null, 'admin' => true)
array('action' => null, 'admin_route' => true)
);
/*
* Route for development functionality
*/
Router::connect('/dev/:controller/:action/*',
array('action' => null, 'dev' => true)
array('action' => null, 'dev_route' => true)
);
?>