From 0fba3427afc991bdbd0c09a9362fe71edf4faef0 Mon Sep 17 00:00:00 2001 From: daitingting Date: Wed, 11 May 2022 01:39:53 +0000 Subject: [PATCH] * Build operate menu for productplan module. --- framework/control.class.php | 2 +- module/productplan/model.php | 101 +++++++++++++++++- module/productplan/view/browsebylist.html.php | 62 +---------- module/productplan/view/view.html.php | 26 +---- 4 files changed, 102 insertions(+), 89 deletions(-) diff --git a/framework/control.class.php b/framework/control.class.php index 3677e1e7dc..326c9f9c20 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -326,7 +326,7 @@ class control extends baseControl if(!isset($this->config->bizVersion)) return false; $moduleName = $this->moduleName; - if(strpos(',bug,feedback,caselib,testsuite,testtask,testcase,product,', ",{$moduleName},") !== false) return $this->$moduleName->buildOperateMenu($object, $type); + if(strpos(',bug,feedback,caselib,testsuite,testtask,testcase,product,productplan,', ",{$moduleName},") !== false) return $this->$moduleName->buildOperateMenu($object, $type); $flow = $this->loadModel('workflow')->getByModule($moduleName); return $this->loadModel('flow')->buildOperateMenu($flow, $object, $type); diff --git a/module/productplan/model.php b/module/productplan/model.php index ad2d763bec..d388bce67f 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -1002,17 +1002,21 @@ class productplanModel extends model * * @param object $plan * @param string $action + * @param string $module * @access public * @return void */ - public static function isClickable($plan, $action) + public static function isClickable($plan, $action, $module = 'productplan') { $action = strtolower($action); - $clickable = commonModel::hasPriv('productplan', $action); + $clickable = commonModel::hasPriv($module, $action); if(!$clickable) return false; switch($action) { + case 'create' : + if($plan->parent > 0 or strpos('done,closed', $plan->status) !== false) return false; + break; case 'start' : if($plan->status != 'wait' or $plan->parent < 0) return false; break; @@ -1025,8 +1029,101 @@ class productplanModel extends model case 'activate' : if($plan->status == 'wait' or $plan->status == 'doing' or $plan->parent < 0) return false; break; + case 'delete' : + if($plan->parent < 0) return false; + break; + } + + if($module == 'execution' && $action == 'create') + { + if($plan->parent < 0 || $plan->expired || in_array($plan->status, array('done', 'closed'))) return false; + + $product = $this->loadModel('product')->getById($plan->product); + $branchList = $this->loadModel('branch')->getList($plan->product, 0, 'all'); + + $branchStatusList = array(); + foreach($branchList as $productBranch) $branchStatusList[$productBranch->id] = $productBranch->status; + + if($product->type != 'normal') + { + $branchStatus = isset($branchStatusList[$plan->branch]) ? $branchStatusList[$plan->branch] : ''; + if($branchStatus == 'closed') return false; + } } return true; } + + /** + * Build operate menu. + * + * @param object $plan + * @param string $type + * @access public + * @return string + */ + public function buildOperateMenu($plan, $type = 'view') + { + $params = "planID=$plan->id"; + + $menu = ''; + $menu .= $this->buildMenu('productplan', 'start', $params, $plan, $type, 'play', 'hiddenwin', '', false, '', $this->lang->productplan->startAB); + $menu .= $this->buildMenu('productplan', 'finish', $params, $plan, $type, 'checked', 'hiddenwin', '', false, '', $this->lang->productplan->finishAB); + $menu .= $this->buildMenu('productplan', 'close', $params, $plan, $type, 'off', 'hiddenwin', 'iframe', true, '', $this->lang->productplan->closeAB); + + if($type == 'view') $menu .= $this->buildMenu('productplan', 'activate', $params, $plan, $type, 'magic', 'hiddenwin', '', false, '', $this->lang->productplan->activateAB); + + if($type == 'browse') + { + if($this->isClickable($plan, 'create', 'execution')) + { + $executionLink = $this->config->systemMode == 'new' ? '#projects' : helper::createLink('execution', 'create', "projectID=0&executionID=0©ExecutionID=0&plan=$plan->id&confirm=no&productID=$plan->product"); + if($this->config->systemMode == 'new') + { + $menu .= html::a($executionLink, '', '', "data-toggle='modal' data-id='$plan->id' onclick='getPlanID(this, $plan->branch)' class='btn' title='{$this->lang->productplan->createExecution}'"); + } + else + { + $menu .= html::a($executionLink, '', '', "class='btn' title='{$this->lang->productplan->createExecution}'"); + } + } + else + { + $menu .= ""; + } + + if(common::hasPriv('productplan', 'linkStory', $plan) and $plan->parent >= 0) + { + $menu .= $this->buildMenu('productplan', 'view', "{$params}&type=story&orderBy=id_desc&link=true", $plan, $type, 'link', '', '', '', '', $this->lang->productplan->linkStory); + } + else + { + $menu .= ""; + } + + if(common::hasPriv('productplan', 'linkBug', $plan) and $plan->parent >= 0) + { + $menu .= $this->buildMenu('productplan', 'view', "{$params}&type=bug&orderBy=id_desc&link=true", $plan, $type, 'bug', '', '', '', '', $this->lang->productplan->linkBug); + } + else + { + $menu .= ""; + } + + $menu .= $this->buildMenu('productplan', 'edit', $params, $plan, $type); + } + + $menu .= $this->buildMenu('productplan', 'create', "product={$plan->product}&branch={$plan->branch}&parent={$plan->id}", $plan, $type, 'split', '', '', '', '', $this->lang->productplan->children); + + if($type == 'browse') $menu .= $this->buildMenu('productplan', 'delete', "{$params}&confirm=no", $plan, $type, 'trash', 'hiddenwin', '', '', $this->lang->productplan->delete); + + if($type == 'view') + { + if(common::hasPriv('productplan', 'edit', $plan)) $menu .= html::a(helper::createLink('productplan', 'edit', $params), " " . $this->lang->edit, '', "class='btn btn-link' title='{$this->lang->edit}'"); + if($plan->parent >= 0 && common::hasPriv('productplan', 'delete', $plan)) $menu .= html::a(helper::createLink('productplan', 'delete', $params), " " . $this->lang->delete, '', "class='btn btn-link' title='{$this->lang->delete}' target='hiddenwin'"); + } + + + return $menu; + } } diff --git a/module/productplan/view/browsebylist.html.php b/module/productplan/view/browsebylist.html.php index 776abaaf9a..db0c2e0b73 100644 --- a/module/productplan/view/browsebylist.html.php +++ b/module/productplan/view/browsebylist.html.php @@ -144,67 +144,7 @@
" . $this->loadModel('flow')->getFieldValue($extendField, $plan) . "";?> - - parent >= 0 ) - { - $attr = "target='hiddenwin'"; - common::printIcon('productplan', 'start', "planID=$plan->id", $plan, 'list', 'play', '', '', false, $attr); - common::printIcon('productplan', 'finish', "planID=$plan->id", $plan, 'list', 'checked', '', '', false, $attr); - common::printIcon('productplan', 'close', "planID=$plan->id", $plan, 'list', 'off', '', 'iframe', true); - } - - $attr = $plan->expired ? "disabled='disabled'" : ''; - $class = ''; - if($product->type != 'normal') - { - $branchStatus = isset($branchStatusList[$plan->branch]) ? $branchStatusList[$plan->branch] : ''; - if($branchStatus == 'closed') $class = 'disabled'; - } - if(common::hasPriv('execution', 'create', $plan) and $plan->parent >= 0) - { - $disabled = ''; - $executionLink = $config->systemMode == 'new' ? '#projects' : $this->createLink('execution', 'create', "projectID=0&executionID=0©ExecutionID=0&plan=$plan->id&confirm=no&productID=$productID"); - - if(in_array($plan->status, array('done', 'closed'))) $disabled = 'disabled'; - - if($config->systemMode == 'new') - { - echo html::a($executionLink, '', '', "data-toggle='modal' data-id='$plan->id' onclick='getPlanID(this, $plan->branch)' class='btn {$disabled} {$class}' title='{$lang->productplan->createExecution}' $attr"); - } - else - { - echo html::a($executionLink, '', '', "class='btn {$disabled}' title='{$lang->productplan->createExecution}' $attr"); - } - } - if(common::hasPriv('productplan', 'linkStory', $plan) and $plan->parent >= 0) echo html::a(inlink('view', "planID=$plan->id&type=story&orderBy=id_desc&link=true"), '', '', "class='btn' title='{$lang->productplan->linkStory}'"); - if(common::hasPriv('productplan', 'linkBug', $plan) and $plan->parent >= 0) echo html::a(inlink('view', "planID=$plan->id&type=bug&orderBy=id_desc&link=true"), '', '', "class='btn' title='{$lang->productplan->linkBug}'"); - common::printIcon('productplan', 'edit', "planID=$plan->id", $plan, 'list'); - if(common::hasPriv('productplan', 'create', $plan)) - { - if($plan->parent > 0 or strpos('done,closed', $plan->status) !== false) - { - echo " "; - } - else - { - echo html::a($this->createLink('productplan', 'create', "product=$productID&branch=$branch&parent={$plan->id}"), "", '', "class='btn {$class}' title='{$this->lang->productplan->children}'"); - } - } - - if(common::hasPriv('productplan', 'delete', $plan)) - { - $deleteURL = '###'; - $disabled = 'disabled'; - if($plan->parent >= 0) - { - $deleteURL = $this->createLink('productplan', 'delete', "planID=$plan->id&confirm=no"); - $disabled = ''; - } - echo html::a($deleteURL, '', 'hiddenwin', "class='btn {$disabled}' title='{$lang->productplan->delete}'"); - } - ?> - + buildOperateMenu($plan, 'browse'); ?> diff --git a/module/productplan/view/view.html.php b/module/productplan/view/view.html.php index 0ffd20a298..cff6af86a6 100644 --- a/module/productplan/view/view.html.php +++ b/module/productplan/view/view.html.php @@ -38,31 +38,7 @@
- deleted && !isonlybody()) - { - echo $this->buildOperateMenu($plan, 'view'); - - if($plan->parent >= 0) - { - $attr = "target='hiddenwin'"; - $class = $plan->status == 'wait' ? '' : 'disabled'; - - common::printLink('productplan', 'start', "planID=$plan->id", "{$lang->productplan->startAB}", '', "class='btn btn-link {$class}'{$attr} title='{$lang->productplan->start}'", '', false, $plan); - $class = $plan->status == 'doing' ? '' : 'disabled'; - common::printLink('productplan', 'finish', "planID=$plan->id", "{$lang->productplan->finishAB}", '', "class='btn btn-link {$class}' target='hiddenwin' title='{$lang->productplan->finish}'", '', false, $plan); - $class = $plan->status !== 'closed' ? 'iframe' : 'disabled'; - common::printLink('productplan', 'close', "planID=$plan->id", "{$lang->productplan->closeAB}", '', "class='btn btn-link {$class}' title='{$lang->productplan->close}'", '', true, $plan); - $class = in_array($plan->status, array('closed', 'done')) ? '' : 'disabled'; - common::printLink('productplan', 'activate', "planID=$plan->id", "{$lang->productplan->activateAB}", '', "class='btn btn-link {$class}' target='hiddenwin' title='{$lang->productplan->activate}'", '', false, $plan); - } - - $class = (isset($branchStatus) and $branchStatus == 'closed') ? 'disabled' : ''; - if(common::hasPriv('productplan', 'create', $plan) and $plan->parent <= 0 and strpos('wait,doing', $plan->status) !== false) echo html::a($this->createLink('productplan', 'create', "product={$plan->product}&branch={$plan->branch}&parent={$plan->id}"), " " . $this->lang->productplan->children , '', "class='btn btn-link {$class}' title='{$this->lang->productplan->children}'"); - if(common::hasPriv('productplan', 'edit', $plan)) echo html::a($this->createLink('productplan', 'edit', "planID=$plan->id"), " " . $this->lang->edit, '', "class='btn btn-link' title='{$this->lang->edit}'"); - if(common::hasPriv('productplan', 'delete', $plan) and $plan->parent >= 0) echo html::a($this->createLink('productplan', 'delete', "planID=$plan->id"), " " . $this->lang->delete, '', "class='btn btn-link' title='{$this->lang->delete}' target='hiddenwin'"); - } - ?> + deleted && !isonlybody()) echo $this->buildOperateMenu($plan, 'view'); ?>