diff --git a/module/bug/control.php b/module/bug/control.php index c567fe085a..2ac98c8b18 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -176,6 +176,7 @@ class bug extends control $this->view->builds = $this->loadModel('build')->getBuildPairs($productID, 'all'); $this->view->linkCommits = $this->loadModel('repo')->getCommitsByObject($bugID, 'bug'); $this->view->actionList = $this->loadModel('bug')->buildOperateMenu($bug, 'view'); + $this->view->actions = $this->loadModel('action')->getList('bug', $bugID); $this->display(); } @@ -317,26 +318,25 @@ class bug extends control public function assignTo(int $bugID) { /* Get old bug, and check privilege of the execution. */ - $bug = $this->bug->getById($bugID); - $this->bugZen->checkBugExecutionPriv($bug); + $oldBug = $this->bug->getById($bugID); + $this->bugZen->checkBugExecutionPriv($oldBug); /* Set menu. */ - $this->qa->setMenu($this->products, $bug->product, $bug->branch); + $this->qa->setMenu($this->products, $oldBug->product, $oldBug->branch); if(!empty($_POST)) { /* Init bug data. */ - $bug = form::data($this->config->bug->form->assignTo) - ->add('id', $bugID) - ->get(); + $bug = form::data($this->config->bug->form->assignTo)->add('id', $bugID)->get(); + + if($oldBug->status != 'closed') $this->bug->assign($bug); - $this->bug->assign($bug, $this->post->comment); 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, $changes)); + return $this->send($this->bugZen->responseAfterOperate($bugID)); } /* Get assigned to member. */ @@ -350,11 +350,9 @@ class bug extends control } /* Show the variables associated. */ - $this->view->title = $this->products[$bug->product] . $this->lang->colon . $this->lang->bug->assignedTo; - $this->view->users = $users; - $this->view->bug = $bug; - $this->view->bugID = $bugID; - $this->view->actions = $this->action->getList('bug', $bugID); + $this->view->title = $this->products[$oldBug->product] . $this->lang->colon . $this->lang->bug->assignedTo; + $this->view->users = $users; + $this->view->bug = $oldBug; $this->display(); } diff --git a/module/bug/model.php b/module/bug/model.php index 9046142dec..302c6bf080 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -560,16 +560,13 @@ class bugModel extends model * Assign a bug to a user. * * @param object $bug - * @param string $comment * @access public - * @return array|false + * @return bool */ - public function assign(object $bug, string $comment = ''): array|false + public function assign(object $bug): bool { /* Get old bug. */ $oldBug = $this->getById($bug->id); - /* If status of the bug is closed, skip it. */ - if($oldBug->status == 'closed') return false; /* Update assigned of the bug. */ $this->dao->update(TABLE_BUG) @@ -583,10 +580,10 @@ class bugModel extends model /* Record log. */ $changes = common::createChanges($oldBug, $bug); - $actionID = $this->loadModel('action')->create('bug', $bug->id, 'Assigned', $comment, $bug->assignedTo); - $this->action->logHistory($actionID, $changes); + $actionID = $this->loadModel('action')->create('bug', $bug->id, 'Assigned', $this->post->comment, $bug->assignedTo); + if($changes) $this->action->logHistory($actionID, $changes); - return $changes; + return !dao::isError(); } /**