From 316e813fbeef4141e0d953f7753ff611a281346b Mon Sep 17 00:00:00 2001 From: leiyong <1549684884@qq.com> Date: Tue, 17 Nov 2020 09:23:06 +0800 Subject: [PATCH] * Fix bug. --- module/program/control.php | 25 ++++--------------------- module/program/lang/de.php | 1 + module/program/lang/en.php | 1 + module/program/lang/fr.php | 1 + module/program/lang/vi.php | 1 + module/program/lang/zh-cn.php | 1 + module/program/lang/zh-tw.php | 1 + module/program/model.php | 7 ++++++- module/program/view/prjcreate.html.php | 2 +- module/program/view/prjedit.html.php | 2 +- 10 files changed, 18 insertions(+), 24 deletions(-) diff --git a/module/program/control.php b/module/program/control.php index 6ac6926b41..964f7401e4 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -145,7 +145,7 @@ class program extends control if($_POST) { $projectID = $this->program->PGMCreate(); - if(dao::isError()) $this->send(array('result' => 'fail', 'message' => $this->processErrors(dao::getError()))); + if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('program', $projectID, 'opened'); $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('pgmbrowse'))); @@ -180,7 +180,7 @@ class program extends control if($_POST) { $changes = $this->program->PGMUpdate($programID); - if(dao::isError()) $this->send(array('result' => 'fail', 'message' => $this->processErrors(dao::getError()))); + if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); if($changes) { $actionID = $this->loadModel('action')->create('program', $programID, 'edited'); @@ -528,23 +528,6 @@ class program extends control $this->display(); } - /** - * Process program errors. - * - * @param array $errors - * @access public - * @return void - */ - public function processErrors($errors) - { - foreach($errors as $field => $error) - { - $errors[$field] = str_replace($this->lang->program->stage, $this->lang->program->common, $error); - } - - return $errors; - } - /** * Ajax get program drop menu. * @@ -741,7 +724,7 @@ class program extends control if($_POST) { $projectID = $this->program->PRJCreate(); - if(dao::isError()) $this->send(array('result' => 'fail', 'message' => $this->processErrors(dao::getError()))); + if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('project', $projectID, 'opened'); @@ -824,7 +807,7 @@ class program extends control if($_POST) { $changes = $this->program->PRJUpdate($projectID); - if(dao::isError()) $this->send(array('result' => 'fail', 'message' => $this->processErrors(dao::getError()))); + if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); if($changes) { diff --git a/module/program/lang/de.php b/module/program/lang/de.php index 0a8b813ab4..c39e7430d7 100644 --- a/module/program/lang/de.php +++ b/module/program/lang/de.php @@ -32,6 +32,7 @@ $lang->program->PRJAddWhitelist = 'Project Add Whitelist'; $lang->program->unbindWhielist = 'Project Remove Whitelist'; $lang->program->PRJManageProducts = 'Manage Products'; $lang->program->copyTitle = 'Please select an item to copy'; +$lang->program->errorSameProducts = 'Project cannot be associated with multiple identical products.'; /* Fields. */ $lang->program->common = 'Project'; diff --git a/module/program/lang/en.php b/module/program/lang/en.php index 0a8b813ab4..c39e7430d7 100644 --- a/module/program/lang/en.php +++ b/module/program/lang/en.php @@ -32,6 +32,7 @@ $lang->program->PRJAddWhitelist = 'Project Add Whitelist'; $lang->program->unbindWhielist = 'Project Remove Whitelist'; $lang->program->PRJManageProducts = 'Manage Products'; $lang->program->copyTitle = 'Please select an item to copy'; +$lang->program->errorSameProducts = 'Project cannot be associated with multiple identical products.'; /* Fields. */ $lang->program->common = 'Project'; diff --git a/module/program/lang/fr.php b/module/program/lang/fr.php index 0a8b813ab4..c39e7430d7 100644 --- a/module/program/lang/fr.php +++ b/module/program/lang/fr.php @@ -32,6 +32,7 @@ $lang->program->PRJAddWhitelist = 'Project Add Whitelist'; $lang->program->unbindWhielist = 'Project Remove Whitelist'; $lang->program->PRJManageProducts = 'Manage Products'; $lang->program->copyTitle = 'Please select an item to copy'; +$lang->program->errorSameProducts = 'Project cannot be associated with multiple identical products.'; /* Fields. */ $lang->program->common = 'Project'; diff --git a/module/program/lang/vi.php b/module/program/lang/vi.php index 0a8b813ab4..c39e7430d7 100644 --- a/module/program/lang/vi.php +++ b/module/program/lang/vi.php @@ -32,6 +32,7 @@ $lang->program->PRJAddWhitelist = 'Project Add Whitelist'; $lang->program->unbindWhielist = 'Project Remove Whitelist'; $lang->program->PRJManageProducts = 'Manage Products'; $lang->program->copyTitle = 'Please select an item to copy'; +$lang->program->errorSameProducts = 'Project cannot be associated with multiple identical products.'; /* Fields. */ $lang->program->common = 'Project'; diff --git a/module/program/lang/zh-cn.php b/module/program/lang/zh-cn.php index 780a68e40a..10f0859f82 100644 --- a/module/program/lang/zh-cn.php +++ b/module/program/lang/zh-cn.php @@ -32,6 +32,7 @@ $lang->program->PRJAddWhitelist = '项目添加白名单'; $lang->program->unbindWhielist = '项目删除白名单'; $lang->program->PRJManageProducts = '项目关联产品'; $lang->program->copyTitle = '请选择一个项目来复制'; +$lang->program->errorSameProducts = '项目不能关联多个相同的产品。'; /* Fields. */ $lang->program->common = '项目集'; diff --git a/module/program/lang/zh-tw.php b/module/program/lang/zh-tw.php index 7b7b6668e8..8bd722140e 100644 --- a/module/program/lang/zh-tw.php +++ b/module/program/lang/zh-tw.php @@ -32,6 +32,7 @@ $lang->program->PRJAddWhitelist = '項目添加白名單'; $lang->program->unbindWhielist = '項目刪除白名單'; $lang->program->PRJManageProducts = '項目關聯產品'; $lang->program->copyTitle = '請選擇一個項目來複制'; +$lang->program->errorSameProducts = '項目不能關聯多個相同的產品。'; /* Fields. */ $lang->program->common = '項目集'; diff --git a/module/program/model.php b/module/program/model.php index 68a33033e2..707c0a74d4 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -278,6 +278,8 @@ class programModel extends model } } + $this->lang->project->code = $this->lang->program->PGMCode; + $this->lang->project->name = $this->lang->program->PGMName; $program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->pgmcreate['id'], $this->post->uid); $this->dao->insert(TABLE_PROGRAM)->data($program) ->autoCheck() @@ -375,7 +377,8 @@ class programModel extends model } if(dao::isError()) return false; - + $this->lang->project->code = $this->lang->program->PGMCode; + $this->lang->project->name = $this->lang->program->PGMName; $this->dao->update(TABLE_PROGRAM)->data($program) ->autoCheck($skipFields = 'begin,end') ->batchcheck($this->config->program->PGMEdit->requiredFields, 'notempty') @@ -1276,6 +1279,8 @@ class programModel extends model $requiredFields = $this->config->program->PRJEdit->requiredFields; if($this->post->longTime) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ','); + $this->lang->project->name = $this->lang->program->PRJName; + $this->lang->project->code = $this->lang->program->PRJCode; $this->dao->update(TABLE_PROJECT)->data($project) ->autoCheck($skipFields = 'begin,end') ->batchcheck($requiredFields, 'notempty') diff --git a/module/program/view/prjcreate.html.php b/module/program/view/prjcreate.html.php index cf17100127..7065bbb211 100644 --- a/module/program/view/prjcreate.html.php +++ b/module/program/view/prjcreate.html.php @@ -18,7 +18,7 @@ project->weekend);?> -project->errorSameProducts);?> +program->errorSameProducts);?>