From 57500e21022aed5b6e57463df11311ca35b7193d Mon Sep 17 00:00:00 2001 From: sgm0422 <976204163@qq.com> Date: Wed, 17 Jun 2020 15:08:09 +0800 Subject: [PATCH] * Fix bug and add program admin. --- module/common/model.php | 1 + module/program/model.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/module/common/model.php b/module/common/model.php index 225540dfb5..ae3bacdddb 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1641,6 +1641,7 @@ 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']; if($program->privway == 'extend') $this->app->user->rights['rights'] = array_merge_recursive($programRightGroup, $rights); if($program->privway == 'reset') diff --git a/module/program/model.php b/module/program/model.php index b300815f30..5f620c3303 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -74,6 +74,27 @@ class programModel extends model $this->dao->update(TABLE_PROJECT)->set('`order`')->eq($programID * 5)->where('id')->eq($programID)->exec(); $this->file->updateObjectID($this->post->uid, $programID, 'project'); + /* Add program admin.*/ + $groupPriv = $this->dao->select('t1.*')->from(TABLE_USERGROUP)->alias('t1') + ->leftJoin(TABLE_GROUP)->alias('t2')->on('t1.group = t2.id') + ->where('t1.account')->eq($this->app->user->account) + ->andWhere('t2.role')->eq('pgmadmin') + ->fetch(); + if(!empty($groupPriv)) + { + $newProgram = $groupPriv->program . ",$programID"; + $this->dao->update(TABLE_USERGROUP)->set('program')->eq($newProgram)->where('account')->eq($groupPriv->account)->andWhere('`group`')->eq($groupPriv->group)->exec(); + } + else + { + $pgmAdminID = $this->dao->select('id')->from(TABLE_GROUP)->where('role')->eq('pgmadmin')->fetch('id'); + $groupPriv = new stdclass(); + $groupPriv->account = $this->app->user->account; + $groupPriv->group = $pgmAdminID; + $groupPriv->program = $programID; + $this->dao->insert(TABLE_USERGROUP)->data($groupPriv)->exec(); + } + if($project->template == 'cmmi') { $product = new stdclass();