From f6904dc8ab90d9e9bf3d32ab14a7bafcddc3c594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Mon, 9 Aug 2021 17:04:12 +0800 Subject: [PATCH] * adjust for updatewhitelist when increase. --- module/personnel/model.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/module/personnel/model.php b/module/personnel/model.php index 029c6bcd7a..8a1209d183 100644 --- a/module/personnel/model.php +++ b/module/personnel/model.php @@ -473,6 +473,7 @@ class personnelModel extends model ->where('t1.objectID')->eq($objectID) ->andWhere('t1.type')->eq('whitelist') ->andWhere('t1.objectType')->eq($objectType) + ->andWhere('t2.realname')->ne('') ->orderBy($orderBy) ->beginIF(!empty($pager))->page($pager)->fi() ->fetchAll(); @@ -488,7 +489,7 @@ class personnelModel extends model */ public function getWhitelistAccount($objectID = 0, $objectType = '') { - return $this->dao->select('account')->from(TABLE_ACL)->where('objectID')->eq($objectID)->andWhere('objectType')->eq($objectType)->fetchPairs('account'); + return $this->dao->select('account')->from(TABLE_ACL)->where('objectID')->eq($objectID)->andWhere('objectType')->eq($objectType)->fetchPairs('account', 'account'); } /** @@ -536,8 +537,18 @@ class personnelModel extends model if($updateType == 'increase') { $oldWhitelist = $this->dao->select('whitelist')->from($objectTable)->where('id')->eq($objectID)->fetch('whitelist'); - $oldWhitelist = explode(',', $oldWhitelist); - $accounts = array_unique(array_merge($accounts, $oldWhitelist)); + + $groups = $this->dao->select('id')->from(TABLE_GROUP)->where('id')->in($oldWhitelist)->fetchPairs('id', 'id'); + if($groups) + { + $oldWhitelist = $this->dao->select('account')->from(TABLE_GROUPPRIV)->where('`group`')->in($groups)->fetchPairs('account', 'account'); + if($oldWhitelist) $accounts = array_unique(array_merge($accounts, $oldWhitelist)); + } + else + { + $oldWhitelist = $this->dao->select('account')->from(TABLE_USER)->where('account')->in($oldWhitelist)->fetchPairs('account', 'account'); + if($oldWhitelist) $accounts = array_unique(array_merge($accounts, $oldWhitelist)); + } } $whitelist = ',' . implode(',', $accounts); $this->dao->update($objectTable)->set('whitelist')->eq($whitelist)->where('id')->eq($objectID)->exec();