bug->noBug;?>
diff --git a/module/bug/lang/en.php b/module/bug/lang/en.php index b1cba31e03..8c1957c244 100644 --- a/module/bug/lang/en.php +++ b/module/bug/lang/en.php @@ -61,6 +61,7 @@ $lang->bug->openedDate = 'ReportedDate'; $lang->bug->openedDateAB = 'Reported'; $lang->bug->openedBuild = 'Open Build'; $lang->bug->assignedTo = 'AssignTo'; +$lang->bug->assignedToMe = 'AssignToMe'; $lang->bug->assignBug = 'AssignedTo'; $lang->bug->assignedToAB = 'AssignedTo'; $lang->bug->assignedDate = 'AssignedDate'; diff --git a/module/bug/lang/zh-cn.php b/module/bug/lang/zh-cn.php index c77c47c11f..52d5277a7c 100644 --- a/module/bug/lang/zh-cn.php +++ b/module/bug/lang/zh-cn.php @@ -61,6 +61,7 @@ $lang->bug->openedDate = '创建日期'; $lang->bug->openedDateAB = '创建日期'; $lang->bug->openedBuild = '影响版本'; $lang->bug->assignedTo = '指派给'; +$lang->bug->assignedToMe = '指派给我'; $lang->bug->assignBug = '指派给'; $lang->bug->assignedToAB = '指派给'; $lang->bug->assignedDate = '指派日期'; diff --git a/module/bug/model.php b/module/bug/model.php index 723d90e267..59a3ce2bae 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1601,18 +1601,62 @@ class bugModel extends model * @param int $limit * @param object $pager * @param int $executionID + * @param int $queryID * @access public - * @return void + * @return array */ - public function getUserBugs($account, $type = 'assignedTo', $orderBy = 'id_desc', $limit = 0, $pager = null, $executionID = 0) + public function getUserBugs($account, $type = 'assignedTo', $orderBy = 'id_desc', $limit = 0, $pager = null, $executionID = 0, $queryID = 0) { - if(!$this->loadModel('common')->checkField(TABLE_BUG, $type)) return array(); + $moduleName = $this->app->rawMethod == 'work' ? 'workBug' : 'contributeBug'; + $queryName = $moduleName . 'Query'; + $formName = $moduleName . 'Form'; + + $bugIDList = array(); + if($moduleName == 'contributeBug') + { + $bugsAssignedByMe = $this->loadModel('my')->getAssignedByMe($account, 0, $pager, $orderBy, 0, 'bug'); + foreach($bugsAssignedByMe as $bugID => $bug) + { + $bugIDList[$bugID] = $bugID; + } + } + + if($queryID) + { + $query = $this->loadModel('search')->getQuery($queryID); + if($query) + { + $this->session->set($queryName, $query->sql); + $this->session->set($formName, $query->form); + } + else + { + $this->session->set($queryName, ' 1 = 1'); + } + } + else + { + if($this->session->$queryName == false) $this->session->set($queryName, ' 1 = 1'); + } + $query = $this->session->$queryName; + $query = preg_replace('/`(\w+)`/', 't1.`$1`', $query); + + if($type != 'bySearch' and !$this->loadModel('common')->checkField(TABLE_BUG, $type)) return array(); $bugs = $this->dao->select('t1.*,t2.name as productName')->from(TABLE_BUG)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id') ->where('t1.deleted')->eq(0) + ->beginIF($type == 'bySearch')->andWhere($query)->fi() ->beginIF($executionID)->andWhere('t1.execution')->eq($executionID)->fi() ->beginIF($type != 'closedBy' and $this->app->moduleName == 'block')->andWhere('t1.status')->ne('closed')->fi() - ->beginIF($type != 'all')->andWhere("t1.`$type`")->eq($account)->fi() + ->beginIF($type != 'all' and $type != 'bySearch')->andWhere("t1.`$type`")->eq($account)->fi() + ->beginIF($type == 'bySearch' and $moduleName == 'workBug')->andWhere("t1.assignedTo")->eq($account)->fi() + ->beginIF($type == 'bySearch' and $moduleName == 'contributeBug') + ->andWhere('t1.openedBy', 1)->eq($account) + ->orWhere('t1.closedBy')->eq($account) + ->orWhere('t1.resolvedBy')->eq($account) + ->orWhere('t1.id')->in($bugIDList) + ->markRight(1) + ->fi() ->orderBy($orderBy) ->beginIF($limit > 0)->limit($limit)->fi() ->page($pager) diff --git a/module/execution/config.php b/module/execution/config.php index fb00ff4e8f..6467b32538 100644 --- a/module/execution/config.php +++ b/module/execution/config.php @@ -51,6 +51,7 @@ $config->execution->search['fields']['desc'] = $lang->task->desc; $config->execution->search['fields']['assignedTo'] = $lang->task->assignedTo; $config->execution->search['fields']['pri'] = $lang->task->pri; +if($app->tab == 'my') $config->execution->search['fields']['project'] = $lang->task->project; $config->execution->search['fields']['execution'] = $lang->task->execution; $config->execution->search['fields']['module'] = $lang->task->module; $config->execution->search['fields']['estimate'] = $lang->task->estimate; @@ -86,6 +87,7 @@ $config->execution->search['params']['desc'] = array('operator' => 'in $config->execution->search['params']['assignedTo'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); $config->execution->search['params']['pri'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->task->priList); +if($app->tab == 'my') $config->execution->search['params']['project'] = array('operator' => '=', 'control' => 'select', 'values' => ''); $config->execution->search['params']['execution'] = array('operator' => '=', 'control' => 'select', 'values' => ''); $config->execution->search['params']['module'] = array('operator' => 'belong', 'control' => 'select', 'values' => ''); $config->execution->search['params']['estimate'] = array('operator' => '=', 'control' => 'input', 'values' => ''); diff --git a/module/my/control.php b/module/my/control.php index 428f26c3eb..5c4b1c29fa 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -411,9 +411,12 @@ EOF; * @access public * @return void */ - public function task($type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function task($type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { $this->loadModel('task'); + $this->loadModel('execution'); + $queryID = ($type == 'bySearch') ? (int)$param : 0; + /* Save session. */ if($this->app->viewType != 'json') $this->session->set('taskList', $this->app->getURI(true), 'execution'); @@ -430,9 +433,13 @@ EOF; { $tasks = $this->my->getAssignedByMe($this->app->user->account, 0, $pager, $sort, 0, 'task'); } + elseif($type == 'bySearch') + { + $tasks = $this->my->getTasksBySearch($this->app->user->account, 0, $pager, $sort, $queryID); + } else { - $tasks = $this->task->getUserTasks($this->app->user->account, $type, 0, $pager, $sort); + $tasks = $this->task->getUserTasks($this->app->user->account, $type, 0, $pager, $sort, $queryID); } $parents = array(); @@ -473,6 +480,9 @@ EOF; /* Get the story language configuration. */ $this->app->loadLang('story'); + $actionURL = $this->createLink('my', $this->app->rawMethod, "mode=task&browseType=bySearch&queryID=myQueryID"); + $this->my->buildTaskSearchForm($queryID, $actionURL); + /* Assign. */ $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->task; $this->view->position[] = $this->lang->my->task; @@ -505,12 +515,13 @@ EOF; * @access public * @return void */ - public function bug($type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function bug($type = 'assignedTo', $param = 0, $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'); + $queryID = ($type == 'bySearch') ? (int)$param : 0; + if($this->app->viewType != 'json') $this->session->set('bugList', $this->app->getURI(true), 'qa'); /* Load pager. */ $this->app->loadClass('pager', $static = true); @@ -525,12 +536,16 @@ EOF; } else { - $bugs = $this->loadModel('bug')->getUserBugs($this->app->user->account, $type, $sort, 0, $pager); + $bugs = $this->loadModel('bug')->getUserBugs($this->app->user->account, $type, $sort, 0, $pager, '', $queryID); } $bugs = $this->bug->checkDelayedBugs($bugs); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug', false); + + $actionURL = $this->createLink('my', $this->app->rawMethod, "mode=bug&browseType=bySearch&queryID=myQueryID"); + $this->my->buildBugSearchForm($queryID, $actionURL); + /* assign. */ $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->bug; $this->view->position[] = $this->lang->my->bug; diff --git a/module/my/lang/en.php b/module/my/lang/en.php index 5aa236aa2a..5ea1688567 100644 --- a/module/my/lang/en.php +++ b/module/my/lang/en.php @@ -44,6 +44,7 @@ $lang->my->storyConcept = 'Story Concept'; $lang->my->pri = 'Priority'; $lang->my->alert = 'You can click on your profile at the top right and select "Preference" to modify your information. '; $lang->my->assignedToMe = 'AssignedToMe'; +$lang->my->byQuery = 'Search'; $lang->my->indexAction = 'My Index'; $lang->my->calendarAction = 'My Calendar'; diff --git a/module/my/lang/zh-cn.php b/module/my/lang/zh-cn.php index 265f0899b7..b1c3471f89 100644 --- a/module/my/lang/zh-cn.php +++ b/module/my/lang/zh-cn.php @@ -44,6 +44,7 @@ $lang->my->storyConcept = $config->URAndSR ? '默认需求概念组合' : ' $lang->my->pri = '优先级'; $lang->my->alert = '后续您可以点击右上方的头像,选择“个性化设置”修改信息。'; $lang->my->assignedToMe = '指派给我'; +$lang->my->byQuery = '搜索'; $lang->my->indexAction = '地盘仪表盘'; $lang->my->calendarAction = '我的日程'; diff --git a/module/my/model.php b/module/my/model.php index b36f80cd30..c7181096c3 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -458,4 +458,168 @@ class myModel extends model } return $cases; } + + /** + * Build search form for task page of work. + * + * @param int $queryID + * @param string $actionURL + * @access public + * @return void + */ + public function buildTaskSearchForm($queryID, $actionURL) + { + $rawMethod = $this->app->rawMethod; + $this->loadModel('execution'); + $this->app->loadConfig('execution'); + + $this->config->execution->search['module'] = $rawMethod . 'Task'; + $this->config->execution->search['actionURL'] = $actionURL; + $this->config->execution->search['queryID'] = $queryID; + + if($rawMethod == 'work') + { + unset($this->config->execution->search['fields']['closedReason']); + unset($this->config->execution->search['fields']['closedBy']); + unset($this->config->execution->search['fields']['canceledBy']); + unset($this->config->execution->search['fields']['closedDate']); + unset($this->config->execution->search['fields']['canceledDate']); + } + + $projects = $this->loadModel('project')->getPairsByProgram(); + $this->config->execution->search['params']['project']['values'] = $projects + array('all' => $this->lang->project->allProjects); + + $executions = $this->execution->getPairs(); + $this->config->execution->search['params']['execution']['values'] = $executions + array('all' => $this->lang->execution->allExecutions); + + $this->config->execution->search['params']['module']['values'] = $this->loadModel('tree')->getAllModulePairs(); + + $this->loadModel('search')->setSearchParams($this->config->execution->search); + } + + /** + * Get tasks by search. + * + * @param string $account + * @param int $limit + * @param object $pager + * @param string $orderBy + * @param int $queryID + * @access public + * @return array + */ + public function getTasksBySearch($account, $limit = 0, $pager = null, $orderBy = 'id_desc', $queryID = 0) + { + $moduleName = $this->app->rawMethod == 'work' ? 'workTask' : 'contributeTask'; + $queryName = $moduleName . 'Query'; + $formName = $moduleName . 'Form'; + + $taskIDList = array(); + if($moduleName == 'contributeTask') + { + $tasksAssignedByMe = $this->getAssignedByMe($account, 0, $pager, $orderBy, 0, 'task'); + foreach($tasksAssignedByMe as $taskID => $task) + { + $taskIDList[$taskID] = $taskID; + } + } + + if($queryID) + { + $query = $this->loadModel('search')->getQuery($queryID); + if($query) + { + $this->session->set($queryName, $query->sql); + $this->session->set($formName, $query->form); + } + else + { + $this->session->set($queryName, ' 1 = 1'); + } + } + else + { + if($this->session->$queryName == false) $this->session->set($queryName, ' 1 = 1'); + } + + $query = $this->session->$queryName; + + $query = preg_replace('/`(\w+)`/', 't1.`$1`', $query); + $query = str_replace('t1.`project`', 't2.`project`', $query); + + $tasks = $this->dao->select('t1.*, t2.id as executionID, t2.name as executionName, t2.type as executionType, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion') + ->from(TABLE_TASK)->alias('t1') + ->leftJoin(TABLE_EXECUTION)->alias('t2')->on("t1.execution = t2.id") + ->leftJoin(TABLE_STORY)->alias('t3')->on('t1.story = t3.id') + ->leftJoin(TABLE_PROJECT)->alias('t4')->on("t1.project = t4.id") + ->where($query) + ->andWhere('t1.deleted')->eq(0) + ->andWhere('t2.deleted')->eq(0) + ->andWhere('(t2.status')->ne('suspended')->orWhere('t4.status')->ne('suspended')->markRight(1) + ->beginIF($moduleName == 'workTask')->andWhere("t1.assignedTo")->eq($account) + ->beginIF($moduleName == 'contributeTask') + ->andWhere('t1.openedBy', 1)->eq($account) + ->orWhere('t1.closedBy')->eq($account) + ->orWhere('t1.canceledBy')->eq($account) + ->orWhere('t1.finishedby', 1)->eq($account) + ->orWhere('t1.finishedList')->like("%,{$account},%") + ->orWhere('t1.id')->in($taskIDList) + ->markRight(1) + ->fi() + ->beginIF($this->config->vision)->andWhere('t1.vision')->eq($this->config->vision)->fi() + ->beginIF($this->config->vision)->andWhere('t2.vision')->eq($this->config->vision)->fi() + ->beginIF(!$this->app->user->admin)->andWhere('t1.execution')->in($this->app->user->view->sprints)->fi() + ->orderBy($orderBy) + ->beginIF($limit > 0)->limit($limit)->fi() + ->page($pager) + ->fetchAll('id'); + + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'task', false); + + $taskTeam = $this->dao->select('*')->from(TABLE_TEAM)->where('root')->in(array_keys($tasks))->andWhere('type')->eq('task')->fetchGroup('root'); + if(!empty($taskTeam)) + { + foreach($taskTeam as $taskID => $team) $tasks[$taskID]->team = $team; + } + + if($tasks) return $this->loadModel('task')->processTasks($tasks); + return array(); + } + + /** + * Build search form for bug page of work. + * + * @param int $queryID + * @param string $actionURL + * @access public + * @return void + */ + public function buildBugSearchForm($queryID, $actionURL) + { + $rawMethod = $this->app->rawMethod; + $this->loadModel('bug'); + $this->app->loadConfig('bug'); + + $products = $this->loadModel('product')->getPairs(); + + $this->config->bug->search['module'] = $rawMethod . 'Bug'; + $this->config->bug->search['actionURL'] = $actionURL; + $this->config->bug->search['queryID'] = $queryID; + if($rawMethod == 'work') + { + unset($this->config->bug->search['fields']['closedDate']); + unset($this->config->bug->search['fields']['closedBy']); + } + + if($this->config->systemMode == 'new') $this->config->bug->search['params']['project']['values'] = $this->loadModel('project')->getPairsByProgram() + array('all' => $this->lang->bug->allProject) + array('' => ''); + $this->config->bug->search['params']['execution']['values'] = $this->loadModel('execution')->getPairs(); + $this->config->bug->search['params']['product']['values'] = $products + array('' => ''); + $this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getPairs(); + $this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getAllModulePairs(); + $this->config->bug->search['params']['severity']['values'] = array(0 => '') + $this->lang->bug->severityList; + $this->config->bug->search['params']['openedBuild']['values'] = $this->loadModel('build')->getBuildPairs($products); + $this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values']; + + $this->loadModel('search')->setSearchParams($this->config->bug->search); + } } diff --git a/module/my/view/bug.html.php b/module/my/view/bug.html.php index 69a18b2ab8..edff420e76 100644 --- a/module/my/view/bug.html.php +++ b/module/my/view/bug.html.php @@ -25,15 +25,23 @@ 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->bug->assignedByMe}" . ($type == 'assignedBy' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'assignedBy' ? ' btn-active-text' : '') . "'"); } + else + { + echo html::a(inlink($app->rawMethod, "mode=$mode&type=assignedTo"), "{$lang->bug->assignedToMe}" . ($type == 'assignedTo' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'assignedTo' ? ' btn-active-text' : '') . "'"); + } ?> + my->byQuery;?>
bug->noBug;?>