From 9786a5182225caa7812dc28311d15cc87778fa9c Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 12 Apr 2016 07:44:48 +0200 Subject: [PATCH] add variable noReadForStatus, method getLoggedInUser setting noReadForStatus will allow to check if a version may be accessible in its status --- SeedDMS_Core/Core/inc.ClassDMS.php | 38 ++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 92b57866c..d7f59a120 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -146,6 +146,13 @@ class SeedDMS_Core_DMS { */ public $viewOnlineFileTypes; + /** + * @var array $noReadForStatus list of status without read right + * online + * @access public + */ + public $noReadForStatus; + /** * @var string $version version of pear package * @access public @@ -231,6 +238,12 @@ class SeedDMS_Core_DMS { /** * Filter objects out which are not accessible in a given mode by a user. * + * This function can be used for documents and folders and calls + * {@link SeedDMS_Core_Folder::getAccessMode()} or + * {@link SeedDMS_Core_Document::getAccessMode()}. A document is also + * filtered out if it has no latest content, which can happen if access + * on documents in a certain state has been restricted. + * * @param array $objArr list of objects (either documents or folders) * @param object $user user for which access is checked * @param integer $minMode minimum access mode required @@ -242,8 +255,15 @@ class SeedDMS_Core_DMS { } $newArr = array(); foreach ($objArr as $obj) { - if ($obj->getAccessMode($user) >= $minMode) - array_push($newArr, $obj); + if ($obj->getAccessMode($user) >= $minMode) { + $dms = $obj->_dms; + if(get_class($obj) == $dms->getClassname('document')) { + if($obj->getLatestContent()) + array_push($newArr, $obj); + } else { + array_push($newArr, $obj); + } + } } return $newArr; } /* }}} */ @@ -358,6 +378,7 @@ class SeedDMS_Core_DMS { $this->forceRename = false; $this->enableConverting = false; $this->convertFileTypes = array(); + $this->noReadForStatus = array(); $this->classnames = array(); $this->classnames['folder'] = 'SeedDMS_Core_Folder'; $this->classnames['document'] = 'SeedDMS_Core_Document'; @@ -563,6 +584,19 @@ class SeedDMS_Core_DMS { $this->user = $user; } /* }}} */ + /** + * Get the logged in user + * + * If user authentication was done externally, this function can + * be used to tell the dms who is currently logged in. + * + * @return object $user + * + */ + function getLoggedInUser() { /* {{{ */ + return $this->user; + } /* }}} */ + /** * Return a document by its id *