diff --git a/module/bug/control.php b/module/bug/control.php index 0aceaf4153..9c7cdde56c 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -31,7 +31,7 @@ class bug extends control $this->loadModel('action'); $this->loadModel('story'); $this->loadModel('task'); - $this->view->products = $this->products = $this->product->getProductsByProject($this->session->PRJ); + $this->view->products = $this->products = $this->product->getProductPairsByProject($this->session->PRJ); if(empty($this->products)) die($this->locate($this->createLink('product', 'showErrorNone', "fromModule=bug"))); } diff --git a/module/design/control.php b/module/design/control.php index c6ab5a7b19..c6b8868cd6 100644 --- a/module/design/control.php +++ b/module/design/control.php @@ -26,7 +26,7 @@ class design extends control parent::__construct($moduleName, $methodName); $products = array(); $this->loadModel('product'); - $this->view->products = $this->products = $this->product->getProductsByProject($this->session->PRJ); + $this->view->products = $this->products = $this->product->getProductPairsByProject($this->session->PRJ); } /** diff --git a/module/doc/control.php b/module/doc/control.php index 445772be6b..8335a99a8d 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -225,7 +225,7 @@ class doc extends control } $programID = $this->session->PRJ; - $products = $this->product->getProductsByProject($programID, 'noclosed'); + $products = $this->product->getProductPairsByProject($programID, 'noclosed'); $projects = $this->project->getPairs('nocode', $programID); $libTypeList = $this->lang->doc->libTypeList; diff --git a/module/doc/model.php b/module/doc/model.php index 73a17985db..f63ef55561 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -183,7 +183,7 @@ class docModel extends model if(strpos($extra, 'withObject') !== false) { - $products = $this->loadModel('product')->getProductsByProject($this->session->PRJ); + $products = $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); $projects = $this->loadModel('project')->getPairs('', $this->session->PRJ); } @@ -1477,7 +1477,7 @@ class docModel extends model * @access public * @return array */ - public function getLibIDByProject($projectID = 0) + public function getLibIdListByProject($projectID = 0) { $products = $this->loadModel('product')->getProductIDByProject($projectID, false); $projects = $this->loadModel('project')->getProjectIDByProgram($projectID); @@ -1488,8 +1488,8 @@ class docModel extends model if($products) $productLibs = $this->dao->select('id')->from(TABLE_DOCLIB)->where('product')->in($products)->fetchPairs(); $customLibs = $this->dao->select('id')->from(TABLE_DOCLIB)->where('type')->eq('custom')->fetchPairs(); - $libIDList = array_merge($customLibs, $projectLibs, $productLibs); - return $libIDList; + $libIdList = array_merge($customLibs, $projectLibs, $productLibs); + return $libIdList; } /** @@ -1501,7 +1501,7 @@ class docModel extends model public function getStatisticInfo() { $libID = 0; - if($this->session->PRJ) $libID = $this->getLibIDByProject($this->session->PRJ); + if($this->session->PRJ) $libID = $this->getLibIdListByProject($this->session->PRJ); $docIdList = $this->getPrivDocs($libID); $today = date('Y-m-d'); diff --git a/module/product/control.php b/module/product/control.php index 37cdb11ddc..04fe855a1e 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -695,25 +695,15 @@ class product extends control */ public function ajaxGetDropMenu($productID, $module, $method, $extra) { + $products = ($module == 'product') ? $this->product->getList() : $this->product->getProductPairsByProject($this->session->PRJ); + $this->view->link = $this->product->getProductLink($module, $method, $extra); $this->view->productID = $productID; $this->view->module = $module; $this->view->method = $method; $this->view->extra = $extra; - - if($module != 'product') - { - $products = $this->product->getProductIDByProject($this->session->PRJ, false); - $products = $this->product->getByIdList($products); - } - else - { - $products = $this->product->getList(); - } - $this->view->products = $products; - $this->view->programID = $this->session->PRJ; - + $this->view->projectID = $this->session->PRJ; $this->display(); } diff --git a/module/product/model.php b/module/product/model.php index 78ee5a09c7..020e61f952 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -307,6 +307,26 @@ class productModel extends model return $products; } + /** + * Get products by project. + * + * @param int $projectID + * @param int $status all|noclosed + * @access public + * @return array + */ + public function getProductPairsByProject($projectID, $status = 'all') + { + $products = $this->getProductsByProject($projectID, $status); + $pairs = array(); + if(!empty($products)) + { + foreach($products as $product) $pairs[$product->id] = $product->name; + } + + return $pairs; + } + /** * Get products by project. * @@ -317,7 +337,7 @@ class productModel extends model */ public function getProductsByProject($projectID, $status = 'all') { - return $this->dao->select('t1.product, t2.name') + return $this->dao->select('t2.*') ->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2') ->on('t1.product = t2.id') @@ -325,7 +345,7 @@ class productModel extends model ->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi() ->andWhere('t2.deleted')->eq(0) ->orderBy('t2.order desc') - ->fetchPairs(); + ->fetchAll(); } /** @@ -1195,7 +1215,7 @@ class productModel extends model elseif($module == 'programplan') { $extra = $extra ? $extra : 'gantt'; - $link = helper::createLink($module, 'browse', "programID=%s&productID=%s&type=$extra" . ($branch ? "&branch=%s" : '')); + $link = helper::createLink($module, 'browse', "projectID=%s&productID=%s&type=$extra" . ($branch ? "&branch=%s" : '')); } else { @@ -1219,11 +1239,6 @@ class productModel extends model { $link = helper::createLink('doc', 'objectLibs', "type=product&objectID=%s&from=product"); } - elseif($module == 'programplan') - { - $extra = $extra ? $extra : 'gantt'; - return helper::createLink('programplan', 'browse', "programID=%s&productID=%s&type=$extra"); - } elseif($module == 'design') { return helper::createLink('design', 'browse', "productID=%s"); diff --git a/module/product/view/ajaxgetdropmenu.html.php b/module/product/view/ajaxgetdropmenu.html.php index 567015c2c1..089ed04d5e 100644 --- a/module/product/view/ajaxgetdropmenu.html.php +++ b/module/product/view/ajaxgetdropmenu.html.php @@ -25,12 +25,12 @@ foreach($products as $product) { if($product->type != 'platform' && $module == 'branch' && $method == 'manage') { - $linkHtml = $module == 'programplan' ? sprintf($link, $programID, $productID) : sprintf($link, $productID); + $linkHtml = $module == 'programplan' ? sprintf($link, $projectID, $productID) : sprintf($link, $productID); $myProductsHtml .= html::a($linkHtml, " " . $product->name, '', "class='text-important' title='{$product->name}' data-key='" . zget($productsPinYin, $product->name, '') . "'"); } else { - $linkHtml = $module == 'programplan' ? sprintf($link, $programID, $product->id) : sprintf($link, $product->id); + $linkHtml = $module == 'programplan' ? sprintf($link, $projectID, $product->id) : sprintf($link, $product->id); $myProductsHtml .= html::a($linkHtml, " " . $product->name, '', "class='text-important' title='{$product->name}' data-key='" . zget($productsPinYin, $product->name, '') . "'"); } } @@ -38,12 +38,12 @@ foreach($products as $product) { if($product->type != 'platform' && $module == 'branch' && $method == 'manage') { - $linkHtml = $module == 'programplan' ? sprintf($link, $programID, $productID) : sprintf($link, $productID); + $linkHtml = $module == 'programplan' ? sprintf($link, $projectID, $productID) : sprintf($link, $productID); $normalProductsHtml .= html::a($linkHtml, " " . $product->name, '', "title='{$product->name}' data-key='" . zget($productsPinYin, $product->name, '') . "'"); } else { - $linkHtml = $module == 'programplan' ? sprintf($link, $programID, $product->id) : sprintf($link, $product->id); + $linkHtml = $module == 'programplan' ? sprintf($link, $projectID, $product->id) : sprintf($link, $product->id); $normalProductsHtml .= html::a($linkHtml, " " . $product->name, '', "title='{$product->name}' data-key='" . zget($productsPinYin, $product->name, '') . "'"); } } @@ -52,12 +52,12 @@ foreach($products as $product) if($product->type != 'platform' && $module == 'branch' && $method == 'manage') { - $linkHtml = $module == 'programplan' ? sprintf($link, $programID, $productID) : sprintf($link, $productID); + $linkHtml = $module == 'programplan' ? sprintf($link, $projectID, $productID) : sprintf($link, $productID); $closedProductsHtml .= html::a($linkHtml, " " . $product->name, '', "title='{$product->name}' class='closed' data-key='" . zget($productsPinYin, $product->name, '') . "'"); } else { - $linkHtml = $module == 'programplan' ? sprintf($link, $programID, $product->id) : sprintf($link, $product->id); + $linkHtml = $module == 'programplan' ? sprintf($link, $projectID, $product->id) : sprintf($link, $product->id); $closedProductsHtml .= html::a($linkHtml, " " . $product->name, '', "title='{$product->name}' class='closed' data-key='" . zget($productsPinYin, $product->name, '') . "'"); } } @@ -81,7 +81,7 @@ foreach($products as $product) diff --git a/module/productplan/control.php b/module/productplan/control.php index 8daf9e83b6..1b83126d26 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -260,7 +260,7 @@ class productplan extends control $sort = $this->loadModel('common')->appendOrder($orderBy); $this->commonAction($plan->product, $plan->branch); - $products = $this->product->getProductsByProject($this->session->PRJ); + $products = $this->product->getProductPairsByProject($this->session->PRJ); $bugPager = new pager(0, $recPerPage, $type == 'bug' ? $pageID : 1); $storyPager = new pager(0, $recPerPage, $type == 'story' ? $pageID : 1); @@ -361,7 +361,7 @@ class productplan extends control $this->loadModel('tree'); $plan = $this->productplan->getByID($planID); $this->commonAction($plan->product, $plan->branch); - $products = $this->product->getProductsByProject($this->session->PRJ); + $products = $this->product->getProductPairsByProject($this->session->PRJ); /* Load pager. */ $this->app->loadClass('pager', $static = true); @@ -499,7 +499,7 @@ class productplan extends control $this->loadModel('bug'); $plan = $this->productplan->getByID($planID); $this->commonAction($plan->product, $plan->branch); - $products = $this->product->getProductsByProject($this->session->PRJ); + $products = $this->product->getProductPairsByProject($this->session->PRJ); $productID = $plan->product; $queryID = ($browseType == 'bysearch') ? (int)$param : 0; diff --git a/module/programplan/control.php b/module/programplan/control.php index 41d5eeb80e..82bcdaaa55 100644 --- a/module/programplan/control.php +++ b/module/programplan/control.php @@ -36,7 +36,7 @@ class programplan extends control */ public function commonAction($projectID, $productID = 0, $extra = '') { - $products = $this->loadModel('product')->getProductsByProject($projectID); + $products = $this->loadModel('product')->getProductPairsByProject($projectID); $productID = $this->product->saveState($productID, $products); $this->productID = $productID; $this->product->setMenu($products, $productID, 0, 0, '', $extra); diff --git a/module/project/control.php b/module/project/control.php index ff19cd207e..887c5629dc 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -125,7 +125,7 @@ class project extends control /* Get products by project. */ $project = $this->commonAction($projectID, $status); $projectID = $project->id; - $products = $this->loadModel('product')->getProductsByProject($projectID); + $products = $this->loadModel('product')->getProductPairsByProject($projectID); setcookie('preProjectID', $projectID, $this->config->cookieLife, $this->config->webRoot, '', false, true); if($this->cookie->preProjectID != $projectID) @@ -757,7 +757,7 @@ class project extends control /* Get project's product. */ $productID = 0; - $productPairs = $this->loadModel('product')->getProductsByProject($projectID); + $productPairs = $this->loadModel('product')->getProductPairsByProject($projectID); if($productPairs) $productID = key($productPairs); /* Assign. */ @@ -1158,7 +1158,7 @@ class project extends control $this->view->position[] = $this->view->title; $this->view->projects = array('' => '') + $this->projects; $this->view->groups = $this->loadModel('group')->getPairs(); - $this->view->allProducts = array(0 => '') + $this->loadModel('product')->getProductsByProject($this->session->PRJ); + $this->view->allProducts = array(0 => '') + $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); $this->view->acl = $acl; $this->view->plan = $plan; $this->view->name = $name; @@ -1813,7 +1813,7 @@ class project extends control /* Get project's product. */ $productID = 0; - $productPairs = $this->loadModel('product')->getProductsByProject($projectID); + $productPairs = $this->loadModel('product')->getProductPairsByProject($projectID); if($productPairs) $productID = key($productPairs); $this->view->title = $this->lang->project->storyKanban; @@ -1896,7 +1896,7 @@ class project extends control $position[] = html::a($browseProjectLink, $project->name); $position[] = $this->lang->project->manageProducts; - $allProducts = $this->product->getProductsByProject($project->project); + $allProducts = $this->product->getProductPairsByProject($project->project); $linkedProducts = $this->project->getProducts($project->id); $linkedBranches = array(); // Merge allProducts and linkedProducts for closed product. @@ -2419,7 +2419,7 @@ class project extends control $this->view->position[] = $this->lang->project->allProject; $this->view->projectStats = $this->project->getProjectStats($status == 'byproduct' ? 'all' : $status, $productID, 0, 30, $orderBy, $pager, $this->session->PRJ); - $this->view->products = array(0 => $this->lang->product->select) + $this->loadModel('product')->getProductsByProject($this->session->PRJ); + $this->view->products = array(0 => $this->lang->product->select) + $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); $this->view->productID = $productID; $this->view->projectID = $projectID; $this->view->pager = $pager; diff --git a/module/project/model.php b/module/project/model.php index aeef412ef0..5faa1fecd0 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -2052,7 +2052,7 @@ class projectModel extends model if($projectType == 'project') { $childSprints = $this->dao->select('id')->from(TABLE_PROJECT)->where('project')->eq($project->id)->andWhere('type')->in('stage,sprint')->andWhere('deleted')->eq('0')->fetchPairs(); - $linkedProducts = $this->loadModel('product')->getProductsByProject($project->id); + $linkedProducts = $this->loadModel('product')->getProductPairsByProject($project->id); if(!empty($childSprints)) $this->loadModel('user')->updateUserView($childSprints, 'sprint', $changedAccounts); if(!empty($linkedProducts)) $this->loadModel('user')->updateUserView(array_keys($linkedProducts), 'product', $changedAccounts); @@ -2097,7 +2097,7 @@ class projectModel extends model $changedAccounts = array_unique($changedAccounts); $this->loadModel('user')->updateUserView($projectID, $projectType, $changedAccounts); - $linkedProducts = $this->loadModel('product')->getProductsByProject($projectID); + $linkedProducts = $this->loadModel('product')->getProductPairsByProject($projectID); if(!empty($linkedProducts)) $this->user->updateUserView(array_keys($linkedProducts), 'product', $changedAccounts); } @@ -2128,7 +2128,7 @@ class projectModel extends model { $this->dao->delete()->from(TABLE_TEAM)->where('root')->eq($sprint->project)->andWhere('type')->eq('project')->andWhere('account')->eq($account)->exec(); $this->loadModel('user')->updateUserView($sprint->project, 'project', array($account)); - $linkedProducts = $this->loadModel('product')->getProductsByProject($sprint->project); + $linkedProducts = $this->loadModel('product')->getProductPairsByProject($sprint->project); if(!empty($linkedProducts)) $this->user->updateUserView(array_keys($linkedProducts), 'product', array($account)); } } diff --git a/module/qa/control.php b/module/qa/control.php index d069eca978..371e8a416f 100644 --- a/module/qa/control.php +++ b/module/qa/control.php @@ -19,7 +19,7 @@ class qa extends control */ public function index($locate = 'auto', $productID = 0) { - $this->products = $this->loadModel('product')->getProductsByProject($this->session->PRJ); + $this->products = $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); if(empty($this->products)) die($this->locate($this->createLink('product', 'showErrorNone', "fromModule=qa"))); if($locate == 'yes') $this->locate($this->createLink('bug', 'browse')); diff --git a/module/story/control.php b/module/story/control.php index ecb9aa903a..8f3dab4289 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -148,7 +148,7 @@ class story extends control /* Set products, users and module. */ if($projectID != 0) { - $products = $this->product->getProductsByProject($projectID); + $products = $this->product->getProductPairsByProject($projectID); $product = $this->product->getById(($productID and array_key_exists($productID, $products)) ? $productID : key($products)); } else diff --git a/module/testcase/control.php b/module/testcase/control.php index 930c585c17..aef28a9177 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -25,7 +25,7 @@ class testcase extends control $this->loadModel('product'); $this->loadModel('tree'); $this->loadModel('user'); - $this->view->products = $this->products = $this->product->getProductsByProject($this->session->PRJ); + $this->view->products = $this->products = $this->product->getProductPairsByProject($this->session->PRJ); if(empty($this->products)) die($this->locate($this->createLink('product', 'showErrorNone', "fromModule=testcase"))); } diff --git a/module/testreport/control.php b/module/testreport/control.php index ff35b9d5e8..93c242dd9b 100644 --- a/module/testreport/control.php +++ b/module/testreport/control.php @@ -520,7 +520,7 @@ class testreport extends control { if($objectType == 'product') { - $this->products = $this->product->getProductsByProject($this->session->PRJ); + $this->products = $this->product->getProductPairsByProject($this->session->PRJ); $productID = $this->product->saveState($objectID, $this->products); $this->testreport->setMenu($this->products, $productID); return $productID; diff --git a/module/testsuite/control.php b/module/testsuite/control.php index ea47c71f0d..3fa8ccb80d 100644 --- a/module/testsuite/control.php +++ b/module/testsuite/control.php @@ -41,7 +41,7 @@ class testsuite extends control $this->session->set('testsuiteList', $this->app->getURI(true)); /* Set menu. */ - $this->view->products = $this->products = $this->loadModel('product')->getProductsByProject($this->session->PRJ); + $this->view->products = $this->products = $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); $productID = $this->product->saveState($productID, $this->products); $this->testsuite->setMenu($this->products, $productID); @@ -105,7 +105,7 @@ class testsuite extends control } /* Set menu. */ - $this->view->products = $this->products = $this->loadModel('product')->getProductsByProject($this->session->PRJ); + $this->view->products = $this->products = $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); $productID = $this->product->saveState($productID, $this->products); $this->testsuite->setMenu($this->products, $productID); @@ -138,7 +138,7 @@ class testsuite extends control if($suite->type == 'private' and $suite->addedBy != $this->app->user->account and !$this->app->user->admin) die(js::error($this->lang->error->accessDenied) . js::locate('back')); $productID = $suite->product; - $this->view->products = $this->products = $this->loadModel('product')->getProductsByProject($this->session->PRJ); + $this->view->products = $this->products = $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); $this->testsuite->setMenu($this->products, $productID); /* Save session. */ @@ -207,7 +207,7 @@ class testsuite extends control if($suite->type == 'private' and $suite->addedBy != $this->app->user->account and !$this->app->user->admin) die(js::error($this->lang->error->accessDenied) . js::locate('back')); /* Get suite info. */ - $this->view->products = $this->products = $this->loadModel('product')->getProductsByProject($this->session->PRJ); + $this->view->products = $this->products = $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); $productID = $this->product->saveState($suite->product, $this->products); /* Set menu. */ @@ -287,7 +287,7 @@ class testsuite extends control $this->session->set('caseList', $this->app->getURI(true)); /* Get suite and product id. */ - $this->view->products = $this->products = $this->loadModel('product')->getProductsByProject($this->session->PRJ); + $this->view->products = $this->products = $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); $suite = $this->testsuite->getById($suiteID); $productID = $this->product->saveState($suite->product, $this->products); diff --git a/module/testtask/control.php b/module/testtask/control.php index 043b0be9b2..3f0db2b936 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -23,7 +23,7 @@ class testtask extends control { parent::__construct($moduleName, $methodName); $this->loadModel('product'); - $this->view->products = $this->products = $this->product->getProductsByProject($this->session->PRJ); + $this->view->products = $this->products = $this->product->getProductPairsByProject($this->session->PRJ); if(empty($this->products)) die($this->locate($this->createLink('product', 'showErrorNone', "fromModule=testtask"))); } diff --git a/module/tree/model.php b/module/tree/model.php index 5527188599..98f966029e 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -170,7 +170,7 @@ class treeModel extends model { if($viewType == 'task') { - $products = array_keys($this->loadModel('product')->getProductsByProject($rootID)); + $products = array_keys($this->loadModel('product')->getProductPairsByProject($rootID)); if(!$this->isMergeModule($rootID, $viewType) or !$products) { $modules = $this->dao->select('id,name,path,short')->from(TABLE_MODULE)->where('root')->eq($rootID)->andWhere('type')->in($viewType)->andWhere('deleted')->eq(0)->fetchAll('id'); @@ -232,7 +232,7 @@ class treeModel extends model public function getTaskOptionMenu($rootID, $productID = 0, $startModule = 0, $extra = '') { /* If createdVersion <= 4.1, go to getOptionMenu(). */ - $products = $this->loadModel('product')->getProductsByProject($rootID); + $products = $this->loadModel('product')->getProductPairsByProject($rootID); $branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products)); if(!$this->isMergeModule($rootID, 'task') or !$products) return $this->getOptionMenu($rootID, 'task', $startModule); @@ -445,7 +445,7 @@ class treeModel extends model $extra = array('projectID' => $rootID, 'productID' => $productID, 'tip' => true, 'extra' => $extra); /* If createdVersion <= 4.1, go to getTreeMenu(). */ - $products = $this->loadModel('product')->getProductsByProject($rootID); + $products = $this->loadModel('product')->getProductPairsByProject($rootID); $branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products)); if(!$this->isMergeModule($rootID, 'task') or !$products) @@ -543,7 +543,7 @@ class treeModel extends model $extra = array('projectID' => $rootID, 'productID' => $productID, 'tip' => true); /* If createdVersion <= 4.1, go to getTreeMenu(). */ - $products = $this->loadModel('product')->getProductsByProject($rootID); + $products = $this->loadModel('product')->getProductPairsByProject($rootID); $branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products)); if(!$this->isMergeModule($rootID, 'task') or !$products) @@ -639,7 +639,7 @@ class treeModel extends model ->fetchPairs(); /* Get module according to product. */ - $products = $this->loadModel('product')->getProductsByProject($rootID); + $products = $this->loadModel('product')->getProductPairsByProject($rootID); $branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products)); $productNum = count($products); foreach($products as $id => $product)