From 8ba7bf968cf185846f7b00a6f4901348f2944238 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Thu, 16 May 2024 11:18:42 +0800 Subject: [PATCH] * Fix bug#47814. --- module/upgrade/model.php | 37 +++++++++++++++++++------------------ module/upgrade/zen.php | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 838f98d04c..f93f71ecfe 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -1408,10 +1408,12 @@ class upgradeModel extends model * * @param string $openVersion * @access public - * @return void + * @return bool */ - public function addORPriv($openVersion = ''): void + public function addORPriv($openVersion = ''): bool { + if(version_compare($openVersion, '18_6', '>=')) return false; + /* Get admin users. */ $admins = $this->dao->select('admins')->from(TABLE_COMPANY)->where('deleted')->eq(0)->fetchPairs(); $admins = explode(',', implode(',', $admins)); @@ -1428,25 +1430,24 @@ class upgradeModel extends model } } - if(version_compare($openVersion, '18_6', '<')) + include('priv.php'); + /* Add or groups. */ + foreach($orData as $role => $name) { - include('priv.php'); - /* Add or groups. */ - foreach($orData as $role => $name) - { - $group = new stdclass(); - $group->vision = 'or'; - $group->name = $name; - $group->role = $role; - $group->desc = $name; - $this->dao->insert(TABLE_GROUP)->data($group)->exec(); - if(dao::isError()) continue; + $group = new stdclass(); + $group->vision = 'or'; + $group->name = $name; + $group->role = $role; + $group->desc = $name; + $this->dao->insert(TABLE_GROUP)->data($group)->exec(); + if(dao::isError()) continue; - $groupID = (string)$this->dao->lastInsertID(); - $sql = 'REPLACE INTO' . TABLE_GROUPPRIV . '(`group`, `module`, `method`) VALUES ' . str_replace('GROUPID', $groupID, ${$role . 'Priv'}); - $this->dao->exec($sql); - } + $groupID = (string)$this->dao->lastInsertID(); + $sql = 'REPLACE INTO' . TABLE_GROUPPRIV . '(`group`, `module`, `method`) VALUES ' . str_replace('GROUPID', $groupID, ${$role . 'Priv'}); + $this->dao->exec($sql); } + + return true; } /** diff --git a/module/upgrade/zen.php b/module/upgrade/zen.php index 41ad10ce51..dd7339888c 100644 --- a/module/upgrade/zen.php +++ b/module/upgrade/zen.php @@ -41,7 +41,7 @@ class upgradeZen extends upgrade /* 如果是 ipd 版本,设置相关的配置。*/ /* When the edition is ipd. */ - if($this->config->edition == 'ipd' && strpos($fromVersion, 'ipd') === false) $this->SetIpdItems(); + if($this->config->edition == 'ipd') $this->SetIpdItems($openVersion); if($selectMode) {