From c5779575c1fb99808d1f719474aad250eb3df16c Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 8 Nov 2021 09:29:45 +0800 Subject: [PATCH] * 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;?>