From 8000d57e9d6cc05474d7a7ac116fc61c97084408 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 1 Nov 2017 13:26:03 +0800 Subject: [PATCH] * adjust for save custom with global. --- module/custom/control.php | 2 +- module/custom/model.php | 9 +++++---- module/datatable/control.php | 9 +++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/module/custom/control.php b/module/custom/control.php index 8d260f6bbb..997238d05c 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -442,8 +442,8 @@ class custom extends control if($confirm == 'no') die(js::confirm($this->lang->custom->confirmRestore, inlink('ajaxRestoreMenu', "setPublic=$setPublic&confirm=yes"))); $account = $this->app->user->account; - if($setPublic) $account = 'system'; $this->loadModel('setting')->deleteItems("owner={$account}&module=common§ion=customMenu"); + if($setPublic) $this->setting->deleteItems("owner=system&module=common§ion=customMenu"); die(js::reload('parent.parent')); } diff --git a/module/custom/model.php b/module/custom/model.php index 978859cc16..c0f4716031 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -358,20 +358,21 @@ class customModel extends model $settingKey = ''; $setPublic = $this->post->setPublic; - if($setPublic) $account = 'system'; if(!is_string($menu)) $menu = json_encode($menu); $flow = $this->config->global->flow; if(empty($method)) { - $settingKey = "$account.common.customMenu.{$flow}_{$module}"; + $settingKey = "common.customMenu.{$flow}_{$module}"; } else { - $settingKey = "$account.common.customMenu.{$flow}_feature_{$module}_{$method}"; + $settingKey = "common.customMenu.{$flow}_feature_{$module}_{$method}"; } - $this->loadModel('setting')->setItem($settingKey, $menu); + $this->loadModel('setting')->setItem($account . '.' . $settingKey, $menu); + if($setPublic) $this->setting->setItem('system.' . $settingKey, $menu); + $this->loadModel('score')->score('ajax', 'customMenu'); } diff --git a/module/datatable/control.php b/module/datatable/control.php index bfcbd6fea0..365847ced9 100644 --- a/module/datatable/control.php +++ b/module/datatable/control.php @@ -33,11 +33,12 @@ class datatable extends control if(!empty($_POST)) { $account = $this->app->user->account; - if($this->post->global) $account = 'system'; if($account == 'guest') $this->send(array('result' => 'fail', 'target' => $target, 'message' => 'guest.')); - $name = $account . '.datatable.' . $this->post->target . '.' . $this->post->name; - $this->loadModel('setting')->setItem($name, $this->post->value); + $name = 'datatable.' . $this->post->target . '.' . $this->post->name; + $this->loadModel('setting')->setItem($account . '.' . $name, $this->post->value); + if($this->post->global) $this->setting->setItem('system.' . $name, $this->post->value); + if(dao::isError()) $this->send(array('result' => 'fail', 'message' => 'dao error.')); $this->send(array('result' => 'success')); } @@ -105,9 +106,9 @@ class datatable extends control $target = $module . ucfirst($method); $mode = isset($this->config->datatable->$target->mode) ? $this->config->datatable->$target->mode : 'table'; $key = $mode == 'datatable' ? 'cols' : 'tablecols'; - if($system) $account = 'system'; $this->loadModel('setting')->deleteItems("owner=$account&module=datatable§ion=$target&key=$key"); + if($system) $this->setting->deleteItems("owner=system&module=datatable§ion=$target&key=$key"); die(js::reload('parent')); } }