From 09ecfa30ddc8d38b47606cf0f7b4e27c2bb39466 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 27 Aug 2015 14:49:33 +0800 Subject: [PATCH] * finish task #2317. --- module/bug/control.php | 21 ++++++---- module/bug/model.php | 66 +++++++++++++++++++++++++++++- module/bug/view/m.resolve.html.php | 2 +- module/bug/view/resolve.html.php | 2 +- 4 files changed, 79 insertions(+), 12 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index cdb0d913c5..54070dedf6 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -772,18 +772,23 @@ class bug extends control die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent')); } - $bug = $this->bug->getById($bugID); - $productID = $bug->product; + $bug = $this->bug->getById($bugID); + $productID = $bug->product; + $users = $this->user->getPairs('nodeleted'); + $assignedTo = $bug->openedBy; + if(!isset($users[$assignedTo])) $assignedTo = $this->bug->getModuleOwner($bug->module, $productID); + $this->bug->setMenu($this->products, $productID); $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->resolve; $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]); $this->view->position[] = $this->lang->bug->resolve; - $this->view->bug = $bug; - $this->view->users = $this->user->getPairs('nodeleted', $bug->openedBy); - $this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID); - $this->view->actions = $this->action->getList('bug', $bugID); + $this->view->bug = $bug; + $this->view->users = $users; + $this->view->assignedTo = $assignedTo; + $this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID); + $this->view->actions = $this->action->getList('bug', $bugID); $this->display(); } @@ -1015,9 +1020,7 @@ class bug extends control */ public function ajaxGetModuleOwner($moduleID, $productID = 0) { - $owner = ''; - if($moduleID) $owner = $this->dao->findByID($moduleID)->from(TABLE_MODULE)->fetch('owner'); - if(!$owner) $owner = $this->dao->findByID($productID)->from(TABLE_PRODUCT)->fetch('QD'); + $owner = $this->bug->getModuleOwner($moduleID, $productID); die($owner); } diff --git a/module/bug/model.php b/module/bug/model.php index 7bd2be7299..00ba767c74 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -340,6 +340,43 @@ class bugModel extends model ->fetchAll(); } + /** + * Get module owner. + * + * @param int $moduleID + * @param int $productID + * @access public + * @return string + */ + public function getModuleOwner($moduleID, $productID) + { + $users = $this->loadModel('user')->getPairs('nodeleted'); + + if($moduleID) + { + $module = $this->dao->findByID($moduleID)->from(TABLE_MODULE)->fetch(); + if($module->owner and isset($users[$module->owner])) return $module->owner; + + $moduleIDList = explode(',', trim(str_replace(",$module->id,", ',', $module->path), ',')); + krsort($moduleIDList); + if($moduleIDList) + { + $modules = $this->dao->select('*')->from(TABLE_MODULE)->where('id')->in($moduleIDList)->fetchAll('id'); + foreach($moduleIDList as $moduleID) + { + if(isset($modules[$moduleID])) + { + $module = $modules[$moduleID]; + if($module->owner and isset($users[$module->owner])) return $module->owner; + } + } + } + } + + $owner = $this->dao->findByID($productID)->from(TABLE_PRODUCT)->fetch('QD'); + return isset($users[$owner]) ? $users[$owner] : ''; + } + /** * Update a bug. * @@ -598,10 +635,37 @@ class bugModel extends model { $now = helper::now(); $bugs = $this->getByList($bugIDList); + + $bug = reset($bugs); + $productID = $bug->product; + $users = $this->loadModel('user')->getPairs('nodeleted'); + $product = $this->dao->findById($productID)->from(TABLE_PRODUCT)->fetch(); + $stmt = $this->dao->query($this->loadModel('tree')->buildMenuQuery($productID, 'bug', '')); + $modules = array(); + while($module = $stmt->fetch()) $modules[$module->id] = $module; + foreach($bugIDList as $bugID) { $oldBug = $bugs[$bugID]; if($oldBug->status != 'active') continue; + + $assignedTo = $oldBug->openedBy; + if(!isset($users[$assignedTo])) + { + $assignedTo = ''; + $module = isset($modules[$oldBug->module]) ? $modules[$oldBug->module] : ''; + while($module) + { + if($module->owner and isset($users[$module->owner])) + { + $assignedTo = $module->owner; + break; + } + $module = isset($modules[$module->parent]) ? $modules[$module->parent] : ''; + } + if(empty($assignedTo)) $assignedTo = $product->QD; + } + $bug = new stdClass(); $bug->resolution = $resolution; $bug->resolvedBuild = $resolution == 'fixed' ? $resolvedBuild : ''; @@ -609,7 +673,7 @@ class bugModel extends model $bug->resolvedDate = $now; $bug->status = 'resolved'; $bug->confirmed = 1; - $bug->assignedTo = $oldBug->openedBy; + $bug->assignedTo = $assignedTo; $bug->assignedDate = $now; $bug->lastEditedBy = $this->app->user->account; $bug->lastEditedDate = $now; diff --git a/module/bug/view/m.resolve.html.php b/module/bug/view/m.resolve.html.php index 6834c71544..76c81506e0 100755 --- a/module/bug/view/m.resolve.html.php +++ b/module/bug/view/m.resolve.html.php @@ -21,7 +21,7 @@ bug->assignedTo?> - openedBy);?> + comment;?> diff --git a/module/bug/view/resolve.html.php b/module/bug/view/resolve.html.php index 31408dceaa..9e246ac4af 100644 --- a/module/bug/view/resolve.html.php +++ b/module/bug/view/resolve.html.php @@ -41,7 +41,7 @@ bug->assignedTo;?> - openedBy, "class='form-control chosen'");?> + bug->files;?>