From d40f43c6179bd61eea96136552c0d3c824dcbee0 Mon Sep 17 00:00:00 2001 From: abijah Date: Fri, 14 Aug 2009 21:49:42 +0000 Subject: [PATCH] Cleaned up several places regarding redirect and rendering during development for debug purposes. Also, added a link to the intended redirect target when we've rendered instead. These changes haven't been tested, hopefully they are benign. git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@563 97e9348a-65ac-dc4b-aefc-98561f571b83 --- app_controller.php | 16 ++++++++++------ controllers/contacts_controller.php | 2 -- controllers/customers_controller.php | 21 +++++++-------------- controllers/leases_controller.php | 6 ------ controllers/maps_controller.php | 4 ++-- controllers/tenders_controller.php | 5 ----- controllers/units_controller.php | 5 ----- views/empty.ctp | 5 +++++ 8 files changed, 24 insertions(+), 40 deletions(-) diff --git a/app_controller.php b/app_controller.php index af2d4d0..b62eedb 100644 --- a/app_controller.php +++ b/app_controller.php @@ -99,6 +99,12 @@ class AppController extends Controller { } function redirect($url, $status = null, $exit = true) { + // 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); + if (headers_sent()) { // If we've already sent the headers, it's because // we're debugging, and our debug output has gotten @@ -108,17 +114,15 @@ class AppController extends Controller { // 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->set('message', + ("Intended redirect:


" . + ''.$url.'')); + echo $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); } diff --git a/controllers/contacts_controller.php b/controllers/contacts_controller.php index eb09b2e..ea2e20d 100644 --- a/controllers/contacts_controller.php +++ b/controllers/contacts_controller.php @@ -126,8 +126,6 @@ class ContactsController extends AppController { // Now that the work is done, let the user view the updated contact $this->redirect(array('action'=>'view', $this->data['Contact']['id'])); - //$this->render('/empty'); - return; } if ($id) { diff --git a/controllers/customers_controller.php b/controllers/customers_controller.php index c0c5e1a..1439b46 100644 --- a/controllers/customers_controller.php +++ b/controllers/customers_controller.php @@ -287,23 +287,20 @@ class CustomersController extends AppController { if (isset($this->params['form']['cancel'])) { if (isset($this->data['Customer']['id'])) $this->redirect(array('action'=>'view', $this->data['Customer']['id'])); - else - $this->redirect(array('action'=>'index')); - return; + + $this->redirect(array('action'=>'index')); } // Make sure we have at least one contact if (!isset($this->data['Contact']) || count($this->data['Contact']) == 0) { $this->Session->setFlash("MUST SPECIFY AT LEAST ONE CONTACT", true); $this->redirect(array('action'=>'view', $this->data['Customer']['id'])); - return; } // Make sure there is a primary contact if (!isset($this->data['Customer']['primary_contact_entry'])) { $this->Session->setFlash("MUST SPECIFY A PRIMARY CONTACT", true); $this->redirect(array('action'=>'view', $this->data['Customer']['id'])); - return; } // Go through each customer and strip the bogus ID if new @@ -320,17 +317,12 @@ class CustomersController extends AppController { pr("CUSTOMER SAVE FAILED"); } - // If existing customer, then view it. Otherwise, since - // this is a new customer, go to the move in screen. + // If existing customer, then view it. if ($this->data['Customer']['id']) $this->redirect(array('action'=>'view', $this->Customer->id)); - else - $this->redirect(array('action'=>'move_in', $this->Customer->id)); - // For debugging, only if the redirects above have been - // commented out, otherwise this section isn't reached. - $this->render('/empty'); - return; + // Since this is a new customer, go to the move in screen. + $this->redirect(array('action'=>'move_in', $this->Customer->id)); } if ($id) { @@ -499,7 +491,8 @@ class CustomersController extends AppController { /* pr(compact('unreconciled')); */ /* echo htmlspecialchars($xml->serialize($unreconciled)); */ -/* $this->render('/fake'); */ +/* $this->render('/empty'); */ +/* return; */ $opts = array(); //$opts['format'] = 'tags'; diff --git a/controllers/leases_controller.php b/controllers/leases_controller.php index de91919..ed501c7 100644 --- a/controllers/leases_controller.php +++ b/controllers/leases_controller.php @@ -158,10 +158,6 @@ class LeasesController extends AppController { // Since this is a new lease, go to the invoice // screen so we can start assessing charges. $this->redirect(array('action'=>'invoice', $lid, 'move-in')); - - // For debugging, only if the redirect above have been - // commented out, otherwise this section isn't reached. - $this->render('/empty'); } /************************************************************************** @@ -231,8 +227,6 @@ class LeasesController extends AppController { /* function promote_surplus($id) { */ /* $this->Lease->promoteSurplus($id); */ -/* pr("PREVENTING REDIRECT"); */ -/* $this->render('fake'); */ /* $this->redirect(array('controller' => 'leases', */ /* 'action' => 'view', */ /* $id)); */ diff --git a/controllers/maps_controller.php b/controllers/maps_controller.php index 79d6692..a6bc7ac 100644 --- a/controllers/maps_controller.php +++ b/controllers/maps_controller.php @@ -109,7 +109,7 @@ class MapsController extends AppController { )); /* pr(compact('map', 'units')); */ -/* $this->render('/fake'); */ +/* $this->render('/empty'); */ /* return; */ /***** @@ -171,7 +171,7 @@ class MapsController extends AppController { } /* pr($info); */ -/* $this->render('/fake'); */ +/* $this->render('/empty'); */ return $info; } diff --git a/controllers/tenders_controller.php b/controllers/tenders_controller.php index 0f0a9fa..71b0d04 100644 --- a/controllers/tenders_controller.php +++ b/controllers/tenders_controller.php @@ -233,11 +233,6 @@ class TendersController extends AppController { } $this->redirect(array('action'=>'view', $this->Tender->id)); - - // For debugging, only if the redirects above have been - // commented out, otherwise this section isn't reached. - $this->render('/fake'); - return; } if ($id) { diff --git a/controllers/units_controller.php b/controllers/units_controller.php index 7dac5ef..d04f7c7 100644 --- a/controllers/units_controller.php +++ b/controllers/units_controller.php @@ -308,11 +308,6 @@ class UnitsController extends AppController { } $this->redirect(array('action'=>'view', $this->Unit->id)); - - // For debugging, only if the redirects above have been - // commented out, otherwise this section isn't reached. - $this->render('/fake'); - return; } if ($id) { diff --git a/views/empty.ctp b/views/empty.ctp index e69de29..3888feb 100644 --- a/views/empty.ctp +++ b/views/empty.ctp @@ -0,0 +1,5 @@ +