From fde89238144c9d8e0c366d530be83fb5b3ac5d9e Mon Sep 17 00:00:00 2001 From: abijah Date: Fri, 28 Aug 2009 20:46:10 +0000 Subject: [PATCH] Added a utility controller, for calling actions that really aren't related to any other controller (we've been using accounts up to this point). git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@809 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/app_controller.php | 35 +++------------- site/app_model.php | 2 +- site/controllers/util_controller.php | 60 ++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 31 deletions(-) create mode 100644 site/controllers/util_controller.php diff --git a/site/app_controller.php b/site/app_controller.php index 13fd507..4f812e6 100644 --- a/site/app_controller.php +++ b/site/app_controller.php @@ -254,6 +254,11 @@ class AppController extends Controller { array('controller' => 'tenders', 'action' => 'deposit'), null, 'SITE', $this->op_area); + if (sandbox()) + $this->addSideMenuLink('Rebuild Sandbox', + array('controller' => 'util', 'action' => 'rebuild_sandbox'), null, + 'SITE', $this->op_area); + // REVISIT : 20090824 // Depending on preference, we may put this into the gridView // function, making the links available only when navigating. @@ -398,36 +403,6 @@ class AppController extends Controller { } - /************************************************************************** - ************************************************************************** - ************************************************************************** - * function: reset_data - * - Development function. TO BE DELETED - */ - - function reset_data() { - $this->layout = null; - $this->autoLayout = false; - $this->autoRender = false; - Configure::write('debug', '0'); - $script = $_SERVER['DOCUMENT_ROOT'] . '/pmgr/build.cmd'; - echo "

" . date('r') . "\n"; - //echo "

Script: $script" . "\n"; - $db = & $this->Account->getDataSource(); - $script .= ' "' . $db->config['database'] . '"'; - $script .= ' "' . $db->config['login'] . '"'; - $script .= ' "' . $db->config['password'] . '"'; - $handle = popen($script . ' 2>&1', 'r'); - //echo "

Handle: $handle; " . gettype($handle) . "\n"; - echo "

\n";
-    while (($read = fread($handle, 2096))) {
-      echo $read;
-    }
-    echo "
\n"; - pclose($handle); - } - - /************************************************************************** ************************************************************************** ************************************************************************** diff --git a/site/app_model.php b/site/app_model.php index b133f58..d83a8fe 100644 --- a/site/app_model.php +++ b/site/app_model.php @@ -509,7 +509,7 @@ class AppModel extends Model { function INTERNAL_ERROR($msg, $depth = 0, $force_stop = false) { INTERNAL_ERROR($msg, $force_stop, $depth+1); - echo $this->requestAction(array('controller' => 'accounts', + echo $this->requestAction(array('controller' => 'util', 'action' => 'render_empty'), array('return', 'bare' => false) ); diff --git a/site/controllers/util_controller.php b/site/controllers/util_controller.php new file mode 100644 index 0000000..09051a0 --- /dev/null +++ b/site/controllers/util_controller.php @@ -0,0 +1,60 @@ +layout = null; + $this->autoLayout = false; + $this->autoRender = false; + Configure::write('debug', '0'); + $script = $_SERVER['DOCUMENT_ROOT'] . '/pmgr/build.cmd'; + echo "

" . date('r') . "\n"; + //echo "

Script: $script" . "\n"; + $handle = popen($script . ' 2>&1', 'r'); + //echo "

Handle: $handle; " . gettype($handle) . "\n"; + echo "

\n";
+    while (($read = fread($handle, 2096))) {
+      echo $read;
+    }
+    echo "
\n"; + pclose($handle); + } + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: rebuild_sandbox + */ + + function rebuild_sandbox() { + $this->layout = null; + $this->autoLayout = false; + $this->autoRender = false; + Configure::write('debug', '2'); + $script = preg_replace('%/webroot/index.php%', + '/build_sandbox.cmd', + $_SERVER['SCRIPT_FILENAME']); + echo "

" . date('r') . "\n"; + echo "

Script: $script" . "\n"; + $handle = popen($script . ' 2>&1', 'r'); + //echo "

Handle: $handle; " . gettype($handle) . "\n"; + echo "

\n";
+    while (($read = fread($handle, 2096))) {
+      echo $read;
+    }
+    echo "
\n"; + pclose($handle); + } + + + +}