diff --git a/module/bug/config/form.php b/module/bug/config/form.php index 27af633f28..353f8b3f6e 100644 --- a/module/bug/config/form.php +++ b/module/bug/config/form.php @@ -82,7 +82,6 @@ $config->bug->form->close['lastEditedBy'] = array('required' => false, 'type' $config->bug->form->close['lastEditedDate'] = array('required' => false, 'type' => 'date', 'default' => helper::now()); $config->bug->form->close['closedBy'] = array('required' => false, 'type' => 'string', 'default' => $app->user->account); $config->bug->form->close['closedDate'] = array('required' => false, 'type' => 'date', 'default' => helper::now()); -$config->bug->form->close['comment'] = array('required' => false, 'type' => 'string', 'default' => ''); $config->bug->form->assignTo = array(); $config->bug->form->assignTo['assignedTo'] = array('required' => false, 'type' => 'string', 'default' => ''); diff --git a/module/bug/control.php b/module/bug/control.php index dc295553cd..8d8623c700 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -380,7 +380,7 @@ class bug extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $regionID = zget($kanbanData, 'regionID', 0); - return $this->send($this->bugZen->responseAfterOperate($bugID, $changes, '', $regionID)); + return $this->bugZen->responseAfterOperate($bugID, $changes, '', $regionID); } $bug = $this->bug->getByID($bugID); @@ -437,7 +437,7 @@ class bug extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $regionID = zget($output, 'regionID', 0); - return $this->send($this->bugZen->responseAfterOperate($bugID, $changes, '', $regionID)); + return $this->bugZen->responseAfterOperate($bugID, $changes, '', $regionID); } /* Remove 'Convert to story' from the solution list. */ @@ -481,7 +481,7 @@ class bug extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $regionID = zget($kanbanParams, 'regionID', 0); - return $this->send($this->bugZen->responseAfterOperate($bugID, $changes, '', $regionID)); + return $this->bugZen->responseAfterOperate($bugID, $changes, '', $regionID); } $this->checkBugExecutionPriv($oldBug); @@ -508,32 +508,28 @@ class bug extends control */ public function close(int $bugID, string $extra = '') { - $oldBug = $this->bug->getByID((int)$bugID); + $oldBug = $this->bug->getByID($bugID); if(!empty($_POST)) { - $data = form::data($this->config->bug->form->close); - - $bug = $this->bugZen->prepareCloseExtras($data, $bugID); - $this->bug->close($bug); - if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $extra = str_replace(array(',', ' '), array('&', ''), $extra); parse_str($extra, $output); - if($oldBug->execution) - { - $this->loadModel('kanban'); - if(!isset($output['toColID'])) $this->kanban->updateLane($oldBug->execution, 'bug', $bug->id); - if(isset($output['toColID'])) $this->kanban->moveCard($bug->id, $output['fromColID'], $output['toColID'], $output['fromLaneID'], $output['toLaneID']); - } - $this->executeHooks($bugID); + $bug = form::data($this->config->bug->form->close)->add('id', $bugID)->get(); + $bug = $this->loadModel('file')->processImgURL($bug, $this->config->bug->editor->close['id'], $this->post->uid); - return $this->send($this->bugZen->responseAfterOperate($bugID)); + $changes = $this->bug->close($bug, $output); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + + $regionID = zget($output, 'regionID', 0); + return $this->bugZen->responseAfterOperate($bugID, $changes, '', $regionID); } $this->bugZen->checkBugExecutionPriv($oldBug); - $this->bugZen->buildCloseForm($oldBug); + $this->view->bug = $oldBug; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); + $this->view->actions = $this->loadModel('action')->getList('bug', $oldBug->id); + $this->display(); } /** diff --git a/module/bug/model.php b/module/bug/model.php index abe80d64c4..b2a39605d2 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -911,7 +911,9 @@ class bugModel extends model } $bug->activatedCount = $oldBug->activatedCount + 1; + $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->checkFlow()->where('id')->eq($bug->id)->exec(); + if(dao::isError()) return false; /* Update build. */ $solveBuild = $this->dao->select('id, bugs')->from(TABLE_BUILD)->where("FIND_IN_SET('{$bug->id}', bugs)")->limit(1)->fetch(); @@ -947,30 +949,33 @@ class bugModel extends model * * @param object $bug * @access public - * @return bool + * @return array|false */ - public function close(object $bug): bool + public function close(object $bug, array $output): array|false { $oldBug = $this->getById($bug->id); - $this->dao->update(TABLE_BUG) - ->data($bug, '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; if(($this->config->edition == 'biz' || $this->config->edition == 'max') && $oldBug->feedback) $this->loadModel('feedback')->updateStatus('bug', $oldBug->feedback, $bug->status, $oldBug->status); $changes = common::createChanges($oldBug, $bug); - $actionID = $this->loadModel('action')->create('bug', $bug->id, 'Closed'); + $actionID = $this->loadModel('action')->create('bug', $bug->id, 'Closed', $this->post->comment); if($changes) $this->action->logHistory($actionID, $changes); + if($oldBug->execution) + { + $this->loadModel('kanban'); + if(!isset($output['toColID'])) $this->kanban->updateLane($oldBug->execution, 'bug', $bug->id); + if(isset($output['toColID'])) $this->kanban->moveCard($bug->id, $output['fromColID'], $output['toColID'], $output['fromLaneID'], $output['toLaneID']); + } + /* 给原bug的抄送人发送完消息后,再处理它。 */ /* After sending a message to the cc of the original bug, then process with it. */ $this->dao->update(TABLE_BUG)->set('assignedTo')->eq('closed')->where('id')->eq($bug->id)->exec(); - return !dao::isError(); + return $changes; } /** diff --git a/module/bug/zen.php b/module/bug/zen.php index 499f12cf7c..8b53dda663 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -1385,41 +1385,6 @@ class bugZen extends bug } } - /** - * 处理关闭bug页面的请求数据。 - * Prepare close request data. - * - * @param object $data - * @param int $bugID - * @access protected - * @return object - */ - protected function prepareCloseExtras(object $data, int $bugID): object - { - $bug = $data->add('id', $bugID) - ->stripTags($this->config->bug->editor->close['id'], $this->config->allowedTags) - ->get(); - - $bug = $this->loadModel('file')->processImgURL($bug, $this->config->bug->editor->close['id'], $this->post->uid); - return $bug; - } - - /** - * 构建关闭bug页面。 - * Build the page of close bug. - * - * @param object $bug - * @access protected - * @return void - */ - protected function buildCloseForm(object $bug) - { - $this->view->bug = $bug; - $this->view->users = $this->user->getPairs('noletter'); - $this->view->actions = $this->action->getList('bug', $bug->id); - $this->display(); - } - /** * Check bug execution priv. *