From 688db76a961b742afed8d6f1f160444ad5ae445a Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 10 Sep 2018 10:42:54 -0700 Subject: [PATCH] Admin-ui: New method: beforePrefsSave($new_data, $old_data); --- e107_handlers/admin_ui.php | 24 ++++++++++++++++++++++-- e107_plugins/_blank/admin_config.php | 5 +++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index 0f2c1e7bf..5b6b98d4b 100755 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -5947,8 +5947,17 @@ class e_admin_ui extends e_admin_controller_ui } /** - * User defined error handling, return true to suppress model messages - */ + * User defined before pref saving logic + * @param $new_data + * @param $old_data + */ + public function beforePrefsSave($new_data, $old_data) + { + } + + /** + * User defined error handling, return true to suppress model messages + */ public function onUpdateError($new_data, $old_data, $id) { } @@ -6007,6 +6016,16 @@ class e_admin_ui extends e_admin_controller_ui { $data = $this->getPosted(); + $beforePref = $data; + unset($beforePref['e-token'],$beforePref['etrigger_save']); + + $tmp = $this->beforePrefsSave($beforePref, $this->getConfig()->getPref()); + + if(!empty($tmp)) + { + $data = $tmp; + } + foreach($this->prefs as $k=>$v) // fix for empty checkboxes - need to save a value. { if(!isset($data[$k]) && $v['data'] !== false && ($v['type'] === 'checkboxes' || $v['type'] === 'checkbox')) @@ -6704,6 +6723,7 @@ class e_admin_form_ui extends e_form $fieldsets['confirm']['triggers']['hidden'] = $this->hidden('etrigger_batch', 'delete'); } + $id = null; $forms[$id] = array( 'id' => $this->getElementId(), // unique string used for building element ids, REQUIRED 'url' => e_REQUEST_SELF, // default diff --git a/e107_plugins/_blank/admin_config.php b/e107_plugins/_blank/admin_config.php index e2c48f210..419ec7322 100644 --- a/e107_plugins/_blank/admin_config.php +++ b/e107_plugins/_blank/admin_config.php @@ -296,6 +296,11 @@ class plugin_blank_admin_ui extends e_admin_ui $ns->tablerender("Hello",$text); } + + public function beforePrefsSave($new_data, $old_data) + { + // return $new_data; + } } class plugin_blank_admin_form_ui extends e_admin_form_ui