From bd9b982157f88a433edfb97f184c7a06293beb4e Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 24 Mar 2022 08:39:15 +0800 Subject: [PATCH 1/4] * Fix the problem that the kanban cannot be displayed in the IE browser. --- module/kanban/js/view.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/kanban/js/view.js b/module/kanban/js/view.js index 7d87f0342e..3aab286d6f 100644 --- a/module/kanban/js/view.js +++ b/module/kanban/js/view.js @@ -822,8 +822,9 @@ function finishCard(cardID, kanbanID, regionID) * @access public * @return boolean */ -function updateRegion(regionID, regionData = []) +function updateRegion(regionID, regionData) { + if(typeof(regionData) == 'undefined') regionData = []; if(!regionID) return false; var $region = $('#kanban'+ regionID).kanban(); From e9ee8a176db1e5f5c2d9c5aed8afc37d5c4f9f90 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 24 Mar 2022 09:35:39 +0800 Subject: [PATCH 2/4] * Fix bug #19072. --- module/execution/control.php | 22 +++++++++++---------- module/product/model.php | 37 ++++++++++++++++++++++-------------- module/program/model.php | 14 +++++++++----- module/project/control.php | 12 +++++++----- 4 files changed, 51 insertions(+), 34 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index e27e25e6c4..82e9efca19 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -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(); diff --git a/module/product/model.php b/module/product/model.php index 70063f678a..930c4597af 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -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') diff --git a/module/program/model.php b/module/program/model.php index d41d852063..cfa76dbf4a 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -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; } diff --git a/module/project/control.php b/module/project/control.php index 32b106b0bc..46e66320a8 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -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)); From 9b7d8686c70e99d2cf09d5d86ae84822c982d7af Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 24 Mar 2022 09:42:08 +0800 Subject: [PATCH 3/4] * Modify the judgment logic. --- module/product/model.php | 4 ++-- module/program/model.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module/product/model.php b/module/product/model.php index 930c4597af..a32997f485 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -284,7 +284,7 @@ class productModel extends model if(!empty($append) and is_array($append)) $append = implode($append, ','); - $views = $append ? $this->app->user->view->products . ",$append" : $this->app->user->view->products; + $views = empty($append) ? $this->app->user->view->products : $this->app->user->view->products . ",$append"; $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) @@ -360,7 +360,7 @@ class productModel extends model if(!empty($append) and is_array($append)) $append = implode($append, ','); - $views = $append ? $this->app->user->view->products . ",$append" : $this->app->user->view->products; + $views = empty($append) ? $this->app->user->view->products : $this->app->user->view->products . ",$append"; $projectProducts = $this->dao->select('t1.branch, t1.plan, t2.*') ->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2') diff --git a/module/program/model.php b/module/program/model.php index cfa76dbf4a..6d4149b771 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -83,7 +83,7 @@ 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; + $views = empty($append) ? $this->app->user->view->products : $this->app->user->view->products . ",$append"; $products = $this->dao->select('*')->from(TABLE_PRODUCT) ->where('deleted')->eq(0) ->andWhere('vision')->eq($this->config->vision) From 9178a6e3b32d50f35c23e13a4c6f466d2c473c0b Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 24 Mar 2022 10:27:42 +0800 Subject: [PATCH 4/4] * Modify variable name. --- module/execution/control.php | 22 +++++++++++----------- module/product/model.php | 4 ++-- module/project/control.php | 36 ++++++++++++++++++------------------ 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 82e9efca19..2bf3dbc620 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1502,7 +1502,7 @@ class execution extends control $browseExecutionLink = $this->createLink('execution', 'browse', "executionID=$executionID"); $execution = $this->execution->getById($executionID); $branches = $this->project->getBranchesByProject($executionID); - $executionProducts = empty($branches) ? '' : array_keys($branches); + $linkedProductIdList = empty($branches) ? '' : array_keys($branches); if($execution->type == 'kanban') { @@ -1514,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, 'all', '', true, $executionProducts); + $oldProducts = $this->product->getProducts($executionID, 'all', '', true, $linkedProductIdList); $changes = $this->execution->update($executionID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); @@ -1529,7 +1529,7 @@ class execution extends control } $oldProducts = array_keys($oldProducts); - $newProducts = $this->product->getProducts($executionID, 'all', '', true, $executionProducts); + $newProducts = $this->product->getProducts($executionID, 'all', '', true, $linkedProductIdList); $newProducts = array_keys($newProducts); $diffProducts = array_merge(array_diff($oldProducts, $newProducts), array_diff($newProducts, $oldProducts)); $products = $diffProducts ? join(',', $newProducts) : ''; @@ -1578,14 +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', 0, $executionProducts) : $this->product->getProducts($execution->project, 'noclosed', '', false, $executionProducts); + $allProducts = $this->config->systemMode == 'classic' ? $this->product->getPairs('noclosed', 0, $linkedProductIdList) : $this->product->getProducts($execution->project, 'noclosed', '', false, $linkedProductIdList); $allProducts = array(0 => '') + $allProducts; $this->loadModel('productplan'); $productPlans = array(0 => ''); $linkedBranches = array(); $linkedBranchList = array(); - $linkedProducts = $this->product->getProducts($executionID, 'all', '', true, $executionProducts); + $linkedProducts = $this->product->getProducts($executionID, 'all', '', true, $linkedProductIdList); $plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts), 'skipParent|unexpired'); $executionStories = $this->project->getStoriesByProject($executionID); @@ -2580,12 +2580,12 @@ class execution extends control $position[] = html::a($browseExecutionLink, $execution->name); $position[] = $this->lang->execution->manageProducts; - $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); + $branches = $this->project->getBranchesByProject($executionID); + $linkedProductIdList = empty($branches) ? '' : array_keys($branches); + $allProducts = $this->config->systemMode == 'classic' ? $this->product->getPairs('noclosed', 0, $linkedProductIdList) : $this->product->getProductPairsByProject($execution->project, 'all', $linkedProductIdList); + $linkedProducts = $this->product->getProducts($execution->id, 'all', '', true, $linkedProductIdList); + $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(); diff --git a/module/product/model.php b/module/product/model.php index a32997f485..5d7f95728a 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -303,7 +303,7 @@ class productModel extends model * Get product pairs by project. * * @param int $projectID - * @param int $status all|noclosed + * @param string $status all|noclosed * @param string|array $append * @access public * @return array @@ -343,7 +343,7 @@ class productModel extends model * Get products by project. * * @param int $projectID - * @param int $status all|noclosed + * @param string $status all|noclosed * @param string $orderBy * @param bool $withBranch * @param string|array $append diff --git a/module/project/control.php b/module/project/control.php index 46e66320a8..e9c203372c 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -571,17 +571,17 @@ class project extends control return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $locateLink)); } - $linkedBranches = array(); - $linkedBranchList = array(); - $productPlans = array(0 => ''); - $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)); + $linkedBranches = array(); + $linkedBranchList = array(); + $productPlans = array(0 => ''); + $branches = $this->project->getBranchesByProject($projectID); + $linkedProductIdList = empty($branches) ? '' : array_keys($branches); + $allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed', $linkedProductIdList); + $linkedProducts = $this->loadModel('product')->getProducts($projectID, 'all', '', true, $linkedProductIdList); + $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)); /* If the story of the product which linked the project, you don't allow to remove the product. */ $unmodifiableProducts = array(); @@ -1806,13 +1806,13 @@ class project extends control $this->project->setMenu($projectID); } - $linkedBranches = array(); - $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)); + $linkedBranches = array(); + $branches = $this->project->getBranchesByProject($projectID); + $linkedProductIdList = empty($branches) ? '' : array_keys($branches); + $allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed', $linkedProductIdList); + $linkedProducts = $this->product->getProducts($projectID, 'all', '', true, $linkedProductIdList); + $projectStories = $this->project->getStoriesByProject($projectID); + $projectBranches = $this->project->getBranchGroupByProject($projectID, array_keys($linkedProducts)); /* If the story of the product which linked the project, you don't allow to remove the product. */ $unmodifiableProducts = array();