From 227c8642de73cbb48fc531fc80c1b7860ce191bc Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Thu, 1 Apr 2021 11:12:23 +0800 Subject: [PATCH] * Fix product custom whitelist upgrade issue. --- module/execution/control.php | 4 ++-- module/project/control.php | 6 +++++- module/upgrade/model.php | 42 ++++++++++++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 497205d68b..ac3e11f87b 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2572,8 +2572,8 @@ class execution extends control $projects = $this->loadModel('program')->getProjectList(0, 'all', 0, 'order_asc'); $executionGroups = $this->dao->select('*')->from(TABLE_EXECUTION) - ->where('id')->in($this->app->user->view->sprints) - ->andWhere('deleted')->eq(0) + ->where('deleted')->eq(0) + ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi() ->beginIF($this->config->systemMode == 'new')->andWhere('project')->in(array_keys($projects))->fi() ->orderBy('id_desc') ->fetchGroup('project', 'id'); diff --git a/module/project/control.php b/module/project/control.php index e71bd75e0f..260f44e6f8 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -108,7 +108,11 @@ class project extends control public function ajaxGetDropMenu($projectID = 0, $module, $method) { $programs = $this->dao->select('id, name')->from(TABLE_PROGRAM)->where('type')->eq('program')->andWhere('deleted')->eq(0)->orderBy('order_asc')->fetchPairs(); - $projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->in($this->app->user->view->projects)->andWhere('deleted')->eq(0)->orderBy('order_asc')->fetchAll('id'); + $projects = $this->dao->select('*')->from(TABLE_PROJECT) + ->where('deleted')->eq(0) + ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->projects)->fi() + ->orderBy('order_asc') + ->fetchAll('id'); /* Sort project by program. */ $this->loadModel('program'); diff --git a/module/upgrade/model.php b/module/upgrade/model.php index a37a2c9b77..d26020ce0c 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -636,6 +636,7 @@ class upgradeModel extends model $this->saveLogs('Execute 15_0'); $this->execSQL($this->getUpgradeFile('15.0')); $this->adjustWhitelistOfProject(); + $this->adjustWhitelistOfProduct(); $this->appendExec('15_0'); case '15_0_beta1': $this->saveLogs('Execute 15_0_beta1'); @@ -4403,6 +4404,10 @@ class upgradeModel extends model $groups = explode(',', $product->whitelist); $groupAccounts = $this->group->getGroupAccounts($groups); + + /* Get the whitelist data from the classic version mode upgrade. */ + $groupAccounts += $this->dao->select('account')->from(TABLE_ACL)->where('objectID')->eq($product->id)->andWhere('objectType')->eq('product')->andWhere('type')->eq('whitelist')->fetchPairs('account'); + $whiteList += $groupAccounts; $this->personnel->updateWhitelist($groupAccounts, 'product', $product->id, 'whitelist', 'upgrade'); } @@ -4413,10 +4418,12 @@ class upgradeModel extends model { if($sprint->acl != 'private') continue; - $groups = explode(',', $sprint->whitelist); - $groupAccounts = $this->group->getGroupAccounts($groups); + $groups = explode(',', $sprint->whitelist); + $groupAccounts = $this->group->getGroupAccounts($groups); + /* Get the whitelist data from the classic version mode upgrade. */ $groupAccounts += $this->dao->select('account')->from(TABLE_ACL)->where('objectID')->eq($sprint->id)->andWhere('objectType')->eq('sprint')->andWhere('type')->eq('whitelist')->fetchPairs('account'); + $this->personnel->updateWhitelist($groupAccounts, 'sprint', $sprint->id, 'whitelist', 'upgrade'); } } @@ -4723,4 +4730,35 @@ class upgradeModel extends model return true; } + + /** + * Adjust the whitelist of projects. + * + * @access public + * @return bool + */ + public function adjustWhitelistOfProduct() + { + $products = $this->dao->select('*')->from(TABLE_PRODUCT)->where('acl')->eq('custom')->fetchAll(); + foreach($products as $product) + { + $groups = explode(',', $product->whitelist); + $accounts = $this->dao->select('account')->from(TABLE_USERGROUP)->where('`group`')->in($groups)->fetchPairs('account'); + foreach($accounts as $account) + { + $acl = new stdclass(); + $acl->account = $account; + $acl->objectType = 'product'; + $acl->objectID = $product->id; + $acl->type = 'whitelist'; + $acl->source = 'upgrade'; + + $this->dao->insert(TABLE_ACL)->data($acl)->exec(); + } + + $this->dao->update(TABLE_PRODUCT)->set('acl')->eq('private')->where('id')->eq($product->id)->exec(); + } + + return true; + } }