From 619068ea8d75816ae2daf644e618af7f5a978b39 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 17 Aug 2022 15:40:01 +0800 Subject: [PATCH] * Finish task #64967. --- module/common/model.php | 9 ++++++--- module/custom/model.php | 4 ++-- module/story/control.php | 14 +++++++------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/module/common/model.php b/module/common/model.php index bf24324a2e..55143fd5f1 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1646,7 +1646,6 @@ EOD; if(strtolower($module) == 'bug' and strtolower($method) == 'tostory') ($module = 'story') and ($method = 'create'); if(strtolower($module) == 'bug' and strtolower($method) == 'createcase') ($module = 'testcase') and ($method = 'create'); if($config->systemMode == 'classic' and strtolower($module) == 'project') $module = 'execution'; - parse_str($vars, $app->params); if(!commonModel::hasPriv($module, $method, $object)) return false; $link = helper::createLink($module, $method, $vars, '', $onlyBody, $programID); @@ -2443,17 +2442,21 @@ EOD; * * @param string $module * @param string $method + * @param object $object + * @param string $vars * @static * @access public * @return bool */ - public static function hasPriv($module, $method, $object = null) + public static function hasPriv($module, $method, $object = null, $vars = '') { global $app, $lang; $module = strtolower($module); $method = strtolower($method); + parse_str($vars, $params); - if($module == 'story' and isset($app->params['storyType']) and strpos(",story,requirement,", ",{$app->params['storyType']},") !== false) $module = $app->params['storyType']; + if($module == 'story' and !empty($app->params['storyType']) and strpos(",story,requirement,", ",{$app->params['storyType']},") !== false) $module = $app->params['storyType']; + if($module == 'story' and !empty($params['storyType']) and strpos(",story,requirement,", ",{$params['storyType']},") !== false) $module = $params['storyType']; if($module == 'product' and $method == 'browse' and isset($app->params['storyType']) and $app->params['storyType'] == 'requirement') $method = 'requirement'; /* If the user is doing a tutorial, have all tutorial privs. */ diff --git a/module/custom/model.php b/module/custom/model.php index b9cf234041..ea8843e979 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -244,9 +244,9 @@ class customModel extends model { $link = explode('|', $link); list($label, $module, $method) = $link; - if(!empty($link[3])) parse_str($link[3], $app->params); - $hasPriv = commonModel::hasPriv($module, $method); + $params = empty($link[3]) ? '' : $link[3]; + $hasPriv = commonModel::hasPriv($module, $method, null, $params); /* Fix bug #20464 */ if(isset($vars)) unset($vars); diff --git a/module/story/control.php b/module/story/control.php index 9617872b32..8a41535eb0 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -436,12 +436,12 @@ class story extends control * @param int $storyID * @param int $executionID * @param int $plan - * @param string $type requirement|story + * @param string $storyType requirement|story * @param string $extra for example feedbackID=0 * @access public * @return void */ - public function batchCreate($productID = 0, $branch = 0, $moduleID = 0, $storyID = 0, $executionID = 0, $plan = 0, $type = 'story', $extra = '') + public function batchCreate($productID = 0, $branch = 0, $moduleID = 0, $storyID = 0, $executionID = 0, $plan = 0, $storyType = 'story', $extra = '') { /* Set menu. */ if($executionID) @@ -488,7 +488,7 @@ class story extends control if($productID != $this->cookie->preProductID) unset($_SESSION['storyImagesFile']); setcookie('preProductID', $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); - $this->story->replaceURLang($type); + $this->story->replaceURLang($storyType); /* Check can subdivide or not. */ if($storyID) @@ -499,7 +499,7 @@ class story extends control if(!empty($_POST)) { - $mails = $this->story->batchCreate($productID, $branch, $type); + $mails = $this->story->batchCreate($productID, $branch, $storyType); if(dao::isError()) return print(js::error(dao::getError())); $stories = array(); @@ -576,7 +576,7 @@ class story extends control else { setcookie('storyModule', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, false); - $locateLink = $this->session->storyList ? $this->session->storyList : $this->createLink('product', 'browse', "productID=$productID&branch=$branch&browseType=unclosed&queryID=0&type=$type"); + $locateLink = $this->session->storyList ? $this->session->storyList : $this->createLink('product', 'browse', "productID=$productID&branch=$branch&browseType=unclosed&queryID=0&storyType=$storyType"); return print(js::locate($locateLink, 'parent')); } } @@ -653,7 +653,7 @@ class story extends control $showFields = str_replace(array(0 => ",branch,", 1 => ",platform,"), '', ",$showFields,"); $showFields = trim($showFields, ','); } - if($type == 'requirement') + if($storyType == 'requirement') { unset($customFields['plan']); $showFields = str_replace('plan', '', $showFields); @@ -683,7 +683,7 @@ class story extends control $this->view->estimate = $estimate; $this->view->storyTitle = isset($story->title) ? $story->title : ''; $this->view->spec = $spec; - $this->view->type = $type; + $this->view->type = $storyType; $this->view->branch = $branch; $this->view->branches = $branches; /* When the user is product owner or add story in project or not set review, the default is not to review. */