From 1cb55567e5cff0bca16601708d2f30656a2b2fac Mon Sep 17 00:00:00 2001 From: wangyuting Date: Fri, 26 May 2023 11:15:42 +0800 Subject: [PATCH] * Optimize bug confirm function. --- module/bug/config/form.php | 1 - module/bug/control.php | 21 +++------------------ module/bug/model.php | 4 ++-- module/bug/zen.php | 4 +++- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/module/bug/config/form.php b/module/bug/config/form.php index 6145364b01..4663a2cc2b 100644 --- a/module/bug/config/form.php +++ b/module/bug/config/form.php @@ -168,4 +168,3 @@ $config->bug->form->confirm['assignedTo'] = array('required' => false, 'type $config->bug->form->confirm['assignedDate'] = array('required' => false, 'type' => 'string', 'default' => helper::now()); $config->bug->form->confirm['lastEditedBy'] = array('required' => false, 'type' => 'string', 'default' => $app->user->account); $config->bug->form->confirm['lastEditedDate'] = array('required' => false, 'type' => 'string', 'default' => helper::now()); -$config->bug->form->confirm['comment'] = array('required' => false, 'type' => 'string', 'default' => '', 'control' => 'editor'); diff --git a/module/bug/control.php b/module/bug/control.php index 2ac98c8b18..e6ea0a789b 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -294,8 +294,6 @@ class bug extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); } - $this->executeHooks($bugID); - /* Get response after editing bug. */ return $this->bugZen->responseAfterOperate($bugID, $changes, $kanbanGroup); } @@ -328,13 +326,12 @@ class bug extends control { /* Init bug data. */ $bug = form::data($this->config->bug->form->assignTo)->add('id', $bugID)->get(); + $bug = $this->loadModel('file')->processImgURL($bug, $this->config->bug->editor->assignto['id'], $this->post->uid); if($oldBug->status != 'closed') $this->bug->assign($bug); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $this->executeHooks($bugID); - /* Get response after assigning bug. */ return $this->send($this->bugZen->responseAfterOperate($bugID)); } @@ -383,20 +380,8 @@ class bug extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - /* 执行工作流的扩展动作。*/ - /* Execute extend actions.*/ - $message = $this->executeHooks($bugID); - - /* 弹窗内的返回。*/ - /* Respond in Modal. */ - if(isonlybody()) - { - $regionID = zget($kanbanData, 'regionID', 0); - $this->bugZen->responseInModal($bug->execution, '', $regionID); - } - - if(!$message) $message = $this->lang->saveSuccess; - return $this->send(array('result' => 'success', 'message' => $message, 'load' => $this->createLink('bug', 'view', "bugID=$bugID"))); + $regionID = zget($kanbanData, 'regionID', 0); + return $this->send($this->bugZen->responseAfterOperate($bugID, $changes, '', $regionID)); } $bug = $this->bug->getByID($bugID); diff --git a/module/bug/model.php b/module/bug/model.php index 302c6bf080..957692a87e 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -599,7 +599,7 @@ class bugModel extends model { $oldBug = $this->getByID($bug->id); - $this->dao->update(TABLE_BUG)->data($bug, $skip = 'comment')->autoCheck()->checkFlow()->where('id')->eq($bug->id)->exec(); + $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->checkFlow()->where('id')->eq($bug->id)->exec(); if(dao::isError()) return false; /* 确认 bug 后的积分变动。*/ @@ -621,7 +621,7 @@ class bugModel extends model $actionID = $this->loadModel('action')->create('bug', $oldBug->id, 'bugConfirmed', $this->post->comment); $this->action->logHistory($actionID, $changes); - return true; + return !dao::isError(); } /** diff --git a/module/bug/zen.php b/module/bug/zen.php index c2851b87a9..978e5e9337 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -462,6 +462,7 @@ class bugZen extends bug */ protected function responseAfterOperate(int $bugID, array $changes = array(), string $kanbanGroup = '', int $regionID = 0): array { + $message = $this->executeHooks($bugID); if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success', 'data' => $bugID)); /* 如果 bug 转任务并且 bug 的状态发生变化,提示是否更新任务状态。*/ @@ -484,7 +485,8 @@ class bugZen extends bug /* Respond after updating in modal. */ if(isonlybody()) return $this->responseInModal($bug->execution, $kanbanGroup, $regionID); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'load' => $this->createLink('bug', 'view', "bugID=$bugID"))); + if(!$message) $message = $this->lang->saveSuccess; + return $this->send(array('result' => 'success', 'message' => $message, 'closeModal' => true, 'load' => $this->createLink('bug', 'view', "bugID=$bugID"))); } /**