From 8b6ba26c9f4f96861d7058ba6a6260393d77e516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Fri, 5 Nov 2021 11:33:59 +0800 Subject: [PATCH 1/9] * fix bug #15189. --- lib/filter/filter.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/filter/filter.class.php b/lib/filter/filter.class.php index 3c92af1281..ebedf6292b 100644 --- a/lib/filter/filter.class.php +++ b/lib/filter/filter.class.php @@ -5,7 +5,7 @@ * * The author disclaims copyright to this source code. In place of * a legal notice, here is a blessing: - * + * * May you do good and not evil. * May you find forgiveness for yourself and forgive others. * May you share freely, never taking more than you give. @@ -15,7 +15,7 @@ helper::import(dirname(dirname(__FILE__)) . '/base/filter/filter.class.php'); /** * validater类,检查数据是否符合规则。 * The validater class, checking data by rules. - * + * * @package framework */ class validater extends baseValidater @@ -25,7 +25,7 @@ class validater extends baseValidater /** * fixer类,处理数据。 * fixer class, to fix data types. - * + * * @package framework */ class fixer extends baseFixer @@ -60,7 +60,7 @@ class fixer extends baseFixer } if($canImplode) $this->data->$field = implode(',', $value); } - if(isset($flowFields[$field]) and $flowFields[$field]->control == 'textarea') $this->skipSpecial($field); + if(isset($flowFields[$field]) and ($flowFields[$field]->control == 'textarea' or $flowFields[$field]->control == 'richtext')) $this->skipSpecial($field); $this->specialChars($field); } From 77da7770649523d372deac5429b228bbea8c7723 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 5 Nov 2021 15:46:52 +0800 Subject: [PATCH 2/9] * Finish task #43893. --- module/branch/control.php | 3 +- module/branch/model.php | 11 +++++-- module/bug/control.php | 2 +- module/productplan/control.php | 8 ++--- module/productplan/model.php | 19 ++++++++++- module/story/control.php | 48 +++++++++++++++++++++++++--- module/story/lang/en.php | 1 + module/story/lang/zh-cn.php | 1 + module/story/model.php | 38 ++++++++++++++++++++-- module/story/view/batchedit.html.php | 1 + 10 files changed, 115 insertions(+), 17 deletions(-) diff --git a/module/branch/control.php b/module/branch/control.php index e59c0aa6c7..8b57ddb8eb 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -70,8 +70,7 @@ class branch extends control $this->view->method = $method; $this->view->extra = $extra; - $branches = $this->branch->getPairs($productID); - $this->view->branches = $branches; + $this->view->branches = $this->branch->getPairs($productID, 'all'); $this->view->currentBranchID = $branch; $this->view->branchesPinyin = common::convert2Pinyin($branches); $this->display(); diff --git a/module/branch/model.php b/module/branch/model.php index f11c0a0f3d..c70accb810 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -40,6 +40,9 @@ class branchModel extends model */ public function getPairs($productID, $params = '') { + $product = $this->loadModel('product')->getById($productID); + if(!$product or $product->type == 'normal') return array(); + $branches = $this->dao->select('*')->from(TABLE_BRANCH) ->where('deleted')->eq(0) ->beginIF($productID)->andWhere('product')->eq($productID)->fi() @@ -49,10 +52,12 @@ class branchModel extends model if(strpos($params, 'noempty') === false) { - $product = $this->loadModel('product')->getById($productID); - if(!$product or $product->type == 'normal') return array(); + $branches = array('0' => $this->lang->branch->main) + $branches; + } - $branches = array('all' => $this->lang->branch->all, '0' => $this->lang->branch->main) + $branches; + if(strpos($params, 'all') !== false) + { + $branches = array('all' => $this->lang->branch->all) + $branches; } return $branches; } diff --git a/module/bug/control.php b/module/bug/control.php index 63a3446018..d3d9486b1f 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -226,7 +226,7 @@ class bug extends control $this->view->moduleID = $moduleID; $this->view->memberPairs = $this->user->getPairs('noletter|nodeleted'); $this->view->branch = $branch; - $this->view->branches = $this->loadModel('branch')->getPairs($productID, 'noempty'); + $this->view->branches = $this->loadModel('branch')->getPairs($productID); $this->view->executions = $executions; $this->view->plans = $this->loadModel('productplan')->getPairs($productID); $this->view->stories = $storyList; diff --git a/module/productplan/control.php b/module/productplan/control.php index fcd0b36611..386266f1fe 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -413,8 +413,8 @@ class productplan extends control else { $this->config->product->search['fields']['branch'] = $this->lang->product->branch; - $branches = array('' => '') + $this->loadModel('branch')->getPairs($plan->product, 'noempty'); - if($plan->branch) $branches = array('' => '', $plan->branch => $branches[$plan->branch]); + $branches = array('' => '', '0' => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($plan->product, 'noempty'); + if($plan->branch) $branches = array('' => '', '0' => $this->lang->branch->main, $plan->branch => $branches[$plan->branch]); $this->config->product->search['params']['branch']['values'] = $branches; } $this->loadModel('search')->setSearchParams($this->config->product->search); @@ -554,8 +554,8 @@ class productplan extends control else { $this->config->bug->search['fields']['branch'] = $this->lang->product->branch; - $branches = array('' => '') + $this->loadModel('branch')->getPairs($productID, 'noempty'); - if($plan->branch) $branches = array('' => '', $plan->branch => $branches[$plan->branch]); + $branches = array('' => '', '0' => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($productID, 'noempty'); + if($plan->branch) $branches = array('' => '', '0' => $this->lang->branch->main, $plan->branch => $branches[$plan->branch]); $this->config->bug->search['params']['branch']['values'] = $branches; } $this->loadModel('search')->setSearchParams($this->config->bug->search); diff --git a/module/productplan/model.php b/module/productplan/model.php index 0e76645121..d5fae673f5 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -237,7 +237,6 @@ class productplanModel extends model $plans = $this->dao->select('id,title,parent,begin,end')->from(TABLE_PRODUCTPLAN) ->where('product')->in($product) ->andWhere('deleted')->eq(0) - ->andWhere('end')->ge($date) ->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi() ->beginIF($skipParent)->andWhere('parent')->ne(-1)->fi() ->orderBy('begin desc') @@ -319,6 +318,24 @@ class productplanModel extends model return $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('parent')->eq((int)$planID)->andWhere('deleted')->eq('0')->fetchAll(); } + /** + * Get plan list by story id list. + * + * @param string|array $storyIdList + * @access public + * @return array + */ + public function getPlansByStories($storyIdList) + { + if(empty($storyIdList)) return array(); + return $this->dao->select('t1.id as storyID, t3.*')->from(TABLE_STORY)->alias('t1') + ->leftJoin(TABLE_PLANSTORY)->alias('t2')->on('t1.id=t2.story') + ->leftJoin(TABLE_PRODUCTPLAN)->alias('t3')->on('t2.plan=t3.id') + ->where('t1.id')->in($storyIdList) + ->andWhere('t3.deleted')->eq(0) + ->fetchGroup('storyID', 'id'); + } + /** * Create a plan. * diff --git a/module/story/control.php b/module/story/control.php index 90da967309..481e2fc666 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -306,7 +306,7 @@ class story extends control $this->view->users = $users; $this->view->moduleID = $moduleID ? $moduleID : (int)$this->cookie->lastStoryModule; $this->view->moduleOptionMenu = $moduleOptionMenu; - $this->view->plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch, true); + $this->view->plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch); $this->view->planID = $planID; $this->view->source = $source; $this->view->sourceNote = $sourceNote; @@ -626,6 +626,7 @@ class story extends control $this->view->stories = $stories; $this->view->users = $users; $this->view->product = $product; + $this->view->plans = $this->loadModel('productplan')->getPairsForStory($story->product, $story->branch); $this->view->products = $myProducts + $othersProducts; $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($story->product); $this->view->reviewers = implode(',', $reviewerList); @@ -1376,14 +1377,53 @@ class story extends control * Batch change branch. * * @param int $branchID + * @param string $confirm yes|no + * @param string $storyIdList * @access public * @return void */ - public function batchChangeBranch($branchID) + public function batchChangeBranch($branchID, $confirm = '', $storyIdList = '') { - $storyIdList = !empty($_POST['storyIdList']) ? $this->post->storyIdList : die(js::locate($this->session->storyList, 'parent')); + if(!empty($_POST['storyIdList'])) $storyIdList = $_POST['storyIdList']; + $storyIdList = !empty($storyIdList) ? $storyIdList : die(js::locate($this->session->storyList, 'parent')); + $plans = $this->loadModel('productplan')->getPlansByStories($storyIdList); + if(empty($confirm)) + { + $stories = $this->story->getByList($storyIdList); + $normalStotyIdList = ''; + $conflictStoryIdList = ''; + $conflictStoryArray = array(); + /* Determine whether there is a conflict between the branch of the story and the linked plan. */ + foreach($storyIdList as $storyID) + { + if($stories[$storyID]->branch != $branchID and $branchID != BRANCH_MAIN and isset($plans[$storyID])) + { + foreach($plans[$storyID] as $plan) + { + if($plan->branch != BRANCH_MAIN and $plan->branch != $branchID and strpos($conflictStoryIdList, '[' . $storyID . ']') === false) + { + $conflictStoryIdList .= '[' . $storyID . ']'; + $conflictStoryArray[] = $storyID; + } + } + } + } + + /* Prompt the user whether to continue to modify the conflicting stories branch. */ + if($conflictStoryIdList) + { + $normalStotyIdList = array_diff($storyIdList, $conflictStoryArray); + $normalStotyIdList = implode(',', $normalStotyIdList); + $storyIdList = implode(',', $storyIdList); + $confirmURL = $this->createLink('story', 'batchChangeBranch', "branchID=$branchID&confirm=yes&storyIdList=$storyIdList"); + $cancelURL = $this->createLink('story', 'batchChangeBranch', "branchID=$branchID&confirm=no&storyIdList=$normalStotyIdList"); + die(js::confirm(sprintf($this->lang->story->confirmChangeBranch, $conflictStoryIdList ), $confirmURL, $cancelURL)); + } + } + + if(is_string($storyIdList)) $storyIdList = array_filter(explode(',', $storyIdList)); $storyIdList = array_unique($storyIdList); - $allChanges = $this->story->batchChangeBranch($storyIdList, $branchID); + $allChanges = $this->story->batchChangeBranch($storyIdList, $branchID, $confirm, $plans); if(dao::isError()) die(js::error(dao::getError())); foreach($allChanges as $storyID => $changes) { diff --git a/module/story/lang/en.php b/module/story/lang/en.php index 9424fb6cdd..e8993a551f 100644 --- a/module/story/lang/en.php +++ b/module/story/lang/en.php @@ -277,6 +277,7 @@ $lang->story->moveChildrenTips = "Its Child {$lang->SRCommon} will be moved $lang->story->changeTips = 'The story associated with the requirements to change, click "Cancel" ignore this change, click "Confirm" to change the story.'; $lang->story->estimateMustBeNumber = 'Estimate value must be number.'; $lang->story->estimateMustBePlus = 'Estimated value cannot be negative'; +$lang->story->confirmChangeBranch = $lang->SRCommon . '%s is linked to the plan of its linked branch. If the branch is edited, ' . $lang->SRCommon . ' will be removed from the plan of its linked branch. Do you want to continue edit ' . $lang->SRCommon . '?'; $lang->story->form = new stdclass(); $lang->story->form->area = 'Scope'; diff --git a/module/story/lang/zh-cn.php b/module/story/lang/zh-cn.php index 1d34df98bd..9c2de764dd 100644 --- a/module/story/lang/zh-cn.php +++ b/module/story/lang/zh-cn.php @@ -277,6 +277,7 @@ $lang->story->moveChildrenTips = "修改父{$lang->SRCommon}的所属产品 $lang->story->changeTips = '该软件需求关联的用户需求有变更,点击“不变更”忽略此条变更,点击“变更”来进行该软件需求的变更。'; $lang->story->estimateMustBeNumber = '估算值必须是数字'; $lang->story->estimateMustBePlus = '估算值不能是负数'; +$lang->story->confirmChangeBranch = $lang->SRCommon . '%s已关联在之前所属分支的计划中,调整分支后,' . $lang->SRCommon . '将从之前所属分支的计划中移除,请确认是否继续修改上述' . $lang->SRCommon . ' 的分支。'; $lang->story->form = new stdclass(); $lang->story->form->area = "该{$lang->SRCommon}所属范围"; diff --git a/module/story/model.php b/module/story/model.php index 186f2642d6..259dac2f26 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1619,6 +1619,7 @@ class storyModel extends model foreach($storyIdList as $storyID) { $oldStory = $oldStories[$storyID]; + if($oldStory->branch != BRANCH_MAIN and $oldStory->branch != $plan->branch and $plan->branch != BRANCH_MAIN) continue; /* Ignore parent story, closed story and story linked to this plan already. */ if($oldStory->parent < 0) continue; @@ -1674,10 +1675,12 @@ class storyModel extends model * * @param array $storyIdList * @param int $branchID + * @param string $confirm + * @param array $plans * @access public * @return void */ - public function batchChangeBranch($storyIdList, $branchID) + public function batchChangeBranch($storyIdList, $branchID, $confirm = '', $plans = array()) { $now = helper::now(); $allChanges = array(); @@ -1692,7 +1695,38 @@ class storyModel extends model $story->branch = $branchID; $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec(); - if(!dao::isError()) $allChanges[$storyID] = common::createChanges($oldStory, $story); + if(!dao::isError()) + { + if($confirm == 'yes') + { + $planIdList = ''; + $conflictPlanIdList = ''; + /* Determine whether there is a conflict between the branch of the story and the linked plan. */ + if($oldStory->branch != $branchID and $branchID != BRANCH_MAIN and isset($plans[$storyID])) + { + foreach($plans[$storyID] as $planID => $plan) + { + if($plan->branch != BRANCH_MAIN and $plan->branch != $branchID) + { + $conflictPlanIdList .= $planID . ','; + } + else + { + $planIdList .= $planID . ','; + } + } + + /* If there is a conflict in the linked plan when the branch story to be modified, the linked with the conflicting plan will be removed. */ + if($conflictPlanIdList) + { + $story->plan = $planIdList; + $this->dao->delete()->from(TABLE_PLANSTORY)->where('story')->eq($storyID)->andWhere('plan')->in($conflictPlanIdList)->exec(); + $this->dao->update(TABLE_STORY)->set('plan')->eq($planIdList)->where('id')->eq($storyID)->exec(); + } + } + } + $allChanges[$storyID] = common::createChanges($oldStory, $story); + } } return $allChanges; } diff --git a/module/story/view/batchedit.html.php b/module/story/view/batchedit.html.php index 5cc967b16b..c6206af93f 100644 --- a/module/story/view/batchedit.html.php +++ b/module/story/view/batchedit.html.php @@ -100,6 +100,7 @@ foreach(explode(',', $showFields) as $field) module, "class='form-control chosen'");?> '> + session->currentProductType != 'normal') $productPlans = $this->productplan->getPairs($productID, $story->branch, '', true);?> plan, "class='form-control chosen'");?> From 1424fbe8694395e899f113a2c93af2891209697c Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 5 Nov 2021 16:04:39 +0800 Subject: [PATCH 3/9] * Modify the error. --- module/branch/control.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/branch/control.php b/module/branch/control.php index 8b57ddb8eb..f9c9c1716a 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -63,6 +63,7 @@ class branch extends control */ public function ajaxGetDropMenu($productID, $branch = 0, $module, $method, $extra = '') { + $branches = $this->branch->getPairs($productID, 'all'); $this->view->link = $this->loadModel('product')->getProductLink($module, $method, $extra, true); $this->view->productID = $productID; $this->view->projectID = $this->session->project; @@ -70,7 +71,7 @@ class branch extends control $this->view->method = $method; $this->view->extra = $extra; - $this->view->branches = $this->branch->getPairs($productID, 'all'); + $this->view->branches = $branches; $this->view->currentBranchID = $branch; $this->view->branchesPinyin = common::convert2Pinyin($branches); $this->display(); From 0328182a4719c277eb5356fffa4cda6289ea1400 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 5 Nov 2021 17:19:41 +0800 Subject: [PATCH 4/9] * Modify the logic of the acquisition plan. --- module/productplan/model.php | 23 ++++++++++++++++++++++- module/story/control.php | 13 ++++++------- module/story/lang/en.php | 2 +- module/story/lang/zh-cn.php | 2 +- module/story/model.php | 4 ++-- module/story/view/batchedit.html.php | 16 +++++++++++++++- 6 files changed, 47 insertions(+), 13 deletions(-) diff --git a/module/productplan/model.php b/module/productplan/model.php index d5fae673f5..8fcbd05056 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -332,10 +332,31 @@ class productplanModel extends model ->leftJoin(TABLE_PLANSTORY)->alias('t2')->on('t1.id=t2.story') ->leftJoin(TABLE_PRODUCTPLAN)->alias('t3')->on('t2.plan=t3.id') ->where('t1.id')->in($storyIdList) - ->andWhere('t3.deleted')->eq(0) ->fetchGroup('storyID', 'id'); } + /** + * Get branch plan pairs. + * + * @param int $productID + * @access public + * @return array + */ + public function getBranchPlanPairs($productID) + { + $plans = $this->dao->select('branch,id,title,begin,end')->from(TABLE_PRODUCTPLAN) + ->where('deleted')->eq(0) + ->andWhere('product')->eq($productID) + ->fetchAll('id'); + + $planPairs = array(); + foreach($plans as $planID => $plan) + { + $planPairs[$plan->branch][$planID] = $plan->title . ' [' . $plan->begin . '~' . $plan->end . ']'; + } + return $planPairs; + } + /** * Create a plan. * diff --git a/module/story/control.php b/module/story/control.php index 481e2fc666..375395a82e 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -706,15 +706,12 @@ class story extends control $product = $this->product->getByID($productID); $branchProduct = $product->type == 'normal' ? false : true; - /* Set modules and productPlans. */ - $modules = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch); - $modules = array('ditto' => $this->lang->story->ditto) + $modules; - $productPlans = $this->productplan->getPairs($productID, $branch, '', true); - $productPlans = array('' => '', 'ditto' => $this->lang->story->ditto) + $productPlans; + /* Set modules. */ + $modules = array('ditto' => $this->lang->story->ditto) + $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch); $this->view->modules = $modules; $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($product->id); - $this->view->productPlans = $productPlans; + $this->view->plans = $this->productplan->getBranchPlanPairs($productID); $this->view->position[] = html::a($this->createLink('product', 'browse', "product=$product->id&branch=$branch"), $product->name); $this->view->title = $product->name . $this->lang->colon . $this->lang->story->batchEdit; } @@ -1393,6 +1390,7 @@ class story extends control $normalStotyIdList = ''; $conflictStoryIdList = ''; $conflictStoryArray = array(); + /* Determine whether there is a conflict between the branch of the story and the linked plan. */ foreach($storyIdList as $storyID) { @@ -1400,10 +1398,11 @@ class story extends control { foreach($plans[$storyID] as $plan) { - if($plan->branch != BRANCH_MAIN and $plan->branch != $branchID and strpos($conflictStoryIdList, '[' . $storyID . ']') === false) + if($plan->branch != BRANCH_MAIN and $plan->branch != $branchID) { $conflictStoryIdList .= '[' . $storyID . ']'; $conflictStoryArray[] = $storyID; + break; } } } diff --git a/module/story/lang/en.php b/module/story/lang/en.php index e8993a551f..75cfdb335c 100644 --- a/module/story/lang/en.php +++ b/module/story/lang/en.php @@ -277,7 +277,7 @@ $lang->story->moveChildrenTips = "Its Child {$lang->SRCommon} will be moved $lang->story->changeTips = 'The story associated with the requirements to change, click "Cancel" ignore this change, click "Confirm" to change the story.'; $lang->story->estimateMustBeNumber = 'Estimate value must be number.'; $lang->story->estimateMustBePlus = 'Estimated value cannot be negative'; -$lang->story->confirmChangeBranch = $lang->SRCommon . '%s is linked to the plan of its linked branch. If the branch is edited, ' . $lang->SRCommon . ' will be removed from the plan of its linked branch. Do you want to continue edit ' . $lang->SRCommon . '?'; +$lang->story->confirmChangeBranch = $lang->SRCommon . ' %s is linked to the plan of its linked branch. If the branch is edited, ' . $lang->SRCommon . ' will be removed from the plan of its linked branch. Do you want to continue edit ' . $lang->SRCommon . '?'; $lang->story->form = new stdclass(); $lang->story->form->area = 'Scope'; diff --git a/module/story/lang/zh-cn.php b/module/story/lang/zh-cn.php index 9c2de764dd..6c485b6e94 100644 --- a/module/story/lang/zh-cn.php +++ b/module/story/lang/zh-cn.php @@ -277,7 +277,7 @@ $lang->story->moveChildrenTips = "修改父{$lang->SRCommon}的所属产品 $lang->story->changeTips = '该软件需求关联的用户需求有变更,点击“不变更”忽略此条变更,点击“变更”来进行该软件需求的变更。'; $lang->story->estimateMustBeNumber = '估算值必须是数字'; $lang->story->estimateMustBePlus = '估算值不能是负数'; -$lang->story->confirmChangeBranch = $lang->SRCommon . '%s已关联在之前所属分支的计划中,调整分支后,' . $lang->SRCommon . '将从之前所属分支的计划中移除,请确认是否继续修改上述' . $lang->SRCommon . ' 的分支。'; +$lang->story->confirmChangeBranch = $lang->SRCommon . '%s已关联在之前所属分支的计划中,调整分支后,' . $lang->SRCommon . '将从之前所属分支的计划中移除,请确认是否继续修改上述' . $lang->SRCommon . '的分支。'; $lang->story->form = new stdclass(); $lang->story->form->area = "该{$lang->SRCommon}所属范围"; diff --git a/module/story/model.php b/module/story/model.php index 259dac2f26..e2e03ccf98 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1678,7 +1678,7 @@ class storyModel extends model * @param string $confirm * @param array $plans * @access public - * @return void + * @return array */ public function batchChangeBranch($storyIdList, $branchID, $confirm = '', $plans = array()) { @@ -1716,7 +1716,7 @@ class storyModel extends model } } - /* If there is a conflict in the linked plan when the branch story to be modified, the linked with the conflicting plan will be removed. */ + /* If there is a conflict in the linked plan when the branch story to be modified, the linked with the conflicting plan will be removed. */ if($conflictPlanIdList) { $story->plan = $planIdList; diff --git a/module/story/view/batchedit.html.php b/module/story/view/batchedit.html.php index c6206af93f..2bc81e2e13 100644 --- a/module/story/view/batchedit.html.php +++ b/module/story/view/batchedit.html.php @@ -100,7 +100,21 @@ foreach(explode(',', $showFields) as $field) module, "class='form-control chosen'");?> '> - session->currentProductType != 'normal') $productPlans = $this->productplan->getPairs($productID, $story->branch, '', true);?> + branch != BRANCH_MAIN) + { + $productPlans = zget($plans, $story->branch) + zget($plans, 0); + } + else + { + foreach($plans as $branchPlan) + { + $productPlans += $branchPlan; + } + } + ?> + session->currentProductType == 'normal') $productPlans = array('' => '', 'ditto' => $this->lang->story->ditto) + $productPlans;?> plan, "class='form-control chosen'");?> From c5779575c1fb99808d1f719474aad250eb3df16c Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 8 Nov 2021 09:29:45 +0800 Subject: [PATCH 5/9] * Modify code logic. --- module/branch/control.php | 12 ++++++------ module/branch/model.php | 5 ++--- module/productplan/control.php | 8 ++++---- module/story/control.php | 4 ++-- module/story/view/batchedit.html.php | 5 +---- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/module/branch/control.php b/module/branch/control.php index f9c9c1716a..03221ca3c4 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -64,13 +64,13 @@ class branch extends control public function ajaxGetDropMenu($productID, $branch = 0, $module, $method, $extra = '') { $branches = $this->branch->getPairs($productID, 'all'); - $this->view->link = $this->loadModel('product')->getProductLink($module, $method, $extra, true); - $this->view->productID = $productID; - $this->view->projectID = $this->session->project; - $this->view->module = $module; - $this->view->method = $method; - $this->view->extra = $extra; + $this->view->link = $this->loadModel('product')->getProductLink($module, $method, $extra, true); + $this->view->productID = $productID; + $this->view->projectID = $this->session->project; + $this->view->module = $module; + $this->view->method = $method; + $this->view->extra = $extra; $this->view->branches = $branches; $this->view->currentBranchID = $branch; $this->view->branchesPinyin = common::convert2Pinyin($branches); diff --git a/module/branch/model.php b/module/branch/model.php index c70accb810..6b2edbb45b 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -40,9 +40,6 @@ class branchModel extends model */ public function getPairs($productID, $params = '') { - $product = $this->loadModel('product')->getById($productID); - if(!$product or $product->type == 'normal') return array(); - $branches = $this->dao->select('*')->from(TABLE_BRANCH) ->where('deleted')->eq(0) ->beginIF($productID)->andWhere('product')->eq($productID)->fi() @@ -52,6 +49,8 @@ class branchModel extends model if(strpos($params, 'noempty') === false) { + $product = $this->loadModel('product')->getById($productID); + if(!$product or $product->type == 'normal') return array(); $branches = array('0' => $this->lang->branch->main) + $branches; } diff --git a/module/productplan/control.php b/module/productplan/control.php index 386266f1fe..68ebf9bbad 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -413,8 +413,8 @@ class productplan extends control else { $this->config->product->search['fields']['branch'] = $this->lang->product->branch; - $branches = array('' => '', '0' => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($plan->product, 'noempty'); - if($plan->branch) $branches = array('' => '', '0' => $this->lang->branch->main, $plan->branch => $branches[$plan->branch]); + $branches = array('' => '', $this->loadModel('branch')->getPairs($plan->product); + if($plan->branch) $branches = array('' => '', $plan->branch => $branches[$plan->branch]); $this->config->product->search['params']['branch']['values'] = $branches; } $this->loadModel('search')->setSearchParams($this->config->product->search); @@ -554,8 +554,8 @@ class productplan extends control else { $this->config->bug->search['fields']['branch'] = $this->lang->product->branch; - $branches = array('' => '', '0' => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($productID, 'noempty'); - if($plan->branch) $branches = array('' => '', '0' => $this->lang->branch->main, $plan->branch => $branches[$plan->branch]); + $branches = array('' => '') + $this->loadModel('branch')->getPairs($productID); + if($plan->branch) $branches = array('' => '', $plan->branch => $branches[$plan->branch]); $this->config->bug->search['params']['branch']['values'] = $branches; } $this->loadModel('search')->setSearchParams($this->config->bug->search); diff --git a/module/story/control.php b/module/story/control.php index 375395a82e..3a406dd2b6 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -306,7 +306,7 @@ class story extends control $this->view->users = $users; $this->view->moduleID = $moduleID ? $moduleID : (int)$this->cookie->lastStoryModule; $this->view->moduleOptionMenu = $moduleOptionMenu; - $this->view->plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch); + $this->view->plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch, true); $this->view->planID = $planID; $this->view->source = $source; $this->view->sourceNote = $sourceNote; @@ -626,7 +626,7 @@ class story extends control $this->view->stories = $stories; $this->view->users = $users; $this->view->product = $product; - $this->view->plans = $this->loadModel('productplan')->getPairsForStory($story->product, $story->branch); + $this->view->plans = $this->loadModel('productplan')->getPairsForStory($story->product, $story->branch, true); $this->view->products = $myProducts + $othersProducts; $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($story->product); $this->view->reviewers = implode(',', $reviewerList); diff --git a/module/story/view/batchedit.html.php b/module/story/view/batchedit.html.php index 2bc81e2e13..fee5c7e5bc 100644 --- a/module/story/view/batchedit.html.php +++ b/module/story/view/batchedit.html.php @@ -108,10 +108,7 @@ foreach(explode(',', $showFields) as $field) } else { - foreach($plans as $branchPlan) - { - $productPlans += $branchPlan; - } + foreach($plans as $branchPlan) $productPlans += $branchPlan; } ?> session->currentProductType == 'normal') $productPlans = array('' => '', 'ditto' => $this->lang->story->ditto) + $productPlans;?> From b18373c7e3a184459e0082a4414673e454261a9c Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Mon, 8 Nov 2021 10:52:14 +0800 Subject: [PATCH 6/9] *Finish task #43908. --- module/my/view/task.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/my/view/task.html.php b/module/my/view/task.html.php index 6bcafdb5f2..c2a31728d7 100644 --- a/module/my/view/task.html.php +++ b/module/my/view/task.html.php @@ -89,7 +89,7 @@ pri;?>' title='task->priList, $task->pri);?>'>task->priList, $task->pri);?> ' title='name?>'> team)) echo '' . $this->lang->task->multipleAB . ' ';?> - parent > 0) echo '' . $this->lang->task->childrenAB . ' ';?> + parent > 0) echo '' . $this->lang->task->parentAB . ' ' . html::a($this->createLink('task', 'view', "taskID=$task->parent", '', '', $task->project),$task->parentName) .'' . $this->lang->task->childrenAB . ' ';?> createLink('task', 'view', "taskID=$task->id", '', '', $task->project), $task->name, null, "style='color: $task->color' data-group='execution'");?> children)) echo '';?> From ea6bcb8b5cb867058c9058756141c93ecd100569 Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Mon, 8 Nov 2021 11:08:56 +0800 Subject: [PATCH 7/9] *Finish task #43908. --- module/my/view/task.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/my/view/task.html.php b/module/my/view/task.html.php index c2a31728d7..ec73646093 100644 --- a/module/my/view/task.html.php +++ b/module/my/view/task.html.php @@ -89,7 +89,7 @@ pri;?>' title='task->priList, $task->pri);?>'>task->priList, $task->pri);?> ' title='name?>'> team)) echo '' . $this->lang->task->multipleAB . ' ';?> - parent > 0) echo '' . $this->lang->task->parentAB . ' ' . html::a($this->createLink('task', 'view', "taskID=$task->parent", '', '', $task->project),$task->parentName) .'' . $this->lang->task->childrenAB . ' ';?> + parent > 0) echo '' . $this->lang->task->childrenAB . ' '.html::a($this->createLink('task', 'view', "taskID=$task->parent", '', '', $task->project),$task->parentName) .'/';?> createLink('task', 'view', "taskID=$task->id", '', '', $task->project), $task->name, null, "style='color: $task->color' data-group='execution'");?> children)) echo '';?> From 26ec2238eec69e290c34ca3fa66246bf38acbf44 Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Mon, 8 Nov 2021 11:31:46 +0800 Subject: [PATCH 8/9] *Finish task #43908. --- module/my/view/task.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/my/view/task.html.php b/module/my/view/task.html.php index ec73646093..f5220cb44a 100644 --- a/module/my/view/task.html.php +++ b/module/my/view/task.html.php @@ -89,7 +89,7 @@ pri;?>' title='task->priList, $task->pri);?>'>task->priList, $task->pri);?> ' title='name?>'> team)) echo '' . $this->lang->task->multipleAB . ' ';?> - parent > 0) echo '' . $this->lang->task->childrenAB . ' '.html::a($this->createLink('task', 'view', "taskID=$task->parent", '', '', $task->project),$task->parentName) .'/';?> + parent > 0) echo '' . $this->lang->task->childrenAB . ' ' . html::a($this->createLink('task', 'view', "taskID=$task->parent", '', '', $task->project), $task->parentName) . ' / ';?> createLink('task', 'view', "taskID=$task->id", '', '', $task->project), $task->name, null, "style='color: $task->color' data-group='execution'");?> children)) echo '';?> From aa116136d03fc4b247bf31e758a7e753934fff88 Mon Sep 17 00:00:00 2001 From: mayue Date: Mon, 8 Nov 2021 13:24:23 +0800 Subject: [PATCH 9/9] * Fix bug #15688. --- module/story/control.php | 11 +++++++++-- module/testcase/control.php | 8 +++++--- module/testcase/js/common.js | 9 +-------- module/testcase/view/create.html.php | 1 - 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/module/story/control.php b/module/story/control.php index d1c890e4ec..a651655914 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -1767,7 +1767,7 @@ class story extends control * @access public * @return void */ - public function ajaxGetProductStories($productID, $branch = 0, $moduleID = 0, $storyID = 0, $onlyOption = 'false', $status = '', $limit = 0, $type = 'full', $hasParent = 1) + public function ajaxGetProductStories($productID, $branch = 0, $moduleID = 0, $storyID = 0, $onlyOption = 'false', $status = '', $limit = 0, $type = 'full', $hasParent = 1, $executionID = 0) { if($moduleID) { @@ -1783,7 +1783,14 @@ class story extends control $storyStatus = array_keys($storyStatus); } - $stories = $this->story->getProductStoryPairs($productID, $branch ? "0,$branch" : $branch, $moduleID, $storyStatus, 'id_desc', $limit, $type, 'story', $hasParent); + if($executionID) + { + $stories = $this->story->getExecutionStoryPairs($executionID, $productID, $branch, $moduleID, $type); + } + else + { + $stories = $this->story->getProductStoryPairs($productID, $branch ? "0,$branch" : $branch, $moduleID, $storyStatus, 'id_desc', $limit, $type, 'story', $hasParent); + } $storyID = isset($stories[$storyID]) ? $storyID : 0; $select = html::select('story', empty($stories) ? array('' => '') : $stories, $storyID, "class='form-control'"); diff --git a/module/testcase/control.php b/module/testcase/control.php index 44f2d07337..0ab81b72c0 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -428,13 +428,15 @@ class testcase extends control if(empty($moduleID)) $moduleID = $story->module; } - $currentModuleID = (int)$moduleID ? (int)$moduleID : (int)$this->cookie->lastCaseModule; + $currentModuleID = $moduleID ? (int)$moduleID : (int)$this->cookie->lastCaseModule; /* Get the status of stories are not closed. */ $storyStatus = $this->lang->story->statusList; unset($storyStatus['closed']); $modules = array(); if($currentModuleID) { + $productModules = $this->tree->getOptionMenu($productID, 'story'); + $currentModuleID = array_key_exists($currentModuleID,$productModules) ? $currentModuleID : 0; $modules = $this->loadModel('tree')->getStoryModule($currentModuleID); $modules = $this->tree->getAllChildID($modules); } @@ -453,11 +455,11 @@ class testcase extends control $this->view->title = $title; $this->view->position = $position; - $this->view->projectID = isset($projectID) ? $projectID : ''; + $this->view->projectID = isset($projectID) ? $projectID : 0; $this->view->productID = $productID; $this->view->productName = $this->products[$productID]; $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0, $branch); - $this->view->currentModuleID = $currentModuleID ? $currentModuleID : (int)$this->cookie->lastCaseModule; + $this->view->currentModuleID = $currentModuleID; $this->view->gobackLink = (isset($output['from']) and $output['from'] == 'global') ? $this->createLink('testcase', 'browse', "productID=$productID") : ''; $this->view->stories = $stories; $this->view->caseTitle = $caseTitle; diff --git a/module/testcase/js/common.js b/module/testcase/js/common.js index 2e3d87bf53..9a0f1ac946 100644 --- a/module/testcase/js/common.js +++ b/module/testcase/js/common.js @@ -124,14 +124,7 @@ function setStories() productID = $('#product').val(); branch = $('#branch').val(); if(typeof(branch) == 'undefined') branch = 0; - if(tab == 'execution') - { - link = createLink('story', 'ajaxGetExecutionStories', 'executionID=' + executionID + '&productID=' + productID + '&branch' + branch + '&moduleID=' + moduleID + '&storyID=0'); - } - else - { - link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=50'); - } + link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=50' + '&executionID' + executionID); $.get(link, function(stories) { diff --git a/module/testcase/view/create.html.php b/module/testcase/view/create.html.php index 632373f46c..1e1a6c5df2 100644 --- a/module/testcase/view/create.html.php +++ b/module/testcase/view/create.html.php @@ -17,7 +17,6 @@ testcase->insertAfter);?> -app->tab);?>