From 129c7dfd030c85943437de56933bc4fa804006e5 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 28 Sep 2022 09:15:16 +0800 Subject: [PATCH] * Finish task #70015. --- module/my/view/requirement.html.php | 20 ++++++++-- module/my/view/story.html.php | 31 ++++++++++----- module/story/model.php | 59 +++++++++++++++++------------ 3 files changed, 71 insertions(+), 39 deletions(-) diff --git a/module/my/view/requirement.html.php b/module/my/view/requirement.html.php index b80649aea4..d607ca8e1c 100644 --- a/module/my/view/requirement.html.php +++ b/module/my/view/requirement.html.php @@ -116,8 +116,14 @@ echo common::buildIconButton('story', 'recall', "$vars&from=list&storyType=requirement", $story, 'list', 'undo', 'hiddenwin', '', '', '', $lang->story->recall); echo common::buildIconButton('story', 'edit', "$vars&from=default&storyType=requirement", $story, 'list', '', '', 'iframe', true, "data-width='95%'"); - $storyType = 'storyType=requirement'; - if((common::hasPriv('story', 'change', '', $storyType) or (strpos('draft,changing', $story->status) !== false and common::hasPriv('story', 'submitReview', '', $storyType)) or (strpos('active,reviewing,closed', $story->status) !== false and common::hasPriv('story', 'review', '', $storyType)) or common::hasPriv('story', 'recall', '', $storyType) or common::hasPriv('story', 'edit', '', $storyType)) and common::hasPriv('story', 'close', '', $storyType)) + $storyType = 'storyType=requirement'; + $canChange = common::hasPriv('story', 'change', '', $storyType); + $canSubmitReview = (strpos('draft,changing', $story->status) !== false and common::hasPriv('story', 'submitReview', '', $storyType)); + $canReview = (strpos('draft,changing', $story->status) === false and common::hasPriv('story', 'review', '', $storyType)); + $canRecall = common::hasPriv('story', 'recall', '', $storyType); + $canEdit = common::hasPriv('story', 'edit', '', $storyType); + $canClose = common::hasPriv('story', 'close', '', $storyType); + if(($canChange or $canSubmitReview or $canReview or $canRecall or $canEdit) and $canClose) { echo "
"; } @@ -171,8 +177,14 @@ common::printIcon('story', 'recall', "$vars&from=list&storyType=story", $child, 'list', 'undo', 'hiddenwin', '', '', '', $lang->story->recall); common::printIcon('story', 'edit', "$vars&from=default&storyType=story", $child, 'list'); - $storyType = 'storyType=story'; - if((common::hasPriv('story', 'change', '', $storyType) or (strpos('draft,changing', $story->status) !== false and common::hasPriv('story', 'submitReview', '', $storyType)) or (strpos('active,reviewing,closed', $story->status) !== false and common::hasPriv('story', 'review', '', $storyType)) or common::hasPriv('story', 'recall', '', $storyType) or common::hasPriv('story', 'edit', '', $storyType)) and common::hasPriv('story', 'close', '', $storyType)) + $storyType = 'storyType=story'; + $canChange = common::hasPriv('story', 'change', '', $storyType); + $canSubmitReview = (strpos('draft,changing', $child->status) !== false and common::hasPriv('story', 'submitReview', '', $storyType)); + $canReview = (strpos('draft,draft', $child->status) === false and common::hasPriv('story', 'review', '', $storyType)); + $canRecall = common::hasPriv('story', 'recall', '', $storyType); + $canEdit = common::hasPriv('story', 'edit', '', $storyType); + $canClose = common::hasPriv('story', 'close', '', $storyType); + if(($canChange or $canSubmitReview or $canReview or $canRecall or $canEdit) and $canClose) { echo "
"; } diff --git a/module/my/view/story.html.php b/module/my/view/story.html.php index da9019cbdb..933b5ce449 100644 --- a/module/my/view/story.html.php +++ b/module/my/view/story.html.php @@ -50,6 +50,11 @@ $canBatchReview = common::hasPriv('story', 'batchReview'); $canBatchAssignTo = common::hasPriv('story', 'batchAssignTo'); $canBatchAction = ($canBatchEdit or $canBatchClose or $canBatchReview or $canBatchAssignTo); + $canChange = common::hasPriv('story', 'change'); + $canRecall = common::hasPriv('story', 'recall'); + $canEdit = common::hasPriv('story', 'edit'); + $canCreateCase = common::hasPriv('testcase', 'create'); + $canClose = common::hasPriv('story', 'close'); ?> @@ -118,16 +123,18 @@ echo common::buildIconButton('story', 'recall', $vars, $story, 'list', 'undo', 'hiddenwin', '', '', '', $lang->story->recall); echo common::buildIconButton('story', 'edit', $vars, $story, 'list', '', '', 'iframe', true, "data-width='95%'"); - if((common::hasPriv('story', 'change') or (strpos('draft,changing', $story->status) !== false and common::hasPriv('story', 'submitReview')) or (strpos('active,reviewing,closed', $story->status) !== false and common::hasPriv('story', 'review')) or common::hasPriv('story', 'recall') or common::hasPriv('story', 'edit')) and (common::hasPriv('testcase', 'create') or common::hasPriv('story', 'close'))) + $canSubmitReview = (strpos('draft,changing', $story->status) !== false and common::hasPriv('story', 'submitReview')); + $canReview = (strpos('draft,changing', $story->status) === false and common::hasPriv('story', 'review')); + + if(($canChange or $canSubmitReview or $canReview or $canRecall or $canEdit) and ($canCreateCase or $canClose)) { echo "
"; } echo common::buildIconButton('testcase', 'create', "productID=$story->product&branch=$story->branch&module=0&from=¶m=0&$vars", $story, 'list', 'sitemap', '', 'iframe', true, "data-width='95%'"); - if(common::hasPriv('testcase', 'create') and common::hasPriv('story', 'close') ) - { - echo "
"; - } + + if($canCreateCase and $canClose) echo "
"; + echo common::buildIconButton('story', 'close', $vars, $story, 'list', '', '', 'iframe', true); } ?> @@ -176,15 +183,19 @@ } common::printIcon('story', 'recall', $vars, $child, 'list', 'undo', 'hiddenwin', '', '', '', $lang->story->recall); common::printIcon('story', 'edit', $vars, $child, 'list', '', '', 'iframe', true, "data-width='95%'"); - if((common::hasPriv('story', 'change') or (strpos('draft,changing', $story->status) !== false and common::hasPriv('story', 'submitReview')) or (strpos('active,reviewing,closed', $story->status) !== false and common::hasPriv('story', 'review')) or common::hasPriv('story', 'recall') or common::hasPriv('story', 'edit')) and (common::hasPriv('testcase', 'create') or common::hasPriv('story', 'close'))) + + $canSubmitReview = (strpos('draft,changing', $child->status) !== false and common::hasPriv('story', 'submitReview')); + $canReview = (strpos('draft,changing', $child->status) === false and common::hasPriv('story', 'review')); + + if(($canChange or $canSubmitReview or $canReview or $canRecall or $canEdit) and ($canCreateCase or $canClose)) { echo "
"; } + common::printIcon('testcase', 'create', "productID=$child->product&branch=$child->branch&module=0&from=¶m=0&$vars", $child, 'list', 'sitemap', '', 'iframe', true, "data-width='95%'"); - if(common::hasPriv('testcase', 'create') and common::hasPriv('story', 'close') ) - { - echo "
"; - } + + if($canCreateCase and $canClose) echo "
"; + common::printIcon('story', 'close', $vars, $child, 'list', '', '', 'iframe', true); } ?> diff --git a/module/story/model.php b/module/story/model.php index 8b77293863..e22654ccfe 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -4259,10 +4259,21 @@ class storyModel extends model $menu .= $this->buildMenu('story', 'recall', $params . "&from=list&confirm=no&storyType=$story->type", $story, $type, 'undo', 'hiddenwin', 'showinonlybody', false, '', $title); $menu .= $this->buildMenu('story', 'edit', $params . "&kanbanGroup=default&storyType=$story->type", $story, $type, '', '', 'showinonlybody'); - $vars = "storyType={$story->type}"; + + $vars = "storyType={$story->type}"; + $canChange = common::hasPriv('story', 'change', '', $vars); + $canRecall = common::hasPriv('story', 'recall', '', $vars); + $canSubmitReview = (strpos('draft,changing', $story->status) !== false and common::hasPriv('story', 'submitReview', '', $vars)); + $canReview = (strpos('draft,changing', $story->status) === false and common::hasPriv('story', 'review', '', $vars)); + $canEdit = common::hasPriv('story', 'edit', '', $vars); + $canBatchCreate = ($this->app->tab == 'product' and (common::hasPriv('story', 'batchCreate', '', 'storyType=story'))); + $canCreateCase = ($story->type == 'story' and common::hasPriv('testcase', 'create')); + $canClose = common::hasPriv('story', 'close', '', $vars); + $canUnlinkStory = ($this->app->tab == 'project' and common::hasPriv('projectstory', 'unlinkStory')); + if(in_array($this->app->tab, array('product', 'project'))) { - if((common::hasPriv('story', 'change', '', $vars) or common::hasPriv('story', 'recall', '', $vars) or (strpos('draft,changing', $story->status) !== false and common::hasPriv('story', 'submitReview', '', $vars)) or (strpos('active,reviewing,closed', $story->status) !== false and common::hasPriv('story', 'review', '', $vars)) or common::hasPriv('story', 'edit', '', $vars)) and ($this->app->tab == 'product' and (common::hasPriv('story', 'batchCreate', '', 'storyType=story')) or ($story->type == 'story' and common::hasPriv('testcase', 'create')) or common::hasPriv('story', 'close', '', $vars) or ($this->app->tab == 'project' and common::hasPriv('projectstory', 'unlinkStory')))) + if(($canChange or $canRecall or $canSubmitReview or $canReview or $canEdit) and ($canBatchCreate or $canClose or $canUnlinkStory)) { $menu .= "
"; } @@ -4271,10 +4282,7 @@ class storyModel extends model if($this->app->tab == 'product' and $storyType == 'requirement') { $menu .= $this->buildMenu('story', 'close', $params . "&from=&storyType=$story->type", $story, $type, '', '', 'iframe', true); - if(common::hasPriv('story', 'close', '', $vars) and (common::hasPriv('story', 'batchCreate', '', 'storyType=story') or ($story->type == 'story' and common::hasPriv('testcase', 'create')))) - { - $menu .= "
"; - } + if($canClose and ($canBatchCreate or $canCreateCase)) $menu .= "
"; } if($storyType == 'requirement') $menu .= $this->buildMenu('story', 'batchCreate', "productID=$story->product&branch=$story->branch&module=$story->module&$params&executionID=0&plan=0&storyType=story", $story, $type, 'split', '', 'showinonlybody', '', '', $title); @@ -4304,20 +4312,15 @@ class storyModel extends model if($this->app->rawModule == 'projectstory' and $this->config->vision != 'lite') { - if(common::hasPriv('testcase', 'create') and (common::hasPriv('story', 'close') or common::hasPriv('projectstory', 'unlinkStory'))) - { - $menu .= "
"; - } + if($canCreateCase and ($canClose or $canUnlinkStory)) $menu .= "
"; + $menu .= $this->buildMenu('story', 'close', $params . "&from=&storyType=$story->type", $story, $type, '', '', 'iframe', true); $menu .= $this->buildMenu('projectstory', 'unlinkStory', "projectID={$this->session->project}&$params", $story, $type, 'unlink', 'hiddenwin', 'showinonlybody'); } if($this->app->tab == 'product' and $storyType == 'story') { - if((common::hasPriv('story', 'batchCreate') or common::hasPriv('testcase', 'create')) and common::hasPriv('story', 'close')) - { - $menu .= "
"; - } + if(($canBatchCreate or $canCreateCase) and $canClose) $menu .= "
"; $menu .= $this->buildMenu('story', 'close', $params . "&from=&storyType=$story->type", $story, $type, '', '', 'iframe', true); } @@ -4396,13 +4399,22 @@ class storyModel extends model $story->reviewer = isset($story->reviewer) ? $story->reviewer : array(); $story->notReview = isset($story->notReview) ? $story->notReview : array(); + $canSubmitReview = (strpos('draft,changing', $story->status) !== false and common::hasPriv('story', 'submitReview')); + $canReview = (strpos('draft,changing', $story->status) === false and common::hasPriv('story', 'review')); + $canRecall = common::hasPriv('story', 'recall'); + $canCreateTask = common::hasPriv('task', 'create'); + $canBatchCreateTask = common::hasPriv('task', 'batchCreate'); + $canCreateCase = ($hasDBPriv and common::hasPriv('testcase', 'create')); + $canEstimate = common::hasPriv('execution', 'storyEstimate', $execution); + $canUnlinkStory = common::hasPriv('execution', 'unlinkStory', $execution); + if(strpos('draft,changing', $story->status) !== false) { - if(common::hasPriv('story', 'submitReview')) $menu .= common::printIcon('story', 'submitReview', "storyID=$story->id&from=story", $story, 'list', 'confirm', '', 'iframe', true, "data-width='50%'"); + if($canSubmitReview) $menu .= common::printIcon('story', 'submitReview', "storyID=$story->id&from=story", $story, 'list', 'confirm', '', 'iframe', true, "data-width='50%'"); } else { - if(common::hasPriv('story', 'review')) + if($canReview) { $reviewDisabled = in_array($this->app->user->account, $story->notReview) and ($story->status == 'draft' or $story->status == 'changing') ? '' : 'disabled'; $story->from = 'execution'; @@ -4410,7 +4422,7 @@ class storyModel extends model } } - if(common::hasPriv('story', 'recall')) + if($canRecall) { $recallDisabled = empty($story->reviewedBy) and strpos('draft,changing', $story->status) !== false and !empty($story->reviewer) ? '' : 'disabled'; $title = $story->status == 'changing' ? $this->lang->story->recallChange : $this->lang->story->recall; @@ -4432,28 +4444,25 @@ class storyModel extends model $this->lang->task->batchCreate = $this->lang->execution->batchWBS; if($hasDBPriv) $menu .= common::printIcon('task', 'batchCreate', "executionID=$executionID&story={$story->id}", '', 'list', 'pluses', '', $toTaskDisabled); - if(((strpos('draft,changing', $story->status) !== false and common::hasPriv('story', 'submitReview')) or (strpos('active,reviewing,closed', $story->status) !== false and common::hasPriv('story', 'review')) or common::hasPriv('story', 'recall') or common::hasPriv('task', 'create') or common::hasPriv('task', 'batchCreate')) and (($hasDBPriv and common::hasPriv('testcase', 'create')) or common::hasPriv('execution', 'storyEstimate', $execution) or common::hasPriv('execution', 'unlinkStory', $execution) or common::hasPriv('execution', 'unlinkStory', $execution))) + if(($canSubmitReview or $canReview or $canRecall or $canCreateTask or $canBatchCreateTask) and ($canCreateCase or $canEstimate or $canUnlinkStory)) { $menu .= "
"; } - if(common::hasPriv('execution', 'storyEstimate', $execution)) + if($canEstimate) { $menu .= common::buildIconButton('execution', 'storyEstimate', "executionID=$executionID&storyID=$story->id", '', 'list', 'estimate', '', 'iframe', true, "data-width='470px'"); } $this->lang->testcase->batchCreate = $this->lang->testcase->create; - if($hasDBPriv and common::hasPriv('testcase', 'create')) + if($canCreateCase) { $menu .= common::buildIconButton('testcase', 'create', "productID=$story->product&branch=$story->branch&moduleID=$story->module&form=¶m=0&storyID=$story->id", '', 'list', 'sitemap', '', '', '', "data-app='qa'"); } - if((common::hasPriv('execution', 'storyEstimate', $execution) or ($hasDBPriv and common::hasPriv('testcase', 'create'))) and common::hasPriv('execution', 'unlinkStory', $execution)) - { - $menu .= "
"; - } + if(($canEstimate or $canCreateCase) and $canUnlinkStory) $menu .= "
"; - if(common::hasPriv('execution', 'unlinkStory', $execution)) + if($canUnlinkStory) { $menu .= common::buildIconButton('execution', 'unlinkStory', "executionID=$executionID&storyID=$story->id&confirm=no", '', 'list', 'unlink', 'hiddenwin'); }