diff --git a/module/bug/control.php b/module/bug/control.php index 3a7007f17c..adbc7606ac 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -821,10 +821,10 @@ class bug extends control $actionID = $this->action->create('bug', $bugID, 'Edited'); $this->action->logHistory($actionID, $changes); } + $this->loadModel('score')->create('ajax', 'batchOther'); } - $this->loadModel('score')->create('ajax', 'batchOther'); - return array('load' => $this->session->bugList, 'closeModal' => true); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => $this->session->bugList)); } /** @@ -852,7 +852,8 @@ class bug extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('score')->create('ajax', 'batchOther'); } - return $this->send(array('result' => 'success', 'load' => $this->session->bugList)); + + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => $this->session->bugList)); } /** @@ -868,7 +869,7 @@ class bug extends control if(!empty($_POST) && isset($_POST['bugIdList'])) { $bugIdList = array_unique($this->post->bugIdList); - $this->bugZen->batchChangePlan($bugIdList, $planID); + $this->bugZen->batchChangePlanZen($bugIdList, $planID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('score')->create('ajax', 'batchOther'); @@ -955,29 +956,24 @@ class bug extends control */ public function batchResolve(string $resolution, string $resolvedBuild = '') { - if(!$this->post->bugIDList) return print(js::locate($this->session->bugList, 'parent')); - - /* Prepare resolve data. */ - $bugIdList = array_unique($this->post->bugIDList); - $oldBugs = $this->bug->getByIdList($bugIdList); - $bugIdList = $this->bugZen->batchResolveIdFilter($bugIdList, $oldBugs); - list($modules, $productQD) = $this->bugZen->getBatchResolveVars($oldBugs); - - /* Batch resolve bugs. */ - $changes = $this->bug->batchResolve($bugIdList, $resolution, $resolvedBuild, $oldBugs, $modules, $productQD); - if(dao::isError()) return print(js::error(dao::getError())); - - /* Link bug to build and release. */ - $this->bug->linkBugToBuild($bugIdList, $resolvedBuild); - - foreach($changes as $bugID => $bugChanges) + if(!empty($_POST) && isset($_POST['bugIdList'])) { - $actionID = $this->action->create('bug', $bugID, 'Resolved', '', $resolution); - $this->action->logHistory($actionID, $bugChanges); + /* Prepare resolve data. */ + $bugIdList = array_unique($this->post->bugIdList); + $bugs = $this->bug->getByIdList($bugIdList); + + $bugIdList = $this->bugZen->batchResolveIdFilter($bugIdList, $bugs); + list($modules, $productQD) = $this->bugZen->getBatchResolveVars($bugs); + + /* Batch resolve bugs. */ + $message = $this->bug->batchResolveZen($bugIdList, $resolution, $resolvedBuild, $bugs, $modules, $productQD); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + + $this->loadModel('score')->create('ajax', 'batchOther'); } - $this->loadModel('score')->create('ajax', 'batchOther'); - return print(js::locate($this->session->bugList, 'parent')); + if(empty($message)) $message = $this->lang->saveSuccess; + return $this->send(array('result' => 'success', 'message' => $message, 'load' => true)); } /** diff --git a/module/bug/model.php b/module/bug/model.php index 7d068c9e4d..8981977dfb 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -727,75 +727,7 @@ class bugModel extends model return $allChanges; } - /** - * 批量解决bug。 - * Batch resolve bugs. - * - * @param array $bugIdList - * @param string $resolution - * @param string $resolvedBuild - * @param object[] $oldBugs - * @param object[] $modules - * @param string $productQD - * @access public - * @return array - */ - public function batchResolve(array $bugIdList, string $resolution, string $resolvedBuild, array $oldBugs, array $modules, string $productQD): array - { - $isBiz = $this->config->edition == 'biz'; - $isMax = $this->config->edition == 'max'; - $users = $this->loadModel('user')->getPairs(); - $now = helper::now(); - $changes = array(); - foreach($bugIdList as $i => $bugID) - { - $oldBug = $oldBugs[$bugID]; - - /* Get bug assignedTo. */ - $assignedTo = $oldBug->openedBy; - if(!isset($users[$assignedTo])) - { - $assignedTo = ''; - $module = isset($modules[$oldBug->module]) ? $modules[$oldBug->module] : ''; - while($module) - { - if($module->owner and isset($users[$module->owner])) - { - $assignedTo = $module->owner; - break; - } - $module = isset($modules[$module->parent]) ? $modules[$module->parent] : ''; - } - if(empty($assignedTo)) $assignedTo = $productQD; - } - - $bug = new stdClass(); - $bug->resolution = $resolution; - $bug->resolvedBuild = $resolution == 'fixed' ? $resolvedBuild : ''; - $bug->resolvedBy = $this->app->user->account; - $bug->resolvedDate = $now; - $bug->status = 'resolved'; - $bug->confirmed = 1; - $bug->assignedTo = $assignedTo; - $bug->assignedDate = $now; - - $this->bugTao->updateByID((int)$bugID, $bug); - - $this->executeHooks((int)$bugID); - - if($oldBug->execution) $this->loadModel('kanban')->updateLane($oldBug->execution, 'bug'); - $changes[$bugID] = common::createChanges($oldBug, $bug); - - if(($isBiz || $isMax) && $oldBug->feedback && !isset($feedbacks[$oldBug->feedback])) - { - $feedbacks[$oldBug->feedback] = $oldBug->feedback; - $this->loadModel('feedback')->updateStatus('bug', $oldBug->feedback, $bug->status, $oldBug->status); - } - } - - return $changes; - } /** * 激活一个bug。 diff --git a/module/bug/zen.php b/module/bug/zen.php index 7ff1cab225..7d19aa7006 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -2289,7 +2289,7 @@ class bugZen extends bug * @access public * @return bool */ - protected function batchChangePlan(array $bugIdList, int $planID): bool + protected function batchChangePlanZen(array $bugIdList, int $planID): bool { $oldBugs = $this->bug->getByIdList($bugIdList); $unlinkPlans = array(); @@ -2320,4 +2320,62 @@ class bugZen extends bug return !dao::isError(); } + + /** + * 批量解决bug。 + * Batch resolve bugs. + * + * @param array $bugIdList + * @param string $resolution + * @param string $resolvedBuild + * @param array $oldBugs + * @param array $modules + * @param string $productQD + * @access public + * @return string + */ + public function batchResolveZen(array $bugIdList, string $resolution, string $resolvedBuild, array $oldBugs, array $modules, string $productQD): string + { + $users = $this->loadModel('user')->getPairs(); + $now = helper::now(); + foreach($bugIdList as $i => $bugID) + { + $oldBug = $oldBugs[$bugID]; + + /* Get bug assignedTo. */ + $assignedTo = $oldBug->openedBy; + if(!isset($users[$assignedTo])) + { + $assignedTo = ''; + $module = isset($modules[$oldBug->module]) ? $modules[$oldBug->module] : ''; + while($module) + { + if($module->owner and isset($users[$module->owner])) + { + $assignedTo = $module->owner; + break; + } + $module = isset($modules[$module->parent]) ? $modules[$module->parent] : ''; + } + if(empty($assignedTo)) $assignedTo = $productQD; + } + + $bug = new stdClass(); + $bug->id = (int)$bugID; + $bug->resolution = $resolution; + $bug->resolvedBuild = $resolution == 'fixed' ? $resolvedBuild : ''; + $bug->resolvedBy = $this->app->user->account; + $bug->resolvedDate = $now; + $bug->status = 'resolved'; + $bug->confirmed = 1; + $bug->assignedTo = $assignedTo; + $bug->assignedDate = $now; + + $this->bug->resolve($bug); + + $message = $this->executeHooks($bug->id); + } + + return $message; + } }