diff --git a/module/bug/control.php b/module/bug/control.php
index 3052e26bef..bc0ff219eb 100644
--- a/module/bug/control.php
+++ b/module/bug/control.php
@@ -55,12 +55,12 @@ class bug extends control
if($this->app->tab == 'project')
{
$objectID = $this->session->project;
- $products = $this->loadModel('project')->getProducts($objectID, false);
+ $products = $this->product->getProducts($objectID, 'all', '', false);
}
elseif($this->app->tab == 'execution')
{
$objectID = $this->session->execution;
- $products = $this->loadModel('execution')->getProducts($objectID, false);
+ $products = $this->product->getProducts($objectID, 'all', '', false);
}
else
{
diff --git a/module/build/control.php b/module/build/control.php
index 292221e7f0..d93836dafd 100644
--- a/module/build/control.php
+++ b/module/build/control.php
@@ -63,7 +63,7 @@ class build extends control
$executions = $this->execution->getPairs($execution->project);
}
- $productGroups = $this->execution->getProducts($executionID);
+ $productGroups = $this->loadModel('product')->getProducts($executionID);
$productID = $productID ? $productID : key($productGroups);
$branchGroups = $this->loadModel('project')->getBranchesByProject($executionID);
$branchPairs = $this->loadModel('branch')->getPairs($productID, 'active');
@@ -156,7 +156,7 @@ class build extends control
$executions = $this->product->getExecutionPairsByProduct($build->product, $build->branch, 'id_desc', $this->session->project, 'stagefilter');
if(!isset($executions[$build->execution])) $executions[$build->execution] = $execution->name;
- $productGroups = $this->execution->getProducts($build->execution);
+ $productGroups = $this->product->getProducts($build->execution);
if(!isset($productGroups[$build->product]))
{
diff --git a/module/build/js/common.js b/module/build/js/common.js
index 13f263f902..0726ba7db2 100644
--- a/module/build/js/common.js
+++ b/module/build/js/common.js
@@ -12,7 +12,7 @@ function loadBranches(productID)
var oldBranch = 0;
if(typeof(productGroups[productID]) != "undefined")
{
- oldBranch = productGroups[productID]['branch'];
+ oldBranch = productGroups[productID]['branches'];
}
$.get(createLink('branch', 'ajaxGetBranches', 'productID=' + productID + '&oldBranch=0¶m=&projectID=' + executionID), function(data)
diff --git a/module/build/view/create.html.php b/module/build/view/create.html.php
index 0c1d6bb3cf..e898e67a29 100644
--- a/module/build/view/create.html.php
+++ b/module/build/view/create.html.php
@@ -35,7 +35,7 @@
if(!empty($product) and $product->type != 'normal' and isset($branches[$product->id]))
{
$branches = $branches[$product->id];
- echo "" . html::select('branch', $branches, $product->branch, "class='form-control chosen'");
+ echo "" . html::select('branch', $branches, key($product->branches), "class='form-control chosen'");
}
?>
diff --git a/module/execution/control.php b/module/execution/control.php
index 6981d3f0de..323bfc4854 100644
--- a/module/execution/control.php
+++ b/module/execution/control.php
@@ -99,7 +99,7 @@ class execution extends control
/* Get executions and products info. */
$executionID = $this->execution->saveState($executionID, $this->executions);
$execution = $this->execution->getById($executionID);
- $products = $this->execution->getProducts($executionID);
+ $products = $this->product->getProducts($executionID);
$childExecutions = $this->execution->getChildExecutions($executionID);
$teamMembers = $this->execution->getTeamMembers($executionID);
$actions = $this->loadModel('action')->getList($this->objectType, $executionID);
@@ -746,7 +746,7 @@ class execution extends control
/* Build the search form. */
$modules = array();
$executionModules = $this->loadModel('tree')->getTaskTreeModules($executionID, true);
- $products = $this->execution->getProducts($executionID);
+ $products = $this->product->getProducts($executionID);
foreach($products as $product)
{
$productModules = $this->tree->getOptionMenu($product->id);
@@ -864,8 +864,8 @@ class execution extends control
$queryID = ($type == 'bysearch') ? (int)$param : 0;
$execution = $this->commonAction($executionID);
$executionID = $execution->id;
- $products = $this->execution->getProducts($execution->id);
- $branchID = isset($products[$productID]) ? $products[$productID]->branch : 0;
+ $products = $this->product->getProducts($execution->id);
+ $branchID = isset($products[$productID]) ? current($products[$productID]->branches) : 0;
$productPairs = array('0' => $this->lang->product->all);
foreach($products as $product) $productPairs[$product->id] = $product->name;
@@ -936,7 +936,7 @@ class execution extends control
$this->session->set('caseList', $uri, 'execution');
$this->session->set('bugList', $uri, 'execution');
- $products = $this->execution->getProducts($executionID);
+ $products = $this->product->getProducts($executionID);
$productID = key($products); // Get the first product for creating testcase.
/* Load pager. */
@@ -999,7 +999,7 @@ class execution extends control
$executionID = $execution->id;
/* Get products' list. */
- $products = $this->execution->getProducts($executionID, false);
+ $products = $this->product->getProducts($executionID, 'all', '', false);
$products = array('' => '') + $products;
/* Build the search form. */
@@ -1020,7 +1020,7 @@ class execution extends control
/* Set execution builds. */
$executionBuilds = array();
- $productList = $this->execution->getProducts($executionID);
+ $productList = $this->product->getProducts($executionID);
if(!empty($builds))
{
foreach($builds as $build)
@@ -1282,7 +1282,7 @@ class execution extends control
$acl = $copyExecution->acl;
$whitelist = $copyExecution->whitelist;
$projectID = $copyExecution->project;
- $products = $this->execution->getProducts($copyExecutionID);
+ $products = $this->loadModel('product')->getProducts($copyExecutionID);
$branches = $this->project->getBranchesByProject($copyExecutionID);
$plans = $this->loadModel('productplan')->getGroupByProduct(array_keys($products));
$branchGroups = $this->execution->getBranchByProduct(array_keys($products), $projectID);
@@ -1357,7 +1357,8 @@ class execution extends control
{
$this->lang->execution->type = str_replace($this->lang->executionCommon, $this->lang->project->stage, $this->lang->execution->type);
}
- $this->loadModel('user');
+
+ $this->loadModel('user');
$poUsers = $this->user->getPairs('noclosed|nodeleted|pofirst', '', $this->config->maxCount);
if(!empty($this->config->user->moreLink)) $this->config->moreLinks["PM"] = $this->config->user->moreLink;
@@ -1415,6 +1416,7 @@ class execution extends control
public function edit($executionID, $action = 'edit', $extra = '')
{
/* Load language files and get browseExecutionLink. */
+ $this->loadModel('product');
$this->app->loadLang('program');
$this->app->loadLang('stage');
$this->app->loadLang('programplan');
@@ -1423,7 +1425,7 @@ class execution extends control
if(!empty($_POST))
{
$oldPlans = $this->dao->select('plan')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($executionID)->andWhere('plan')->ne(0)->fetchPairs('plan');
- $oldProducts = $this->execution->getProducts($executionID);
+ $oldProducts = $this->product->getProducts($executionID);
$changes = $this->execution->update($executionID);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
@@ -1438,7 +1440,7 @@ class execution extends control
}
$oldProducts = array_keys($oldProducts);
- $newProducts = $this->execution->getProducts($executionID);
+ $newProducts = $this->product->getProducts($executionID);
$newProducts = array_keys($newProducts);
$diffProducts = array_merge(array_diff($oldProducts, $newProducts), array_diff($newProducts, $oldProducts));
$products = $diffProducts ? join(',', $newProducts) : '';
@@ -1486,14 +1488,12 @@ class execution extends control
$position[] = html::a($browseExecutionLink, $execution->name);
$position[] = $this->lang->execution->edit;
- $allProducts = array(0 => '');
- $executionProsucts = $this->execution->getProducts($execution->project, true, 'noclosed');
- foreach($executionProsucts as $product) $allProducts[$product->id] = $product->name;
+ $allProducts = array(0 => '') + $this->product->getProducts($execution->project, 'noclosed', '', false);
$this->loadModel('productplan');
$productPlans = array(0 => '');
$linkedBranches = array();
- $linkedProducts = $this->execution->getProducts($executionID);
+ $linkedProducts = $this->product->getProducts($executionID);
$branches = $this->project->getBranchesByProject($executionID);
$plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts));
$executionStories = $this->project->getStoriesByProject($executionID);
@@ -1546,7 +1546,7 @@ class execution extends control
$this->view->branches = $branches;
$this->view->unmodifiableProducts = $unmodifiableProducts;
$this->view->unmodifiableBranches = $unmodifiableBranches;
- $this->view->multiBranchProducts = $this->loadModel('product')->getMultiBranchPairs();
+ $this->view->multiBranchProducts = $this->product->getMultiBranchPairs();
$this->view->productPlans = $productPlans;
$this->view->branchGroups = $this->execution->getBranchByProduct(array_keys($linkedProducts), $execution->project);
$this->display();
@@ -1828,11 +1828,14 @@ class execution extends control
/* Execution not found to prevent searching for .*/
if(!isset($this->executions[$execution->id])) $this->executions = $this->execution->getPairs($execution->project, 'all', 'nocode');
- $products = $this->execution->getProducts($execution->id);
+ $products = $this->loadModel('product')->getProducts($execution->id);
$linkedBranches = array();
foreach($products as $product)
{
- if($product->branch) $linkedBranches[$product->branch] = $product->branch;
+ if(isset($product->branches))
+ {
+ foreach($product->branches as $branchID) $linkedBranches[$branchID] = $branchID;
+ }
}
/* Set menu. */
@@ -2245,7 +2248,7 @@ class execution extends control
if(count($_POST['products']) > 1) die(js::alert($this->lang->execution->oneProduct) . js::locate($this->createLink('execution', 'manageProducts', "executionID=$executionID&from=$from")));
}
- $oldProducts = $this->execution->getProducts($executionID);
+ $oldProducts = $this->product->getProducts($executionID);
if($from == 'buildCreate' && $this->session->buildCreate) $browseExecutionLink = $this->session->buildCreate;
@@ -2253,7 +2256,7 @@ class execution extends control
if(dao::isError()) die(js::error(dao::getError()));
$oldProducts = array_keys($oldProducts);
- $newProducts = $this->execution->getProducts($executionID);
+ $newProducts = $this->product->getProducts($executionID);
$newProducts = array_keys($newProducts);
$diffProducts = array_merge(array_diff($oldProducts, $newProducts), array_diff($newProducts, $oldProducts));
if($diffProducts) $this->loadModel('action')->create($this->objectType, $executionID, 'Managed', '', !empty($_POST['products']) ? join(',', $_POST['products']) : '');
@@ -2274,7 +2277,7 @@ class execution extends control
$position[] = $this->lang->execution->manageProducts;
$allProducts = $this->config->systemMode == 'classic' ? $this->product->getPairs('noclosed') : $this->product->getProductPairsByProject($execution->project);
- $linkedProducts = $this->execution->getProducts($execution->id);
+ $linkedProducts = $this->product->getProducts($execution->id);
$linkedBranches = array();
$branches = $this->project->getBranchesByProject($executionID);
$executionStories = $this->project->getStoriesByProject($executionID);
@@ -2431,7 +2434,7 @@ class execution extends control
/* Get projects, executions and products. */
$object = $this->project->getByID($objectID, $this->app->tab == 'project' ? 'project' : 'sprint,stage');
- $products = $this->project->getProducts($objectID);
+ $products = $this->product->getProducts($objectID);
$browseLink = $this->createLink($this->app->tab == 'project' ? 'projectstory' : 'execution', 'story', "objectID=$objectID");
$this->session->set('storyList', $this->app->getURI(true), $this->app->tab); // Save session.
@@ -2681,7 +2684,7 @@ class execution extends control
*/
public function ajaxGetProducts($executionID)
{
- $products = $this->execution->getProducts($executionID, false);
+ $products = $this->loadModel('product')->getProducts($executionID, 'all', '', false);
die(html::select('product', $products, '', 'class="form-control"'));
}
diff --git a/module/execution/model.php b/module/execution/model.php
index 3668ac5b05..da342cd500 100644
--- a/module/execution/model.php
+++ b/module/execution/model.php
@@ -544,7 +544,7 @@ class executionModel extends model
$changedAccounts[$owner] = $owner;
$teamMembers[$ownerField] = $member;
}
- if($execution->project) $this->addProjectMembers($execution->project, $teamMembers);
+ if($execution->project) $this->addProjectMembers($execution->project, $teamMembers);
$whitelist = explode(',', $execution->whitelist);
$this->loadModel('personnel')->updateWhitelist($whitelist, 'sprint', $executionID);
@@ -1628,33 +1628,6 @@ class executionModel extends model
return $managers;
}
- /**
- * Get products of a execution.
- *
- * @param int $executionID
- * @param bool $withBranch
- * @access public
- * @return array
- */
- public function getProducts($executionID, $withBranch = true, $status = 'all')
- {
- if(defined('TUTORIAL'))
- {
- if(!$withBranch) return $this->loadModel('tutorial')->getProductPairs();
- return $this->loadModel('tutorial')->getExecutionProducts();
- }
-
- $query = $this->dao->select('t2.id, t2.name, t2.type, t1.branch, t1.plan')->from(TABLE_PROJECTPRODUCT)->alias('t1')
- ->leftJoin(TABLE_PRODUCT)->alias('t2')
- ->on('t1.product = t2.id')
- ->where('t1.project')->eq((int)$executionID)
- ->andWhere('t2.deleted')->eq(0)
- ->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
- ->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->products)->fi();
- if(!$withBranch) return $query->fetchPairs('id', 'name');
- return $query->fetchAll('id');
- }
-
/**
* Get branch pairs by product id list.
*
@@ -3108,7 +3081,7 @@ class executionModel extends model
}
}
- $branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), 'noempty');
+ $branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products));
$branchPairs = array();
$productType = 'normal';
$productNum = count($products);
@@ -3119,9 +3092,12 @@ class executionModel extends model
if($product->type != 'normal')
{
$productType = $product->type;
- if($product->branch and isset($branchGroups[$product->id][$product->branch]))
+ if(isset($product->branches))
{
- $branchPairs[$product->branch] = (count($products) > 1 ? $product->name . '/' : '') . $branchGroups[$product->id][$product->branch];
+ foreach($product->branches as $branch)
+ {
+ if(isset($branchGroups[$product->id][$branch])) $branchPairs[$branch] = (count($products) > 1 ? $product->name . '/' : '') . $branchGroups[$product->id][$branch];
+ }
}
else
{
@@ -3681,7 +3657,7 @@ class executionModel extends model
$productPlans = array();
foreach($products as $productID => $product)
{
- foreach($product->branch as $branchID)
+ foreach($product->branches as $branchID)
{
$planInfo = $this->productplan->getPairs($product->id, $branchID);
foreach($planInfo as $planID => $plan)
@@ -3760,7 +3736,7 @@ class executionModel extends model
{
$this->loadModel('user')->updateUserView($executionID, $objectType, $users);
- $products = $this->getProducts($executionID, $withBranch = false);
+ $products = $this->loadModel('product')->getProducts($executionID, 'all', '', false);
if(!empty($products)) $this->user->updateUserView(array_keys($products), 'product', $users);
}
diff --git a/module/execution/view/view.html.php b/module/execution/view/view.html.php
index d9ff7abf36..9a0554305c 100644
--- a/module/execution/view/view.html.php
+++ b/module/execution/view/view.html.php
@@ -200,11 +200,13 @@
$product):?>
- branch]) ? '/' . $branchGroups[$productID][$product->branch] : '';?>
+ branches as $branchID):?>
+
- createLink('product', 'browse', "productID=$productID&branch=$product->branch"), " " . $product->name . $branchName);?>
+ createLink('product', 'browse', "productID=$productID&branch=$branchID"), " " . $product->name . $branchName);?>
+
@@ -213,10 +215,12 @@
$product):?>
- plan])):?>
-
createLink('productplan', 'view', "planID={$product->plan}"), $product->name . '/' . $planGroups[$productID][$product->plan]);?>
+ plans as $planID):?>
+
+
createLink('productplan', 'view', "planID={$planID}"), $product->name . '/' . $planGroups[$productID][$planID]);?>
+
diff --git a/module/product/control.php b/module/product/control.php
index 1e53c206c3..66adb9ca21 100644
--- a/module/product/control.php
+++ b/module/product/control.php
@@ -216,12 +216,12 @@ class product extends control
$this->app->loadLang('datatable');
$this->lang->datatable->showBranch = sprintf($this->lang->datatable->showBranch, $this->lang->product->branchName[$product->type]);
}
-
+
/* Get stories. */
if($this->app->rawModule == 'projectstory')
{
if(!empty($product)) $this->session->set('currentProductType', $product->type);
- $this->products = $this->loadModel('project')->getProducts($projectID, false);
+ $this->products = $this->product->getProducts($projectID, 'all', '', false);
$projectProducts = $this->product->getProducts($projectID);
$productPlans = $this->execution->getPlans($projectProducts);
diff --git a/module/product/model.php b/module/product/model.php
index b4a0ada3a6..4a106627ea 100644
--- a/module/product/model.php
+++ b/module/product/model.php
@@ -330,55 +330,52 @@ class productModel extends model
* @param int $projectID
* @param int $status all|noclosed
* @param string $orderBy
+ * @param bool $withBranch
* @access public
* @return array
*/
- public function getProducts($projectID = 0, $status = 'all', $orderBy = '', $test = false)
+ public function getProducts($projectID = 0, $status = 'all', $orderBy = '', $withBranch = true)
{
- if($test)
+ if(defined('TUTORIAL'))
{
- $productList = $this->dao->select('t1.*, t2.branch, t2.plan')
- ->from(TABLE_PRODUCT)->alias('t1')
- ->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')
- ->on('t1.id = t2.product')
- ->where('t1.deleted')->eq(0)
- ->beginIF(!empty($projectID))->andWhere('t2.project')->eq($projectID)->fi()
- ->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->products)->fi()
- ->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
- ->orderBy($orderBy . 't1.order asc')
- ->fetchGroup('id', 'branch');
+ if(!$withBranch) return $this->loadModel('tutorial')->getProductPairs();
+ return $this->loadModel('tutorial')->getExecutionProducts();
+ }
- $products = array();
- foreach($productList as $productID => $branches)
+ $projectProducts = $this->dao->select('t1.branch, t1.plan, t2.*')
+ ->from(TABLE_PROJECTPRODUCT)->alias('t1')
+ ->leftJoin(TABLE_PRODUCT)->alias('t2')
+ ->on('t1.product = t2.id')
+ ->where('t2.deleted')->eq(0)
+ ->beginIF(!empty($projectID))->andWhere('t1.project')->eq($projectID)->fi()
+ ->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->products)->fi()
+ ->beginIF(strpos($status, 'noclosed') !== false)->andWhere('t2.status')->ne('closed')->fi()
+ ->orderBy($orderBy . 't2.order asc')
+ ->fetchAll();
+
+ $products = array();
+ foreach($projectProducts as $product)
+ {
+ if(!$withBranch)
{
- $branch = array();
- $plan = array();
- foreach($branches as $branchID => $productInfo)
- {
- $branch[$productInfo->branch] = $productInfo->branch;
- $plan[$productInfo->plan] = $productInfo->plan;
-
- $productInfo->branch = $branch;
- $productInfo->plan = $plan;
-
- $products[$productID] = $productInfo;
- }
+ $products[$product->id] = $product->name;
+ continue;
}
- return $products;
- }
- else
- {
- $productList = $this->dao->select('t1.*, t2.branch, t2.plan')
- ->from(TABLE_PRODUCT)->alias('t1')
- ->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')
- ->on('t1.id = t2.product')
- ->where('t1.deleted')->eq(0)
- ->beginIF(!empty($projectID))->andWhere('t2.project')->eq($projectID)->fi()
- ->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->products)->fi()
- ->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
- ->orderBy($orderBy . 't1.order asc')
- ->fetchAll('id');
+
+ if(!isset($products[$product->id]))
+ {
+ $products[$product->id] = $product;
+ $products[$product->id]->branches = array();
+ $products[$product->id]->plans = array();
+ }
+ $products[$product->id]->branches[$product->branch] = $product->branch;
+ if($product->plan) $products[$product->id]->plans[$product->plan] = $product->plan;
+
+ unset($product->branch);
+ unset($product->plan);
}
+
+ return $products;
}
/**
diff --git a/module/project/control.php b/module/project/control.php
index 15519ac9b9..7047d10818 100644
--- a/module/project/control.php
+++ b/module/project/control.php
@@ -70,6 +70,8 @@ class project extends control
$projects = $this->project->getInfoList($status, 30, $orderBy, null);
$users = $this->loadModel('user')->getPairs('noletter');
+
+ $this->loadModel('product');
foreach($projects as $i => $project)
{
$project->PM = zget($users, $project->PM);
@@ -79,7 +81,7 @@ class project extends control
$project->budget = $project->budget . zget($projectLang->unitList, $project->budgetUnit);
$project->parent = $project->parentName;
- $linkedProducts = $this->project->getProducts($project->id, false);
+ $linkedProducts = $this->product->getProducts($project->id, 'all', '', false);
$project->linkedProducts = implode(',', $linkedProducts);
if($this->post->exportType == 'selected')
@@ -344,6 +346,7 @@ class project extends control
public function create($model = 'scrum', $programID = 0, $copyProjectID = 0, $extra = '')
{
$this->loadModel('execution');
+ $this->loadModel('product');
if($_POST)
{
@@ -397,7 +400,7 @@ class project extends control
{
if($model == 'waterfall')
{
- $productID = $this->loadModel('product')->getProductIDByProject($projectID, true);
+ $productID = $this->product->getProductIDByProject($projectID, true);
$this->session->set('projectPlanList', $this->createLink('programplan', 'browse', "projectID=$projectID&productID=$productID&type=lists", '', '', $projectID), 'project');
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('programplan', 'create', "projectID=$projectID", '', '', $projectID)));
}
@@ -436,7 +439,7 @@ class project extends control
$programID = $copyProject->parent;
$model = $copyProject->model;
- $products = $this->project->getProducts($copyProjectID);
+ $products = $this->product->getProducts($copyProjectID);
foreach($products as $product)
{
$productPlans[$product->id] = $this->loadModel('productplan')->getPairs($product->id);
@@ -457,7 +460,7 @@ class project extends control
$this->view->productPlans = array('0' => '') + $productPlans;
$this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), 'noclosed');
$this->view->programID = $programID;
- $this->view->multiBranchProducts = $this->loadModel('product')->getMultiBranchPairs($programID);
+ $this->view->multiBranchProducts = $this->product->getMultiBranchPairs($programID);
$this->view->model = $model;
$this->view->name = $name;
$this->view->code = $code;
@@ -531,7 +534,7 @@ class project extends control
$linkedBranches = array();
$productPlans = array(0 => '');
$allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed');
- $linkedProducts = $this->project->getProducts($projectID);
+ $linkedProducts = $this->loadModel('product')->getProducts($projectID);
$parentProject = $this->program->getByID($project->parent);
$branches = $this->project->getBranchesByProject($projectID);
$plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts));
@@ -667,7 +670,10 @@ class project extends control
$linkedBranches = array();
foreach($products as $productID => $product)
{
- if($product->branch) $linkedBranches = $product->branch;
+ if(isset($product->branches))
+ {
+ foreach($product->branches as $branchID) $linkedBranches[$branchID] = $branchID;
+ }
}
/* Load pager. */
@@ -887,8 +893,8 @@ class project extends control
$project = $this->project->getByID($projectID);
$type = strtolower($type);
$queryID = ($type == 'bysearch') ? (int)$param : 0;
- $products = $this->project->getProducts($projectID);
- $branchID = isset($products[$productID]) ? $products[$productID]->branch : 0;
+ $products = $this->product->getProducts($projectID);
+ $branchID = isset($products[$productID]) ? current($products[$productID]->branches) : 0;
$productPairs = array('0' => $this->lang->product->all);
foreach($products as $product) $productPairs[$product->id] = $product->name;
@@ -955,7 +961,7 @@ class project extends control
{
$this->loadModel('product');
$this->session->set('bugList', $this->app->getURI(true), 'project');
- $products = array('0' => $this->lang->product->all) + $this->project->getProducts($projectID, false);
+ $products = array('0' => $this->lang->product->all) + $this->product->getProducts($projectID, 'all', '', false);
$this->lang->modulePageNav = $this->product->select($products, $productID, 'project', 'testcase', '', $branch, 0, '', false);
echo $this->fetch('testcase', 'browse', "productID=$productID&branch=$branch&browseType=$browseType¶m=$param&orderBy=$orderBy&recTotal=$orderBy&recPerPage=$recPerPage&pageID=$pageID&projectID=$projectID");
@@ -1039,13 +1045,14 @@ class project extends control
{
/* Load module and get project. */
$this->loadModel('build');
+ $this->loadModel('product');
$project = $this->project->getByID($projectID);
$this->project->setMenu($projectID);
$this->session->set('buildList', $this->app->getURI(true), 'project');
/* Get products' list. */
- $products = $this->project->getProducts($projectID, false);
+ $products = $this->product->getProducts($projectID, 'all', '', false);
$products = array('' => '') + $products;
/* Build the search form. */
@@ -1070,7 +1077,7 @@ class project extends control
/* Set project builds. */
$projectBuilds = array();
- $productList = $this->project->getProducts($projectID);
+ $productList = $this->product->getProducts($projectID);
if(!empty($builds))
{
foreach($builds as $build)
@@ -1683,12 +1690,12 @@ class project extends control
return $this->send(array('result' => 'fail', 'message' => dao::getError()));
}
- $oldProducts = $this->project->getProducts($projectID);
+ $oldProducts = $this->product->getProducts($projectID);
$this->project->updateProducts($projectID);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$oldProducts = array_keys($oldProducts);
- $newProducts = $this->project->getProducts($projectID);
+ $newProducts = $this->product->getProducts($projectID);
$newProducts = array_keys($newProducts);
$diffProducts = array_merge(array_diff($oldProducts, $newProducts), array_diff($newProducts, $oldProducts));
if($diffProducts) $this->loadModel('action')->create('project', $projectID, 'Managed', '', !empty($_POST['products']) ? join(',', $_POST['products']) : '');
diff --git a/module/project/model.php b/module/project/model.php
index 4464eb27b9..2fc7d8b741 100644
--- a/module/project/model.php
+++ b/module/project/model.php
@@ -534,32 +534,6 @@ class projectModel extends model
->fetchPairs('project');
}
- /**
- * Get products of a project.
- *
- * @param int $projectID
- * @param bool $withBranch
- * @access public
- * @return array
- */
- public function getProducts($projectID, $withBranch = true, $status = 'all')
- {
- if(defined('TUTORIAL'))
- {
- if(!$withBranch) return $this->loadModel('tutorial')->getProductPairs();
- return $this->loadModel('tutorial')->getExecutionProducts();
- }
-
- $query = $this->dao->select('t2.id, t2.name, t2.type, t1.branch, t1.plan')->from(TABLE_PROJECTPRODUCT)->alias('t1')
- ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
- ->where('t1.project')->eq((int)$projectID)
- ->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
- ->beginIF(!$this->app->user->admin)->andWhere('t1.product')->in($this->app->user->view->products)->fi()
- ->andWhere('t2.deleted')->eq(0);
- if(!$withBranch) return $query->fetchPairs('id', 'name');
- return $query->fetchAll('id');
- }
-
/**
* Get branches by project id.
*
@@ -1482,7 +1456,7 @@ class projectModel extends model
$class = "c-$id" . (in_array($id, array('budget', 'teamCount', 'estimate', 'consume')) ? ' c-number' : '');
if($id == 'id') $class .= ' cell-id';
-
+
if($id == 'code') $title = "title={$project->code}";
if($id == 'name')
diff --git a/module/project/view/create.html.php b/module/project/view/create.html.php
index 4f195e90f0..80565c63d5 100644
--- a/module/project/view/create.html.php
+++ b/module/project/view/create.html.php
@@ -109,7 +109,7 @@
id, "class='form-control chosen' onchange='loadBranches(this)' data-last='" . $product->id . "'");?>
- id], $product->branch, "class='form-control chosen' onchange=\"loadPlans('#products{$i}', this.value)\"");?>
+ id], key($product->branches), "class='form-control chosen' onchange=\"loadPlans('#products{$i}', this.value)\"");?>
diff --git a/module/project/view/view.html.php b/module/project/view/view.html.php
index daf52bfb5a..656b9d99d6 100644
--- a/module/project/view/view.html.php
+++ b/module/project/view/view.html.php
@@ -140,7 +140,7 @@
$product):?>
- branch as $branchID):?>
+ branches as $branchID):?>
createLink('product', 'browse', "productID=$productID&branch=$branchID"), "
" . $product->name . $branchName);?>
@@ -155,7 +155,7 @@
$product):?>
- plan as $planID):?>
+ plans as $planID):?>
createLink('productplan', 'view', "planID={$planID}"), $product->name . '/' . $planGroup[$productID][$planID]);?>
diff --git a/module/story/model.php b/module/story/model.php
index 9539d9b3be..46fe149a0b 100644
--- a/module/story/model.php
+++ b/module/story/model.php
@@ -2417,14 +2417,9 @@ class storyModel extends model
*/
public function getBySearch($productID, $branch = '', $queryID, $orderBy, $executionID = '', $type = 'story', $excludeStories = '', $pager = null)
{
- if(!empty($executionID))
- {
- $products = $this->loadModel('project')->getProducts($executionID);
- }
- else
- {
- $products = $this->loadModel('product')->getProducts();
- }
+ $executionID = empty($executionID) ? 0 : $executionID;
+ $products = $this->loadModel('product')->getProducts($executionID);
+
$query = $queryID ? $this->loadModel('search')->getQuery($queryID) : '';
/* Get the sql and form status from the query. */
@@ -2449,9 +2444,14 @@ class storyModel extends model
$allBranch = "`branch` = 'all'";
if($executionID != '')
{
- foreach($products as $product) $branches[$product->branch] = $product->branch;
+ $branches = array();
+ foreach($products as $product)
+ {
+ foreach($product->branches as $branchID) $branches[$branchID] = $branchID;
+ }
$branches = join(',', $branches);
if($branches) $storyQuery .= " AND `branch`" . helper::dbIN($branches);
+
if($this->app->moduleName == 'release' or $this->app->moduleName == 'build')
{
$storyQuery .= " AND `status` NOT IN ('draft')"; // Fix bug #990.
diff --git a/module/testcase/control.php b/module/testcase/control.php
index d900def98d..ae077935e8 100644
--- a/module/testcase/control.php
+++ b/module/testcase/control.php
@@ -50,12 +50,12 @@ class testcase extends control
if($this->app->tab == 'project')
{
$objectID = $this->session->project;
- $products = $this->loadModel('project')->getProducts($objectID, false);
+ $products = $this->product->getProducts($objectID, 'all', '', false);
}
elseif($this->app->tab == 'execution')
{
$objectID = $this->session->execution;
- $products = $this->loadModel('execution')->getProducts($objectID, false);
+ $products = $this->product->getProducts($objectID, 'all', '', false);
}
else
{
@@ -125,7 +125,7 @@ class testcase extends control
/* Set menu, save session. */
if($this->app->tab == 'project')
{
- $this->products = array('0' => $this->lang->product->all) + $this->loadModel('project')->getProducts($projectID, false);
+ $this->products = array('0' => $this->lang->product->all) + $this->product->getProducts($projectID, 'all', '', false);
$this->loadModel('project')->setMenu($projectID);
}
else