* finish task #42846.
This commit is contained in:
+22
-20
@@ -1904,18 +1904,6 @@ EOD;
|
||||
if(isset($this->app->user))
|
||||
{
|
||||
$this->app->user = $this->session->user;
|
||||
|
||||
$inProject = (isset($this->lang->navGroup->$module) && $this->lang->navGroup->$module == 'project');
|
||||
if(!defined('IN_UPGRADE') and $inProject)
|
||||
{
|
||||
/* Check program priv. */
|
||||
$viewProjects = trim($this->app->user->view->projects, ',');
|
||||
$accessDenied = ($this->session->project and $viewProjects and strpos(",{$viewProjects},", ",{$this->session->project},") === false);
|
||||
if($accessDenied and !$this->app->user->admin) $this->loadModel('project')->accessDenied();
|
||||
$this->resetProgramPriv($module, $method);
|
||||
if(!commonModel::hasPriv($module, $method)) $this->deny($module, $method, false);
|
||||
}
|
||||
|
||||
if(!commonModel::hasPriv($module, $method)) $this->deny($module, $method);
|
||||
}
|
||||
else
|
||||
@@ -1986,18 +1974,17 @@ EOD;
|
||||
/**
|
||||
* Reset program priv.
|
||||
*
|
||||
* @param string $module
|
||||
* @param string $method
|
||||
* @static
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function resetProgramPriv($module, $method)
|
||||
public function resetProgramPriv($projectID = 0)
|
||||
{
|
||||
/* Get user program priv. */
|
||||
if(!$this->app->session->project) return;
|
||||
if(empty($projectID) and $this->session->project) $projectID = $this->session->project;
|
||||
if(empty($projectID)) return;
|
||||
|
||||
$program = $this->dao->findByID($this->app->session->project)->from(TABLE_PROJECT)->fetch();
|
||||
$program = $this->dao->findByID($projectID)->from(TABLE_PROJECT)->fetch();
|
||||
if(empty($program)) return;
|
||||
|
||||
$programRights = $this->dao->select('t3.module, t3.method')->from(TABLE_GROUP)->alias('t1')
|
||||
@@ -2013,18 +2000,33 @@ EOD;
|
||||
foreach($programRights as $programRight) $programRightGroup[$programRight->module][$programRight->method] = 1;
|
||||
|
||||
/* Reset priv by program privway. */
|
||||
$this->app->user->rights = $this->loadModel('user')->authorize($this->app->user->account);
|
||||
$rights = $this->app->user->rights['rights'];
|
||||
$this->app->user = clone $_SESSION['user'];
|
||||
if($projectID == '1649')
|
||||
{
|
||||
a($_SESSION['user']->rights['rights']['project']);
|
||||
}
|
||||
|
||||
if($program->auth == 'extend') $this->app->user->rights['rights'] = array_merge_recursive($programRightGroup, $rights);
|
||||
if($program->auth == 'reset')
|
||||
{
|
||||
$recomputedRights = $this->loadModel('user')->authorize($this->app->user->account);
|
||||
$recomputedRights = $recomputedRights['rights'];
|
||||
|
||||
/* If priv way is reset, unset common program priv, and cover by program priv. */
|
||||
foreach($rights as $moduleKey => $methods)
|
||||
{
|
||||
if(in_array($moduleKey, $this->config->programPriv->waterfall)) unset($rights[$moduleKey]);
|
||||
}
|
||||
|
||||
$this->app->user->rights['rights'] = array_merge($rights, $programRightGroup);
|
||||
$recomputedRights = array_merge($rights, $programRightGroup);
|
||||
|
||||
/* Set base priv for project. */
|
||||
if(isset($this->app->user->rights['rights']['project']['browse']) and !isset($recomputedRights['project']['browse'])) $recomputedRights['project']['browse'] = 1;
|
||||
if(isset($this->app->user->rights['rights']['project']['kanban']) and !isset($recomputedRights['project']['kanban'])) $recomputedRights['project']['kanban'] = 1;
|
||||
if(isset($this->app->user->rights['rights']['project']['index']) and !isset($recomputedRights['project']['index'])) $recomputedRights['project']['index'] = 1;
|
||||
|
||||
$this->app->user->rights['rights'] = $recomputedRights;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,8 @@ class compileModel extends model
|
||||
$this->dao->update(TABLE_COMPILE)->set('tag')->eq($lastTag)->where('id')->eq($compile->id)->exec();
|
||||
}
|
||||
|
||||
if($job->engine == 'gitlab') $compile = $this->loadModel('job')->execGitlabPipeline($job, $compileID);
|
||||
$this->loadModel('job');
|
||||
if($job->engine == 'gitlab') $compile = $this->job->execGitlabPipeline($job, $compileID);
|
||||
if($job->engine == 'jenkins') $compile = $this->job->execJenkinsPipeline($job, $repo, $compile->id);
|
||||
|
||||
$this->dao->update(TABLE_COMPILE)->data($compile)->where('id')->eq($compileID)->exec();
|
||||
|
||||
@@ -126,6 +126,12 @@ class projectModel extends model
|
||||
if($projectID && strpos(",{$this->app->user->view->projects},", ",{$this->session->project},") === false) $this->accessDenied();
|
||||
}
|
||||
|
||||
/* Reset program priv. */
|
||||
$moduleName = $this->app->getModuleName();
|
||||
$methodName = $this->app->getMethodName();
|
||||
$this->loadModel('common')->resetProgramPriv($this->session->project);
|
||||
if(!commonModel::hasPriv($moduleName, $methodName)) $this->common->deny($moduleName, $methodName, false);
|
||||
|
||||
return $this->session->project;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user