diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index 4286a8398..2292e1551 100644 --- a/e107_handlers/model_class.php +++ b/e107_handlers/model_class.php @@ -9,8 +9,8 @@ * e107 Base Model * * $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $ - * $Revision: 1.17 $ - * $Date: 2009-10-22 05:14:07 $ + * $Revision: 1.18 $ + * $Date: 2009-10-22 07:23:17 $ * $Author: e107coders $ */ @@ -1607,7 +1607,7 @@ class e_model_interface var $listQry; var $table; var $primary; - var $mode; // to work with $_GET and admin menu. + var $mode; // as found in the URL query. $_GET['mode] function __construct() { @@ -1617,32 +1617,9 @@ class e_model_interface function init() { - global $user_pref; + global $user_pref; // e107::getConfig('user') ?? - if(varset($_POST['update']) || varset($_POST['create'])) - { - - $id = intval($_POST['record_id']); - $this->submitPage($id); - } - - if(varset($_POST['delete'])) - { - $id = key($_POST['delete']); - $this->deleteRecord($id); - $_GET['mode'] = "list"; - } - - if(varset($_GET['mode'])=='create') - { - $id = varset($_POST['edit']) ? key($_POST['edit']) : ""; - $this->createRecord($id); - } - else - { - $this->listRecords(); - } - //TODO add options 'preferences page'. + $this->mode = varset($_GET['mode']) ? $_GET['mode'] : 'list'; if(isset($_POST['submit-e-columns'])) { @@ -1650,26 +1627,49 @@ class e_model_interface $user_pref[$column_pref_name] = $_POST['e-columns']; save_prefs('user'); } + + if(varset($_POST['update']) || varset($_POST['create'])) + { + + $id = intval($_POST['record_id']); + $this->saveRecord($id); + } + + if(varset($_POST['delete'])) + { + $id = key($_POST['delete']); + $this->deleteRecord($id); + $this->mode = "list"; + } + + if(varset($_POST['saveOptions'])) + { + $this->saveSettings(); + } + + if($this->mode) + { + $method = $this->mode."Page"; + $this->$method(); + } + } /** * Generic DB Record Listing Function. - * @param object $mode [optional] * @return */ - function listRecords($mode=FALSE) + function listPage() { $ns = e107::getRender(); $sql = e107::getDb(); $frm = e107::getForm(); $mes = e107::getMessage(); - - global $pref; - + $pref = e107::getConfig()->getPref(); $text = "