From 8ad5979b52daf5b6ae669d1768965fed4ed2bb59 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Mon, 10 Jul 2023 18:20:29 +0800 Subject: [PATCH] * Change send data and return value. --- module/custom/control.php | 12 +++++------- module/custom/ui/set.html.php | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/module/custom/control.php b/module/custom/control.php index 6bf74fe565..932a80561c 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -40,7 +40,7 @@ class custom extends control * @access public * @return void */ - public function set($module = 'story', $field = 'priList', $lang = '') + public function set(string $module = 'story', string $field = 'priList', string $lang = '') { if(empty($lang)) $lang = $this->app->getClientLang(); if($module == 'user' and $field == 'priList') $field = 'statusList'; @@ -206,6 +206,7 @@ class custom extends control } else { + if(!$this->post->keys) return $this->sendError(sprintf($this->lang->error->notempty, $this->lang->custom->key)); $lang = $_POST['lang']; $oldCustoms = $this->custom->getItems("lang=$lang&module=$module§ion=$field"); foreach($_POST['keys'] as $index => $key) @@ -261,7 +262,7 @@ class custom extends control } } if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('custom', 'set', "module=$module&field=$field&lang=" . ($lang == 'all' ? $lang : '')))); + return $this->sendSuccess(array('load' => $this->createLink('custom', 'set', "module=$module&field=$field&lang=" . ($lang == 'all' ? $lang : '')))); } /* Check whether the current language has been customized. */ @@ -298,14 +299,11 @@ class custom extends control * * @param string $module * @param string $field - * @param string $confirm * @access public * @return void */ - public function restore($module, $field, $confirm = 'no') + public function restore(string $module, string $field) { - if($confirm == 'no') return print(js::confirm($this->lang->custom->confirmRestore, inlink('restore', "module=$module&field=$field&confirm=yes"))); - if($module == 'user' and $field == 'contactField') { $this->loadModel('setting')->deleteItems("module=$module&key=$field"); @@ -314,7 +312,7 @@ class custom extends control { $this->custom->deleteItems("module=$module§ion=$field"); } - return print(js::reload('parent')); + return $this->sendSuccess(array('load' => true)); } /** diff --git a/module/custom/ui/set.html.php b/module/custom/ui/set.html.php index 712494e4e2..8a1ed6e07d 100644 --- a/module/custom/ui/set.html.php +++ b/module/custom/ui/set.html.php @@ -308,7 +308,7 @@ elseif($module == 'user' && $field == 'contactField') if(common::hasPriv('custom', 'restore')) { $formActions[] = array( - 'url' => inlink('restore', "module=user&field=contactField&confirm=yes"), + 'url' => inlink('restore', "module=user&field=contactField"), 'text' => $lang->custom->restore, 'class' => 'btn-wide ajax-submit', 'data-confirm' => $lang->custom->confirmRestore, @@ -347,6 +347,12 @@ else formRow ( + input + ( + set::type('hidden'), + set::name('systems[]'), + set::value('0') + ), formGroup ( set::width('1/2'), @@ -380,7 +386,13 @@ else ( set::type('hidden'), set::name('keys[]'), - set::value(isset($dbFields[$key]) ? $dbFields[$key]->value : $value) + set::value($key) + ), + input + ( + set::type('hidden'), + set::name('systems[]'), + set::value($system) ), formGroup ( @@ -422,7 +434,7 @@ else if(common::hasPriv('custom', 'restore')) { $formActions[] = array( - 'url' => inlink('restore', "module={$module}&field={$field}&confirm=yes"), + 'url' => inlink('restore', "module={$module}&field={$field}"), 'text' => $lang->custom->restore, 'class' => 'btn-wide ajax-submit', 'data-confirm' => $lang->custom->confirmRestore,