From 683b1d4dabb9d35243d5c6cd648bdd5daef4b478 Mon Sep 17 00:00:00 2001 From: wyd621 Date: Thu, 13 Mar 2014 01:14:30 +0000 Subject: [PATCH 1/2] * fix a bug #580. --- module/common/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/common/model.php b/module/common/model.php index 20d611015b..a914b5fa47 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -387,7 +387,7 @@ class commonModel extends model echo ""; echo "\n"; } From 38e449f8bbc51613ac80df085b3ab9e617425447 Mon Sep 17 00:00:00 2001 From: wyd621 Date: Thu, 13 Mar 2014 01:58:09 +0000 Subject: [PATCH 2/2] * finish task #1803. --- module/bug/control.php | 33 +++++++++++++ module/bug/lang/en.php | 1 + module/bug/lang/zh-cn.php | 1 + module/bug/model.php | 29 ++++++++--- module/bug/view/browse.custom.html.php | 67 +++++++++++++++++++++++++- module/bug/view/browse.html.php | 4 ++ module/my/view/bug.html.php | 16 +++++- module/task/control.php | 16 ++++-- module/task/lang/en.php | 1 + module/task/lang/zh-cn.php | 1 + module/task/model.php | 15 ++++++ 11 files changed, 169 insertions(+), 15 deletions(-) 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 "
"; + echo html::commonButton($lang->edit, $misc); + echo ""; + echo "
"; ?>
@@ -87,3 +93,60 @@
+ + + + + + diff --git a/module/bug/view/browse.html.php b/module/bug/view/browse.html.php index 13660406e6..5f5b6d3e6a 100644 --- a/module/bug/view/browse.html.php +++ b/module/bug/view/browse.html.php @@ -216,6 +216,10 @@ if($customed) $misc = common::hasPriv('bug', 'batchConfirm') ? "onclick=\"setFormAction('$actionLink','hiddenwin')\"" : "class='disabled'"; echo "
  • " . html::a('#', $lang->bug->confirmBug, '', $misc) . "
  • "; + $actionLink = $this->createLink('bug', 'batchClose'); + $misc = common::hasPriv('bug', 'batchClose') ? "onclick=\"setFormAction('$actionLink','hiddenwin')\"" : "class='disabled'"; + echo "
  • " . html::a('#', $lang->bug->close, '', $misc) . "
  • "; + $misc = common::hasPriv('bug', 'batchResolve') ? "onmouseover='toggleSubMenu(this.id)' onmouseout='toggleSubMenu(this.id)' id='resolveItem'" : $class; echo "
  • " . html::a('#', $lang->bug->resolve, '', $misc) . "
  • "; ?> diff --git a/module/my/view/bug.html.php b/module/my/view/bug.html.php index cc65a51666..5527301799 100644 --- a/module/my/view/bug.html.php +++ b/module/my/view/bug.html.php @@ -70,7 +70,21 @@
    - edit);?> + createLink('bug', 'batchEdit', "productID=0"); + echo html::commonButton($lang->edit, "onclick=\"setFormAction('$actionLink')\""); + } + + if(common::hasPriv('bug', 'batchClose') and $type != 'closedBy') + { + $actionLink = $this->createLink('bug', 'batchClose'); + echo html::commonButton($lang->bug->close, "onclick=\"setFormAction('$actionLink','hiddenwin')\""); + } + ?>
    show();?> diff --git a/module/task/control.php b/module/task/control.php index aa83d134ca..c5a54eecc1 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -639,15 +639,20 @@ class task extends control { if($this->post->taskIDList) { - $tasks = $this->post->taskIDList; + $taskIDList = $this->post->taskIDList; unset($_POST['taskIDList']); $this->loadModel('action'); - foreach($tasks as $taskID) + $tasks = $this->task->getList($taskIDList); + foreach($tasks as $taskID => $task) { - $this->commonAction($taskID); - $task = $this->task->getById($taskID); - if($task->status == 'wait' or $task->status == 'doing') continue; + if($task->status == 'wait' or $task->status == 'doing') + { + $skipTasks[$taskID] = $taskID; + continue; + } + + if($task->status == 'closed') continue; $changes = $this->task->close($taskID); @@ -658,6 +663,7 @@ class task extends control $this->sendmail($taskID, $actionID); } } + if(isset($skipTasks)) echo js::alert(sprintf($this->lang->task->error->skipClose, join(',', $skipTasks))); } die(js::reload('parent')); } diff --git a/module/task/lang/en.php b/module/task/lang/en.php index 8416b24dc3..3cb971276c 100644 --- a/module/task/lang/en.php +++ b/module/task/lang/en.php @@ -151,6 +151,7 @@ $lang->task->error->consumedSmall = '"Consumed" must be more than consumed be $lang->task->error->consumedThisTime = 'Please input "hours"'; $lang->task->error->left = 'Please input "left"'; $lang->task->error->work = '"Comment" must be less than 255 characters'; +$lang->task->error->skipClose = 'The status of Tasks : %s are not finished or canceled, can not close.'; /* Report. */ $lang->task->report = new stdclass(); diff --git a/module/task/lang/zh-cn.php b/module/task/lang/zh-cn.php index 2c8fdced7e..42aaf9329c 100644 --- a/module/task/lang/zh-cn.php +++ b/module/task/lang/zh-cn.php @@ -151,6 +151,7 @@ $lang->task->error->consumedSmall = '"已经消耗"必须大于之前消耗'; $lang->task->error->consumedThisTime = '请填写"工时"'; $lang->task->error->left = '请填写"剩余"'; $lang->task->error->work = '"备注"必须小于255个字符'; +$lang->task->error->skipClose = '任务:%s 不是“已完成”或“已取消”状态,不能关闭!'; /* 统计报表。*/ $lang->task->report = new stdclass(); diff --git a/module/task/model.php b/module/task/model.php index 33a58259f4..08041f40c2 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -677,6 +677,21 @@ class taskModel extends model return $this->processTask($task); } + /** + * Get task list. + * + * @param int|array|string $taskIDList + * @access public + * @return array + */ + public function getList($taskIDList = 0) + { + return $this->dao->select('*')->from(TABLE_TASK) + ->where('deleted')->eq(0) + ->beginIF($taskIDList)->andWhere('id')->in($taskIDList)->fi() + ->fetchAll('id'); + } + /** * Get tasks list of a project. *