From 9adee22ad52c169627ab8948a6f8d2aa785e8f71 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Fri, 5 May 2023 15:45:02 +0800 Subject: [PATCH] * Modify function name. --- module/common/model.php | 2 +- module/project/control.php | 2 +- module/project/model.php | 22 ++++++++++++---------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/module/common/model.php b/module/common/model.php index 79e9211411..0f5a3d03ce 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -2658,7 +2658,7 @@ EOF; if($program->auth == 'reset') { /* If priv way is reset, unset common program priv, and cover by program priv. */ - $projectPrivs = $this->loadModel('project')->processProjectPrivs($program->multiple ? $program->model : 'noSprint'); + $projectPrivs = $this->loadModel('project')->getProjectPrivs($program->multiple ? $program->model : 'noSprint'); foreach($projectPrivs as $module => $methods) { foreach($methods as $method => $label) diff --git a/module/project/control.php b/module/project/control.php index edd4959eda..ab4c869213 100755 --- a/module/project/control.php +++ b/module/project/control.php @@ -1453,7 +1453,7 @@ class project extends control } $this->view->project = $project; - $this->lang->resource = $this->project->processProjectPrivs($project->multiple ? $project->model : 'noSprint'); + $this->lang->resource = $this->project->getProjectPrivs($project->multiple ? $project->model : 'noSprint'); } $this->display(); diff --git a/module/project/model.php b/module/project/model.php index d15ed0115b..6e8ae5065d 100755 --- a/module/project/model.php +++ b/module/project/model.php @@ -116,7 +116,7 @@ class projectModel extends model } } - setcookie('lastProject', (int)$this->session->project, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); + setcookie('lastProject', (string)$this->session->project, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); return $this->session->project; } @@ -893,23 +893,25 @@ class projectModel extends model } /** - * Process the project privs according to the project model. + * 根据项目类型生成权限数据。 + * Get project priv data according to the project type. * - * @param string $model sprint | waterfall | noSprint + * @param string $model scrum|waterfall|noSprint|agileplus|waterfallplus * @access public - * @return object + * @return object|false */ - public function processProjectPrivs($model = 'waterfall') + public function getProjectPrivs(string $model = 'waterfall'): object|false { + if(!in_array($model, array_keys((array)$this->config->programPriv))) return false; + if($model == 'noSprint') $this->config->project->includedPriv = $this->config->project->noSprintPriv; $this->app->loadLang('group'); - - $privs = new stdclass(); - $resource = $this->lang->resource; - foreach($resource as $module => $methods) + $privs = new stdclass(); + foreach($this->lang->resource as $module => $methods) { - if(!$methods) continue; + if(empty($methods)) continue; + if(!in_array($module, $this->config->programPriv->$model)) continue; foreach($methods as $method => $label)