From f0d405aebf8facff2cbf413ec37fccadd690005c Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 12 Apr 2023 14:04:15 +0800 Subject: [PATCH] * Fix bug #34076. --- module/doc/model.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/module/doc/model.php b/module/doc/model.php index 5edf6bda76..f4a852905e 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1263,6 +1263,8 @@ class docModel extends model */ public function checkPrivLib($object, $extra = '') { + if(empty($object)) return false; + if($this->app->user->admin and $object->type != 'mine') return true; if($object->acl == 'open') return true; @@ -1320,18 +1322,10 @@ class docModel extends model */ public function checkPrivDoc($object) { - $libType = $this->dao->select('type')->from(TABLE_DOCLIB)->where('id')->eq($object->lib)->fetch('type'); - if($this->app->user->admin and $libType != 'mine') return true; + $lib = $this->getLibById($object->lib); + if($this->app->user->admin and $lib->type != 'mine') return true; - static $extraDocLibs; - if($extraDocLibs === null) $extraDocLibs = $this->getPrivLibsByDoc(); - - static $libs; - if($libs === null) $libs = $this->getLibs('all'); - if(isset($libs[$object->lib]) and isset($extraDocLibs[$object->lib])) unset($extraDocLibs[$object->lib]); - - if($object->acl == 'open' and !isset($extraDocLibs[$object->lib]) and isset($libs[$object->lib])) return true; - if($object->acl == 'public' and !isset($extraDocLibs[$object->lib]) and isset($libs[$object->lib])) return true; + if(in_array($object->acl, array('open', 'public')) and $this->checkPrivLib($lib)) return true; $account = ",{$this->app->user->account},"; if(isset($object->addedBy) and $object->addedBy == $this->app->user->account) return true;