diff --git a/module/bug/control.php b/module/bug/control.php index 1d353355ac..2e11fc511c 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -553,14 +553,10 @@ class bug extends control $moduleOwner = $this->bug->getModuleOwner($moduleID, $productID); - /* Set team members of the latest execution as assignedTo list. */ - $productMembers = $this->bug->getProductMemberPairs($productID); + /* Get all project team members linked with this product. */ + $productMembers = $this->bug->getProductMemberPairs($productID, $branch); + $productMembers = array_filter($productMembers); if(empty($productMembers)) $productMembers = $this->view->users; - if($assignedTo and !isset($productMembers[$assignedTo])) - { - $user = $this->loadModel('user')->getById($assignedTo); - if($user) $productMembers[$assignedTo] = $user->realname; - } $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, ($branch === 'all' or !isset($branches[$branch])) ? 0 : $branch); if(empty($moduleOptionMenu)) return print(js::locate(helper::createLink('tree', 'browse', "productID=$productID&view=story"))); @@ -577,7 +573,7 @@ class bug extends control if($projectID) { $project = $this->loadModel('project')->getByID($projectID); - if(empty($bugID) or $this->app->tab != 'qa') $projects = array($projectID => $project->name); + if(empty($bugID) or $this->app->tab != 'qa') $projects += array($projectID => $project->name); } } elseif($projectID) @@ -1090,6 +1086,22 @@ class bug extends control $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $bug->branch); if(!isset($moduleOptionMenu[$bug->module])) $moduleOptionMenu += $this->tree->getModulesName($bug->module); + /* Get assigned to member. */ + if($bug->execution) + { + $assignedToList = $this->user->getTeamMemberPairs($bug->execution, 'execution'); + } + elseif($bug->project) + { + $assignedToList = $this->loadModel('project')->getTeamMemberPairs($bug->project); + } + else + { + $assignedToList = $this->bug->getProductMemberPairs($bug->product, $bug->branch); + $assignedToList = array_filter($assignedToList); + if(empty($assignedToList)) $assignedToList = $this->user->getPairs('devfirst|noclosed'); + } + $this->view->bug = $bug; $this->view->productID = $productID; $this->view->product = $product; @@ -1105,6 +1117,7 @@ class bug extends control $this->view->tasks = $this->task->getExecutionTaskPairs($bug->execution); $this->view->testtasks = $this->loadModel('testtask')->getPairs($bug->product, $bug->execution, $bug->testtask); $this->view->users = $this->user->getPairs('', "$bug->assignedTo,$bug->resolvedBy,$bug->closedBy,$bug->openedBy"); + $this->view->assignedToList = $assignedToList; $this->view->openedBuilds = $openedBuilds; $this->view->resolvedBuilds = array('' => '') + $openedBuilds + $oldResolvedBuild; $this->view->actions = $this->action->getList('bug', $bugID); @@ -1234,35 +1247,94 @@ class bug extends control $this->view->customFields = $customFields; $this->view->showFields = $this->config->bug->custom->batchEditFields; - /* Set users. */ - $appendUsers = array(); + $branchIdList = array(); + $projectIdList = array(); + $executionIdList = array(); foreach($bugs as $bug) { - $appendUsers[$bug->assignedTo] = $bug->assignedTo; - $appendUsers[$bug->resolvedBy] = $bug->resolvedBy; + $projectIdList[$bug->project] = $bug->project; + $executionIdList[$bug->execution] = $bug->execution; + + $branchIdList[$bug->product][$bug->branch] = $bug->branch; if(!isset($modules[$bug->product][$bug->branch])) $modules[$bug->product][$bug->branch] = $modules[$bug->product][0] + $this->tree->getModulesName($bug->module); } - $users = $this->user->getPairs('devfirst', $appendUsers, $this->config->maxCount); + + /* Get assigned to member. */ + $this->loadModel('project'); + $this->loadModel('execution'); + + $productMembers = array(); + $projectMembers = array(); + $executionMembers = array(); + if($productID) + { + $branchList = zget($branchIdList, $productID, array()); + foreach($branchList as $branchID) + { + $members = $this->bug->getProductMemberPairs($productID, $branchID); + $productMembers[$productID][$branchID] = array_filter($members); + } + } + else + { + foreach($productIdList as $id) + { + $branchList = zget($branchIdList, $id, array()); + foreach($branchList as $branchID) + { + $members = $this->bug->getProductMemberPairs($id, $branchID); + $productMembers[$id][$branchID] = array_filter($members); + } + } + } + + $projectMemberGroup = $this->project->getTeamMemberGroup($projectIdList); + $projectMembers = array(); + foreach($projectIdList as $projectID) + { + $projectTeam = zget($projectMemberGroup, $projectID, array()); + if(empty($projectTeam)) $projectMembers[$projectID] = array(); + foreach($projectTeam as $user) + { + $projectMembers[$projectID][$user->account] = $user->realname; + } + } + + $executionMemberGroup = $this->execution->getMembersByIdList($executionIdList); + $executionMembers = array(); + foreach($executionIdList as $executionID) + { + $executionTeam = zget($executionMemberGroup, $executionID, array()); + if(empty($executionTeam)) $executionMemberGroup[$executionID] = array(); + foreach($executionTeam as $user) + { + $executionMembers[$executionID][$user->account] = $user->realname; + } + } + + /* Set users. */ + $users = $this->user->getPairs('devfirst', '', $this->config->maxCount); $users = array('' => '', 'ditto' => $this->lang->bug->ditto) + $users; /* Assign. */ - $this->view->position[] = $this->lang->bug->common; - $this->view->position[] = $this->lang->bug->batchEdit; - $this->view->productID = $productID; - $this->view->branchProduct = $branchProduct; - $this->view->severityList = array('ditto' => $this->lang->bug->ditto) + $this->lang->bug->severityList; - $this->view->typeList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->typeList; - $this->view->priList = array('0' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->priList; - $this->view->resolutionList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->resolutionList; - $this->view->statusList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->statusList; - $this->view->osList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->osList; - $this->view->browserList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->browserList; - $this->view->bugs = $bugs; - $this->view->branch = $branch; - $this->view->users = $users; - $this->view->modules = $modules; - $this->view->branchTagOption = $branchTagOption; + $this->view->productID = $productID; + $this->view->branchProduct = $branchProduct; + $this->view->severityList = array('ditto' => $this->lang->bug->ditto) + $this->lang->bug->severityList; + $this->view->typeList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->typeList; + $this->view->priList = array('0' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->priList; + $this->view->resolutionList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->resolutionList; + $this->view->statusList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->statusList; + $this->view->osList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->osList; + $this->view->browserList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->browserList; + $this->view->bugs = $bugs; + $this->view->branch = $branch; + $this->view->users = $users; + $this->view->productMembers = $productMembers; + $this->view->projectMembers = $projectMembers; + $this->view->executionMembers = $executionMembers; + $this->view->modules = $modules; + $this->view->branchTagOption = $branchTagOption; $this->display(); } @@ -1320,17 +1392,20 @@ class bug extends control } } - if($this->app->tab == 'project') + /* Get assigned to member. */ + if($bug->execution) { - $users = $this->user->getTeamMemberPairs($bug->project, 'project', 'nodeleted', $bug->assignedTo); + $users = $this->user->getTeamMemberPairs($bug->execution, 'execution'); } - elseif($this->app->tab == 'execution') + elseif($bug->project) { - $users = $this->user->getTeamMemberPairs($bug->execution, 'execution', 'nodeleted', $bug->assignedTo); + $users = $this->loadModel('project')->getTeamMemberPairs($bug->project); } else { - $users = $this->user->getPairs('noclosed', $bug->assignedTo); + $users = $this->bug->getProductMemberPairs($bug->product, $bug->branch); + $users = array_filter($users); + if(empty($users)) $users = $this->user->getPairs('devfirst|noclosed'); } $this->view->title = $this->products[$bug->product] . $this->lang->colon . $this->lang->bug->assignedTo; @@ -2029,7 +2104,7 @@ class bug extends control */ public function ajaxLoadAssignedTo($executionID, $selectedUser = '') { - $executionMembers = $this->user->getTeamMemberPairs($executionID, 'execution', '', $selectedUser); + $executionMembers = $this->user->getTeamMemberPairs($executionID, 'execution'); $execution = $this->loadModel('execution')->getByID($executionID); if(empty($selectedUser)) $selectedUser = $execution->QD; @@ -2351,12 +2426,15 @@ class bug extends control * * @param int $productID * @param string $selectedUser + * @param int $branchID * @access public * @return string */ - public function ajaxGetProductMembers($productID, $selectedUser = '') + public function ajaxGetProductMembers($productID, $selectedUser = '', $branchID = '') { - $productMembers = $this->bug->getProductMemberPairs($productID); + $productMembers = $this->bug->getProductMemberPairs($productID, $branchID); + $productMembers = array_filter($productMembers); + if(empty($productMembers)) $productMembers = $this->loadModel('user')->getPairs('devfirst|noclosed'); return print(html::select('assignedTo', $productMembers, $selectedUser, 'class="form-control"')); } @@ -2365,7 +2443,7 @@ class bug extends control * Ajax get project team members. * * @param int $projectID - * @param string $$selectedUser + * @param string $selectedUser * @access public * @return string */ diff --git a/module/bug/js/common.js b/module/bug/js/common.js index 8410c771b3..166e71d0d1 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -130,6 +130,7 @@ function loadBranch() loadProductBuilds(productID); loadProductplans(productID); loadProductStories(productID); + loadProductMembers(productID); } /** @@ -333,12 +334,44 @@ function loadProductExecutions(productID, projectID = 0) $(this).find('select').chosen(); if(typeof(bugExecution) == 'string' && systemMode != 'classic') $('#executionIdBox').prepend("" + bugExecution + ""); if(required) $(this).find('#execution_chosen').addClass('required'); - if(page != 'edit') changeAssignedTo(projectID); + changeAssignedTo(projectID); }); projectID != 0 ? loadProjectBuilds(projectID) : loadProductBuilds(productID); } +/** + * Ajax change execution name. + * + * @param int $projectID + * @access public + * @return void + */ +function changeAssignedTo(projectID) +{ + if(parseInt(projectID)) + { + loadProjectTeamMembers(projectID); + if(page == 'create') + { + var link = createLink('bug', 'ajaxGetExecutionLang', 'projectID=' + projectID); + $.post(link, function(executionLang) + { + $('#executionBox').html(executionLang); + }) + } + } + else if($('#execution').val() != 0) + { + loadAssignedTo($('#execution').val()); + } + else + { + var productID = $('#product').val(); + loadProductMembers(productID); + } +} + /** * Load executions of product and project. * @@ -441,13 +474,13 @@ function loadExecutionRelated(executionID) } else { - var currentProjectID = $('#project').val(); + var currentProjectID = $('#project').val() == 'undefined' ? 0 : $('#project').val(); var currentProductID = $('#product').val(); $('#taskIdBox').innerHTML = ''; // Reset the task. loadProductStories(currentProductID); loadTestTasks(currentProductID); - if(typeof(currentProjectID) == 'undefined') + if(currentProjectID == 0) { loadProductMembers(currentProductID); } @@ -593,7 +626,8 @@ function loadExecutionBuilds(executionID, num) */ function loadProductMembers(productID) { - link = createLink('bug', 'ajaxGetProductMembers', 'productID=' + productID + '&selectedUser=' + $('#assignedTo').val()); + var branchID = $('#branch').val() == undefined ? '' : $('#branch').val(); + var link = createLink('bug', 'ajaxGetProductMembers', 'productID=' + productID + '&selectedUser=' + $('#assignedTo').val() + '&branchID=' + branchID); $.get(link, function(data) { if(!data) data = ''; @@ -678,6 +712,7 @@ function loadProductBranches(productID, param) loadProductProjects(productID); loadProductplans(productID); loadProductStories(productID); + loadProductMembers(productID); }) } diff --git a/module/bug/js/create.js b/module/bug/js/create.js index 68d406da31..b804a98e40 100644 --- a/module/bug/js/create.js +++ b/module/bug/js/create.js @@ -125,34 +125,6 @@ $(function() }); }); -/** - * Ajax change execution name. - * - * @param int $projectID - * @access public - * @return void - */ -function changeAssignedTo(projectID) -{ - if(parseInt(projectID)) - { - loadProjectTeamMembers(projectID); - var link = createLink('bug', 'ajaxGetExecutionLang', 'projectID=' + projectID); - $.post(link, function(executionLang) - { - $('#executionBox').html(executionLang); - }) - } - else if($('#execution').val() != 0) - { - loadAssignedTo($('#execution').val()); - } - else - { - setAssignedTo(); - } -} - $(window).unload(function(){ if(blockID) window.parent.refreshBlock($('#block' + blockID)); }); diff --git a/module/bug/model.php b/module/bug/model.php index ef747cb7ef..236f66bef3 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -460,6 +460,8 @@ class bugModel extends model echo(js::alert($this->lang->bug->executionAccessDenied)); $loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login"; if(strpos($this->server->http_referer, $loginLink) !== false) return print(js::locate(helper::createLink('bug', 'index', ''))); + if($this->app->tab == 'my') print(js::reload('parent')); + return print(js::locate('back')); } } @@ -1898,14 +1900,15 @@ class bugModel extends model * get Product member pairs. * * @param int $productID + * @param int $branchID * @access public * @return void */ - public function getProductMemberPairs($productID) + public function getProductMemberPairs($productID, $branchID = '') { if(defined('TUTORIAL')) return $this->loadModel('tutorial')->getTeamMembersPairs(); - $projects = $this->loadModel('product')->getProjectPairsByProduct($productID); + $projects = $this->loadModel('product')->getProjectPairsByProduct($productID, $branchID); $users = $this->dao->select("t2.id, t2.account, t2.realname")->from(TABLE_TEAM)->alias('t1') ->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account') diff --git a/module/bug/view/batchedit.html.php b/module/bug/view/batchedit.html.php index 5a7252c532..c15db2a9b3 100644 --- a/module/bug/view/batchedit.html.php +++ b/module/bug/view/batchedit.html.php @@ -102,7 +102,27 @@