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) . "";?> -