From 46843ad0e7c7b10e7c178b12b278cfe627041c0b Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 9 Mar 2016 07:44:12 +0100 Subject: [PATCH] add mayEditVersion() checks if version may be edited online --- inc/inc.ClassAccessOperation.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/inc/inc.ClassAccessOperation.php b/inc/inc.ClassAccessOperation.php index d2e053d4a..ceb5e7897 100644 --- a/inc/inc.ClassAccessOperation.php +++ b/inc/inc.ClassAccessOperation.php @@ -45,6 +45,27 @@ class SeedDMS_AccessOperation { $this->settings = $settings; } /* }}} */ + /** + * Check if editing of version is allowed + * + * This check can only be done for documents. Removal of versions is + * only allowed if this is turned on in the settings and there are + * at least 2 versions avaiable. Everybody with write access on the + * document may delete versions. The admin may even delete a version + * even if is disallowed in the settings. + */ + function mayEditVersion() { /* {{{ */ + if(get_class($this->obj) == 'SeedDMS_Core_Document') { + $version = $this->obj->getLatestContent(); + if (!isset($this->settings->_editOnlineFileTypes) || !is_array($this->settings->_editOnlineFileTypes) || !in_array(strtolower($version->getFileType()), $this->settings->_editOnlineFileTypes)) + return false; + if ($this->obj->getAccessMode($this->user) == M_ALL || $this->user->isAdmin()) { + return true; + } + } + return false; + } /* }}} */ + /** * Check if removal of version is allowed *