diff --git a/module/my/control.php b/module/my/control.php index 2e3efc3220..3cf5216ea5 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -393,6 +393,7 @@ EOF; */ public function task($type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { + $this->loadModel('task'); /* Save session. */ if($this->app->viewType != 'json') $this->session->set('taskList', $this->app->getURI(true), 'execution'); @@ -405,7 +406,14 @@ EOF; $sort = common::appendOrder($orderBy); /* Get tasks. */ - $tasks = $this->loadModel('task')->getUserTasks($this->app->user->account, $type, 0, $pager, $sort); + if($type == 'assignedBy') + { + $tasks = $this->my->getAssignedByMe($this->app->user->account, 0, $pager, $sort, 0, 'task'); + } + else + { + $tasks = $this->task->getUserTasks($this->app->user->account, $type, 0, $pager, $sort); + } $parents = array(); $executionIDList = array(); @@ -480,6 +488,7 @@ EOF; public function bug($type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { /* Save session. load Lang. */ + $this->loadModel('bug'); if($this->app->viewType != 'json') $this->session->set('bugList', $this->app->getURI(true), 'qa'); $this->app->loadLang('bug'); @@ -490,7 +499,15 @@ EOF; /* Append id for secend sort. */ $sort = common::appendOrder($orderBy); - $bugs = $this->loadModel('bug')->getUserBugs($this->app->user->account, $type, $sort, 0, $pager); + if($type == 'assignedBy') + { + $bugs = $this->loadModel('my')->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'bug'); + } + else + { + $bugs = $this->loadModel('bug')->getUserBugs($this->app->user->account, $type, $sort, 0, $pager); + } + $bugs = $this->bug->checkDelayedBugs($bugs); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug', false); @@ -752,7 +769,7 @@ EOF; $this->view->orderBy = $orderBy; $this->view->pager = $pager; $this->view->type = $type; - $this->view->issues = $this->loadModel('issue')->getUserIssues($type, $this->app->user->account, $orderBy, $pager); + $this->view->issues = $type == 'assignedBy' ? $this->loadModel('my')->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'issue') : $this->loadModel('issue')->getUserIssues($type, $this->app->user->account, $orderBy, $pager); $this->view->projectList = $this->loadModel('project')->getPairsByProgram(); @@ -773,6 +790,7 @@ EOF; public function risk($type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { /* Set the pager. */ + $this->loadModel('risk'); $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); @@ -780,7 +798,7 @@ EOF; $this->view->title = $this->lang->my->risk; $this->view->position[] = $this->lang->my->risk; - $this->view->risks = $this->loadModel('risk')->getUserRisks($type, $this->app->user->account, $orderBy, $pager); + $this->view->risks = $type == 'assignedBy' ? $this->loadModel('my')->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'risk') : $this->loadModel('risk')->getUserRisks($type, $this->app->user->account, $orderBy, $pager); $this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter'); $this->view->orderBy = $orderBy; $this->view->pager = $pager; @@ -857,7 +875,7 @@ EOF; $this->app->loadClass('pager', $static = true); if($this->app->getViewType() == 'mhtml') $recPerPage = 10; $pager = pager::init($recTotal, $recPerPage, $pageID); - $ncList = $this->my->getNcList($browseType, $orderBy, $pager, 'active'); + $ncList = $browseType == 'assignedBy' ? $this->loadModel('my')->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'nc') : $this->my->getNcList($browseType, $orderBy, $pager, 'active'); foreach($ncList as $nc) $ncIdList[] = $nc->id; $this->session->set('ncIdList', isset($ncIdList) ? $ncIdList : ''); diff --git a/module/my/lang/de.php b/module/my/lang/de.php index b558580030..ae56776df9 100644 --- a/module/my/lang/de.php +++ b/module/my/lang/de.php @@ -56,7 +56,7 @@ $lang->my->taskMenu->assignedToMe = 'AssignedToMe'; $lang->my->taskMenu->openedByMe = 'CreatedByMe'; $lang->my->taskMenu->finishedByMe = 'FinishedByMe'; $lang->my->taskMenu->closedByMe = 'ClosedByMe'; -$lang->my->taskMenu->canceledByMe = 'CancelledByMe'; +$lang->my->taskMenu->assignedByMe = 'AssignedByMe'; $lang->my->storyMenu = new stdclass(); $lang->my->storyMenu->assignedToMe = 'AssignedToMe'; diff --git a/module/my/lang/en.php b/module/my/lang/en.php index 4705823a20..f97a214255 100644 --- a/module/my/lang/en.php +++ b/module/my/lang/en.php @@ -66,6 +66,7 @@ $lang->my->taskMenu->openedByMe = 'CreatedByMe'; $lang->my->taskMenu->finishedByMe = 'FinishedByMe'; $lang->my->taskMenu->closedByMe = 'ClosedByMe'; $lang->my->taskMenu->canceledByMe = 'CancelledByMe'; +$lang->my->taskMenu->assignedByMe = 'AssignedByMe'; $lang->my->storyMenu = new stdclass(); $lang->my->storyMenu->assignedToMe = 'AssignedToMe'; diff --git a/module/my/lang/fr.php b/module/my/lang/fr.php index b558580030..a1020163b0 100644 --- a/module/my/lang/fr.php +++ b/module/my/lang/fr.php @@ -57,6 +57,7 @@ $lang->my->taskMenu->openedByMe = 'CreatedByMe'; $lang->my->taskMenu->finishedByMe = 'FinishedByMe'; $lang->my->taskMenu->closedByMe = 'ClosedByMe'; $lang->my->taskMenu->canceledByMe = 'CancelledByMe'; +$lang->my->taskMenu->assignedByMe = 'AssignedByMe'; $lang->my->storyMenu = new stdclass(); $lang->my->storyMenu->assignedToMe = 'AssignedToMe'; diff --git a/module/my/lang/zh-cn.php b/module/my/lang/zh-cn.php index 93e5ddba0d..763e49b434 100644 --- a/module/my/lang/zh-cn.php +++ b/module/my/lang/zh-cn.php @@ -66,6 +66,7 @@ $lang->my->taskMenu->openedByMe = '由我创建'; $lang->my->taskMenu->finishedByMe = '由我完成'; $lang->my->taskMenu->closedByMe = '由我关闭'; $lang->my->taskMenu->canceledByMe = '由我取消'; +$lang->my->taskMenu->assignedByMe = '由我指派'; $lang->my->storyMenu = new stdclass(); $lang->my->storyMenu->assignedToMe = '指派给我'; diff --git a/module/my/lang/zh-tw.php b/module/my/lang/zh-tw.php index 9bbe89a5ba..dc42ee55d2 100644 --- a/module/my/lang/zh-tw.php +++ b/module/my/lang/zh-tw.php @@ -65,6 +65,7 @@ $lang->my->taskMenu->openedByMe = '由我創建'; $lang->my->taskMenu->finishedByMe = '由我完成'; $lang->my->taskMenu->closedByMe = '由我關閉'; $lang->my->taskMenu->canceledByMe = '由我取消'; +$lang->my->taskMenu->assignedByMe = '由我指派'; $lang->my->storyMenu = new stdclass(); $lang->my->storyMenu->assignedToMe = '指派給我'; diff --git a/module/my/model.php b/module/my/model.php index 3941377e1e..7ab57208a6 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -309,4 +309,56 @@ class myModel extends model return $actions; } + + /** + * Get assigned by me objects. + * + * @param string $account + * @param int $limit + * @param string $orderBy + * @param int $pager + * @param int $projectID + * @param string $objectType + * @access public + * @return array + */ + public function getAssignedByMe($account, $limit = 0, $pager = null, $orderBy = "id_desc", $projectID = 0, $objectType = '') + { + $this->loadModel($objectType); + $objectList = $this->dao->select('t1.*') + ->from($this->config->objectTables[$objectType])->alias('t1') + ->leftJoin(TABLE_ACTION)->alias('t2')->on("t1.id = t2.objectID and t2.objectType='{$objectType}'") + ->where('t2.actor')->eq($account) + ->andWhere('t2.action')->eq('assigned') + ->andWhere('t1.deleted')->eq(0) + ->orderBy($orderBy) + ->page($pager, 't1.id') + ->fetchAll('id'); + + if($objectType == 'task') + { + $projectList = array(); + foreach($objectList as $task) $projectList[$task->project] = $task->project; + $projectPairs = $this->dao->select('id,name')->from(TABLE_PROJECT)->where('id')->in($projectList)->fetchPairs('id'); + foreach($objectList as $task) $task->projectName = zget($projectPairs, $task->project); + + $executionList = array(); + foreach($objectList as $task) $executionList[$task->execution] = $task->execution; + $executionPairs = $this->dao->select('id,name')->from(TABLE_PROJECT)->where('id')->in($executionList)->fetchPairs('id'); + foreach($objectList as $task) $task->executionName = zget($executionPairs, $task->execution); + + if($objectList) return $this->loadModel('task')->processTasks($objectList); + return array(); + } + + if($objectType == 'bug') + { + $productList = array(); + foreach($objectList as $bug) $productList[$bug->product] = $bug->product; + $productPairs = $this->dao->select('id,name')->from(TABLE_PRODUCT)->where('id')->in($productList)->fetchPairs('id'); + foreach($objectList as $bug) $bug->productName = zget($productPairs, $bug->product); + } + + return $objectList; + } } diff --git a/module/my/view/bug.html.php b/module/my/view/bug.html.php index c347928130..b3705442c5 100644 --- a/module/my/view/bug.html.php +++ b/module/my/view/bug.html.php @@ -23,6 +23,7 @@ echo html::a(inlink($app->rawMethod, "mode=$mode&type=openedBy"), "{$lang->bug->openedByMe}" . ($type == 'openedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'openedBy' ? ' btn-active-text' : '') . "'"); echo html::a(inlink($app->rawMethod, "mode=$mode&type=resolvedBy"), "{$lang->bug->resolvedByMe}" . ($type == 'resolvedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'resolvedBy' ? ' btn-active-text' : '') . "'"); echo html::a(inlink($app->rawMethod, "mode=$mode&type=closedBy"), "{$lang->bug->closedByMe}" . ($type == 'closedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'closedBy' ? ' btn-active-text' : '') . "'"); + echo html::a(inlink($app->rawMethod, "mode=$mode&type=assignedBy"), "{$lang->my->assignedByMe}" . ($type == 'assignedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'assignedBy' ? ' btn-active-text' : '') . "'"); } ?> diff --git a/module/my/view/task.html.php b/module/my/view/task.html.php index 68520fe242..54b0acd24d 100644 --- a/module/my/view/task.html.php +++ b/module/my/view/task.html.php @@ -20,10 +20,11 @@ {$pager->recTotal}"; ?> rawMethod == 'contribute'):?> rawMethod, "mode=$mode&type=openedBy"), "{$lang->my->taskMenu->openedByMe}" . ($type == 'openedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'openedBy' ? ' btn-active-text' : '') . "'"); - echo html::a(inlink($app->rawMethod, "mode=$mode&type=finishedBy"), "{$lang->my->taskMenu->finishedByMe}" . ($type == 'finishedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'finishedBy' ? ' btn-active-text' : '') . "'"); - echo html::a(inlink($app->rawMethod, "mode=$mode&type=closedBy"), "{$lang->my->taskMenu->closedByMe}" . ($type == 'closedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'closedBy' ? ' btn-active-text' : '') . "'"); - echo html::a(inlink($app->rawMethod, "mode=$mode&type=canceledBy"), "{$lang->my->taskMenu->canceledByMe}" . ($type == 'canceledBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'canceledBy' ? ' btn-active-text' : '') . "'"); + echo html::a(inlink($app->rawMethod, "mode=$mode&type=openedBy"), "{$lang->my->taskMenu->openedByMe}" . ($type == 'openedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'openedBy' ? ' btn-active-text' : '') . "'"); + echo html::a(inlink($app->rawMethod, "mode=$mode&type=finishedBy"), "{$lang->my->taskMenu->finishedByMe}" . ($type == 'finishedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'finishedBy' ? ' btn-active-text' : '') . "'"); + echo html::a(inlink($app->rawMethod, "mode=$mode&type=closedBy"), "{$lang->my->taskMenu->closedByMe}" . ($type == 'closedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'closedBy' ? ' btn-active-text' : '') . "'"); + echo html::a(inlink($app->rawMethod, "mode=$mode&type=canceledBy"), "{$lang->my->taskMenu->canceledByMe}" . ($type == 'canceledBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'canceledBy' ? ' btn-active-text' : '') . "'"); + echo html::a(inlink($app->rawMethod, "mode=$mode&type=assignedBy"), "{$lang->my->taskMenu->assignedByMe}" . ($type == 'assignedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'assignedBy' ? ' btn-active-text' : '') . "'"); ?>