* Fix bug #19072.
This commit is contained in:
@@ -1501,6 +1501,8 @@ class execution extends control
|
||||
$this->app->loadLang('programplan');
|
||||
$browseExecutionLink = $this->createLink('execution', 'browse', "executionID=$executionID");
|
||||
$execution = $this->execution->getById($executionID);
|
||||
$branches = $this->project->getBranchesByProject($executionID);
|
||||
$executionProducts = empty($branches) ? '' : array_keys($branches);
|
||||
|
||||
if($execution->type == 'kanban')
|
||||
{
|
||||
@@ -1512,7 +1514,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->product->getProducts($executionID);
|
||||
$oldProducts = $this->product->getProducts($executionID, 'all', '', true, $executionProducts);
|
||||
$changes = $this->execution->update($executionID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
@@ -1527,7 +1529,7 @@ class execution extends control
|
||||
}
|
||||
|
||||
$oldProducts = array_keys($oldProducts);
|
||||
$newProducts = $this->product->getProducts($executionID);
|
||||
$newProducts = $this->product->getProducts($executionID, 'all', '', true, $executionProducts);
|
||||
$newProducts = array_keys($newProducts);
|
||||
$diffProducts = array_merge(array_diff($oldProducts, $newProducts), array_diff($newProducts, $oldProducts));
|
||||
$products = $diffProducts ? join(',', $newProducts) : '';
|
||||
@@ -1576,15 +1578,14 @@ class execution extends control
|
||||
$position[] = html::a($browseExecutionLink, $execution->name);
|
||||
$position[] = $this->lang->execution->edit;
|
||||
|
||||
$allProducts = $this->config->systemMode == 'classic' ? $this->product->getPairs('noclosed') : $this->product->getProducts($execution->project, 'noclosed', '', false);
|
||||
$allProducts = $this->config->systemMode == 'classic' ? $this->product->getPairs('noclosed', 0, $executionProducts) : $this->product->getProducts($execution->project, 'noclosed', '', false, $executionProducts);
|
||||
$allProducts = array(0 => '') + $allProducts;
|
||||
|
||||
$this->loadModel('productplan');
|
||||
$productPlans = array(0 => '');
|
||||
$linkedBranches = array();
|
||||
$linkedBranchList = array();
|
||||
$linkedProducts = $this->product->getProducts($executionID);
|
||||
$branches = $this->project->getBranchesByProject($executionID);
|
||||
$linkedProducts = $this->product->getProducts($executionID, 'all', '', true, $executionProducts);
|
||||
$plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts), 'skipParent|unexpired');
|
||||
$executionStories = $this->project->getStoriesByProject($executionID);
|
||||
|
||||
@@ -2579,11 +2580,12 @@ class execution extends control
|
||||
$position[] = html::a($browseExecutionLink, $execution->name);
|
||||
$position[] = $this->lang->execution->manageProducts;
|
||||
|
||||
$allProducts = $this->config->systemMode == 'classic' ? $this->product->getPairs('noclosed') : $this->product->getProductPairsByProject($execution->project);
|
||||
$linkedProducts = $this->product->getProducts($execution->id);
|
||||
$linkedBranches = array();
|
||||
$branches = $this->project->getBranchesByProject($executionID);
|
||||
$executionStories = $this->project->getStoriesByProject($executionID);
|
||||
$branches = $this->project->getBranchesByProject($executionID);
|
||||
$executionProducts = empty($branches) ? '' : array_keys($branches);
|
||||
$allProducts = $this->config->systemMode == 'classic' ? $this->product->getPairs('noclosed', 0, $executionProducts) : $this->product->getProductPairsByProject($execution->project, 'all', $executionProducts);
|
||||
$linkedProducts = $this->product->getProducts($execution->id, 'all', '', true, $executionProducts);
|
||||
$linkedBranches = array();
|
||||
$executionStories = $this->project->getStoriesByProject($executionID);
|
||||
|
||||
/* If the story of the product which linked the execution, you don't allow to remove the product. */
|
||||
$unmodifiableProducts = array();
|
||||
|
||||
+23
-14
@@ -273,14 +273,18 @@ class productModel extends model
|
||||
/**
|
||||
* Get product pairs.
|
||||
*
|
||||
* @param string $mode
|
||||
* @param string $programID
|
||||
* @param string $mode
|
||||
* @param string $programID
|
||||
* @param string|array $append
|
||||
* @return array
|
||||
*/
|
||||
public function getPairs($mode = '', $programID = 0)
|
||||
public function getPairs($mode = '', $programID = 0, $append = '')
|
||||
{
|
||||
if(defined('TUTORIAL')) return $this->loadModel('tutorial')->getProductPairs();
|
||||
|
||||
if(!empty($append) and is_array($append)) $append = implode($append, ',');
|
||||
|
||||
$views = $append ? $this->app->user->view->products . ",$append" : $this->app->user->view->products;
|
||||
$orderBy = !empty($this->config->product->orderBy) ? $this->config->product->orderBy : 'isClosed';
|
||||
$products = $this->dao->select('*, IF(INSTR(" closed", status) < 2, 0, 1) AS isClosed')
|
||||
->from(TABLE_PRODUCT)
|
||||
@@ -288,7 +292,7 @@ class productModel extends model
|
||||
->beginIF(strpos($mode, 'all') === false)->andWhere('deleted')->eq(0)->fi()
|
||||
->beginIF($programID)->andWhere('program')->eq($programID)->fi()
|
||||
->beginIF(strpos($mode, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
|
||||
->beginIF(!$this->app->user->admin and $this->config->vision == 'rnd')->andWhere('id')->in($this->app->user->view->products)->fi()
|
||||
->beginIF(!$this->app->user->admin and $this->config->vision == 'rnd')->andWhere('id')->in($views)->fi()
|
||||
->andWhere('vision')->eq($this->config->vision)
|
||||
->orderBy($orderBy)
|
||||
->fetchPairs('id', 'name');
|
||||
@@ -298,14 +302,15 @@ class productModel extends model
|
||||
/**
|
||||
* Get product pairs by project.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $status all|noclosed
|
||||
* @param int $projectID
|
||||
* @param int $status all|noclosed
|
||||
* @param string|array $append
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProductPairsByProject($projectID = 0, $status = 'all')
|
||||
public function getProductPairsByProject($projectID = 0, $status = 'all', $append = '')
|
||||
{
|
||||
$products = empty($projectID) ? $this->getList() : $this->getProducts($projectID, $status);
|
||||
$products = empty($projectID) ? $this->getList() : $this->getProducts($projectID, $status, '', true, $append);
|
||||
$pairs = array();
|
||||
if(!empty($products))
|
||||
{
|
||||
@@ -337,14 +342,15 @@ class productModel extends model
|
||||
/**
|
||||
* Get products by project.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $status all|noclosed
|
||||
* @param string $orderBy
|
||||
* @param bool $withBranch
|
||||
* @param int $projectID
|
||||
* @param int $status all|noclosed
|
||||
* @param string $orderBy
|
||||
* @param bool $withBranch
|
||||
* @param string|array $append
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProducts($projectID = 0, $status = 'all', $orderBy = '', $withBranch = true)
|
||||
public function getProducts($projectID = 0, $status = 'all', $orderBy = '', $withBranch = true, $append = '')
|
||||
{
|
||||
if(defined('TUTORIAL'))
|
||||
{
|
||||
@@ -352,13 +358,16 @@ class productModel extends model
|
||||
return $this->loadModel('tutorial')->getExecutionProducts();
|
||||
}
|
||||
|
||||
if(!empty($append) and is_array($append)) $append = implode($append, ',');
|
||||
|
||||
$views = $append ? $this->app->user->view->products . ",$append" : $this->app->user->view->products;
|
||||
$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 and $this->config->vision == 'rnd')->andWhere('t2.id')->in($this->app->user->view->products)->fi()
|
||||
->beginIF(!$this->app->user->admin and $this->config->vision == 'rnd')->andWhere('t2.id')->in($views)->fi()
|
||||
->andWhere('t2.vision')->eq($this->config->vision)
|
||||
->beginIF(strpos($status, 'noclosed') !== false)->andWhere('t2.status')->ne('closed')->fi()
|
||||
->orderBy($orderBy . 't2.order asc')
|
||||
|
||||
@@ -62,13 +62,14 @@ class programModel extends model
|
||||
/**
|
||||
* Get the product associated with the program.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param string $mode all|assign
|
||||
* @param string $status all|noclosed
|
||||
* @param int $programID
|
||||
* @param string $mode all|assign
|
||||
* @param string $status all|noclosed
|
||||
* @param string|array $append
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProductPairs($programID = 0, $mode = 'assign', $status = 'all')
|
||||
public function getProductPairs($programID = 0, $mode = 'assign', $status = 'all', $append = '')
|
||||
{
|
||||
/* Get the top programID. */
|
||||
if($programID)
|
||||
@@ -80,12 +81,15 @@ class programModel extends model
|
||||
}
|
||||
|
||||
/* When mode equals assign and programID equals 0, you can query the standalone product. */
|
||||
if(!empty($append) and is_array($append)) $append = implode($append, ',');
|
||||
|
||||
$views = $append ? $this->app->user->view->products . ",$append" : $this->app->user->view->products;
|
||||
$products = $this->dao->select('*')->from(TABLE_PRODUCT)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('vision')->eq($this->config->vision)
|
||||
->beginIF($mode == 'assign')->andWhere('program')->eq($programID)->fi()
|
||||
->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
|
||||
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi()
|
||||
->beginIF(!$this->app->user->admin)->andWhere('id')->in($views)->fi()
|
||||
->fetchPairs('id', 'name');
|
||||
return $products;
|
||||
}
|
||||
|
||||
@@ -574,10 +574,11 @@ class project extends control
|
||||
$linkedBranches = array();
|
||||
$linkedBranchList = array();
|
||||
$productPlans = array(0 => '');
|
||||
$allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed');
|
||||
$linkedProducts = $this->loadModel('product')->getProducts($projectID);
|
||||
$parentProject = $this->program->getByID($project->parent);
|
||||
$branches = $this->project->getBranchesByProject($projectID);
|
||||
$projectProducts = empty($branches) ? '' : array_keys($branches);
|
||||
$allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed', $projectProducts);
|
||||
$linkedProducts = $this->loadModel('product')->getProducts($projectID, 'all', '', true, $projectProducts);
|
||||
$parentProject = $this->program->getByID($project->parent);
|
||||
$plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts), 'skipParent|unexpired');
|
||||
$projectStories = $this->project->getStoriesByProject($projectID);
|
||||
$projectBranches = $this->project->getBranchGroupByProject($projectID, array_keys($linkedProducts));
|
||||
@@ -1806,9 +1807,10 @@ class project extends control
|
||||
}
|
||||
|
||||
$linkedBranches = array();
|
||||
$allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed');
|
||||
$linkedProducts = $this->product->getProducts($projectID);
|
||||
$branches = $this->project->getBranchesByProject($projectID);
|
||||
$projectProducts = empty($branches) ? '' : array_keys($branches);
|
||||
$allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed', $projectProducts);
|
||||
$linkedProducts = $this->product->getProducts($projectID, 'all', '', true, $projectProducts);
|
||||
$projectStories = $this->project->getStoriesByProject($projectID);
|
||||
$projectBranches = $this->project->getBranchGroupByProject($projectID, array_keys($linkedProducts));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user