From b7a77757f924083f8da8a777ebec943b4b18bebf Mon Sep 17 00:00:00 2001 From: abijah Date: Fri, 14 Aug 2009 18:11:33 +0000 Subject: [PATCH] Fixed a couple URL problems, including redirect, which was previously entirely unable to utilize our AppHelper for the url generation. Added a couple menu items into the Admin section. Changed debug to be OFF for any route other than the 'dev' one. git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@551 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/app_controller.php | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/site/app_controller.php b/site/app_controller.php index b414f4f..42ae8b4 100644 --- a/site/app_controller.php +++ b/site/app_controller.php @@ -66,6 +66,9 @@ class AppController extends Controller { $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' => 'Transactions', 'url' => array('controller' => 'transactions', 'action' => 'index')); + $menu[] = array('name' => 'Ldgr Entries', 'url' => array('controller' => 'ledger_entries', 'action' => 'index')); + $menu[] = array('name' => 'Stmt Entries', 'url' => array('controller' => 'statement_entries', 'action' => 'index')); $menu[] = array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger')); $menu[] = array('name' => 'Assess Charges', 'url' => array('controller' => 'leases', 'action' => 'assess_all')); } @@ -86,12 +89,39 @@ class AppController extends Controller { (!empty($this->params['dev_route'])); $this->params['admin'] = (!empty($this->params['admin_route']) || !empty($this->params['dev_route'])); + + if (!$this->params['dev']) + Configure::write('debug', '0'); } function beforeRender() { $this->set('sidemenu', $this->sideMenuLinks()); } + function redirect($url, $status = null, $exit = true) { + if (headers_sent()) { + // If we've already sent the headers, it's because + // we're debugging, and our debug output has gotten + // out before the redirect. That's probably a good + // thing, as we don't typically want pages to be + // jerked out from under us while trying to read + // the debug output. So, since we can't redirect + // anyway, we may as well go with the flow and just + // render this page instead, using an empty template + $this->render('/empty'); + if ($exit) + $this->_stop(); + } + + // OK, since the controller will not be able to + // utilize our overriden url function in AppHelper, + // we'll have to do it manually here. + App::import('Helper', 'Html'); + $url = HtmlHelper::url($url, true); + + return parent::redirect($url, $status, $exit); + } + function reset_data() { $this->layout = null; $this->autoLayout = false; @@ -720,6 +750,8 @@ class AppController extends Controller { if (isset($params['post']['nolinks'])) return; + App::import('Helper', 'Html'); + foreach ($links AS $table => $fields) { $special = array('controller', 'action', 'id'); $controller = Inflector::pluralize(Inflector::underscore($table)); @@ -738,9 +770,9 @@ class AppController extends Controller { //$params['linkrecord'][] = compact('table', 'field', 'id', 'controller', 'record'); $record[$table][$field] = '' . $record[$table][$field] . '';