diff --git a/module/bug/control.php b/module/bug/control.php index ff0ce859ce..fc8934d466 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -825,6 +825,39 @@ class bug extends control $this->display(); } + /** + * Batch close bugs. + * + * @access public + * @return void + */ + public function batchClose() + { + if($this->post->bugIDList) + { + $bugIDList = $this->post->bugIDList; + foreach($_POST as $postKey => $postValue) unset($_POST[$postKey]); + + $bugs = $this->bug->getList($bugIDList); + foreach($bugs as $bugID => $bug) + { + if($bug->status != 'resolved') + { + if($bug->status != 'closed') $skipBugs[$bugID] = $bugID; + continue; + } + + $this->bug->close($bugID); + + $actionID = $this->action->create('bug', $bugID, 'Closed'); + $this->sendmail($bugID, $actionID); + } + + if(isset($skipBugs)) echo js::alert(sprintf($this->lang->bug->skipClose, join(',', $skipBugs))); + } + die(js::reload('parent')); + } + /** * Confirm story change. * diff --git a/module/bug/lang/en.php b/module/bug/lang/en.php index 5cf9357a1b..e4ed89c083 100644 --- a/module/bug/lang/en.php +++ b/module/bug/lang/en.php @@ -155,6 +155,7 @@ $lang->bug->confirmChangeProduct = 'Change product will change project, task and $lang->bug->confirmDelete = 'Are you sure to delete this bug?'; $lang->bug->setTemplateTitle = 'Please input the template title:'; $lang->bug->remindTask = 'This bug has been to be a task, update the task:%s or not?'; +$lang->bug->skipClose = 'The status of bug:%s are not resolved, so can not close!'; /* Templates. */ $lang->bug->tplStep = "
[Steps]
\n"; diff --git a/module/bug/lang/zh-cn.php b/module/bug/lang/zh-cn.php index 7f84f97e37..b20f15e00e 100644 --- a/module/bug/lang/zh-cn.php +++ b/module/bug/lang/zh-cn.php @@ -155,6 +155,7 @@ $lang->bug->confirmChangeProduct = '修改产品会导致相应的项目、需 $lang->bug->confirmDelete = '您确认要删除该Bug吗?'; $lang->bug->setTemplateTitle = '请输入bug模板标题(保存之前请先填写bug重现步骤):'; $lang->bug->remindTask = '该Bug已经转化为任务,是否更新任务(编号:%s)状态 ?'; +$lang->bug->skipClose = 'Bug %s 不是已解决状态,不能关闭。'; /* 模板。*/ $lang->bug->tplStep = "[步骤]
\n"; diff --git a/module/bug/model.php b/module/bug/model.php index e607c89bb8..100ff52e7f 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -194,6 +194,21 @@ class bugModel extends model return $bug; } + /** + * Get bug list. + * + * @param int|array|string $bugIDList + * @access public + * @return array + */ + public function getList($bugIDList = 0) + { + return $this->dao->select('*')->from(TABLE_BUG) + ->where('deleted')->eq(0) + ->beginIF($bugIDList)->andWhere('id')->in($bugIDList)->fi() + ->fetchAll('id'); + } + /** * getActiveBugs * @@ -353,7 +368,7 @@ class bugModel extends model * * @param int $bugID * @access public - * @return void + * @return string */ public function assign($bugID) { @@ -406,11 +421,11 @@ class bugModel extends model */ public function batchConfirm($bugIDList) { - $now = helper::now(); + $now = helper::now(); + $bugs = $this->getList($bugIDList); foreach($bugIDList as $bugID) { - $oldBug = $this->getById($bugID); - if($oldBug->confirmed) continue; + if($bugs[$bugID]->confirmed) continue; $bug = new stdclass(); $bug->assignedTo = $this->app->user->account; @@ -466,10 +481,11 @@ class bugModel extends model */ public function batchResolve($bugIDList, $resolution, $resolvedBuild) { - $now = helper::now(); + $now = helper::now(); + $bugs = $this->getList($bugIDList); foreach($bugIDList as $bugID) { - $oldBug = $this->getById($bugID); + $oldBug = $bugs[$bugID]; if($oldBug->status != 'active') continue; $bug = new stdClass(); $bug->resolution = $resolution; @@ -528,7 +544,6 @@ class bugModel extends model */ public function close($bugID) { - $oldBug = $this->getById($bugID); $now = helper::now(); $bug = fixer::input('post') ->add('assignedTo', 'closed') diff --git a/module/bug/view/browse.custom.html.php b/module/bug/view/browse.custom.html.php index 9c54c6195c..ac662a7cf2 100644 --- a/module/bug/view/browse.custom.html.php +++ b/module/bug/view/browse.custom.html.php @@ -1,6 +1,6 @@| + |
@@ -74,7 +74,13 @@
edit);
+
+ $actionLink = $this->createLink('bug', 'batchEdit', "productID=$productID");
+ $misc = common::hasPriv('bug', 'batchEdit') ? "onclick=\"setFormAction('$actionLink')\"" : "disabled='disabled'";
+ echo "
@@ -87,3 +93,60 @@
";
+ echo html::commonButton($lang->edit, $misc);
+ echo "";
+ echo " ";
?>
|