diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 070d9f098..f9009b4bf 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -188,10 +188,22 @@ class SeedDMS_Core_DMS { */ public $callbacks; + /** + * @var string last error message. This can be set by hooks to pass an + * error message from the hook to the application which has called the + * method containing the hook. For example SeedDMS_Core_Document::remove() + * calls the hook 'onPreRemoveDocument'. The hook function can set $dms->lasterror + * which can than be read when SeedDMS_Core_Document::remove() fails. + * This variable could be set in any SeedDMS_Core class, but is currently + * only set by hooks. + * @access public + */ + public $lasterror; + /** * @var SeedDMS_Core_DMS */ - public $_dms; +// public $_dms; /** @@ -381,6 +393,7 @@ class SeedDMS_Core_DMS { $this->classnames['user'] = 'SeedDMS_Core_User'; $this->classnames['group'] = 'SeedDMS_Core_Group'; $this->callbacks = array(); + $this->lasterror = ''; $this->version = '@package_version@'; if($this->version[0] == '@') $this->version = '5.1.16'; @@ -2033,8 +2046,8 @@ class SeedDMS_Core_DMS { $user = $this->getUser($this->db->getInsertID('tblUsers')); /* Check if 'onPostAddUser' callback is set */ - if(isset($this->_dms->callbacks['onPostAddUser'])) { - foreach($this->_dms->callbacks['onPostUser'] as $callback) { + if(isset($this->callbacks['onPostAddUser'])) { + foreach($this->callbacks['onPostUser'] as $callback) { /** @noinspection PhpStatementHasEmptyBodyInspection */ if(!call_user_func($callback[0], $callback[1], $user)) { } @@ -2096,8 +2109,8 @@ class SeedDMS_Core_DMS { $group = $this->getGroup($this->db->getInsertID('tblGroups')); /* Check if 'onPostAddGroup' callback is set */ - if(isset($this->_dms->callbacks['onPostAddGroup'])) { - foreach($this->_dms->callbacks['onPostAddGroup'] as $callback) { + if(isset($this->callbacks['onPostAddGroup'])) { + foreach($this->callbacks['onPostAddGroup'] as $callback) { /** @noinspection PhpStatementHasEmptyBodyInspection */ if(!call_user_func($callback[0], $callback[1], $group)) { } @@ -2188,8 +2201,8 @@ class SeedDMS_Core_DMS { $category = $this->getKeywordCategory($this->db->getInsertID('tblKeywordCategories')); /* Check if 'onPostAddKeywordCategory' callback is set */ - if(isset($this->_dms->callbacks['onPostAddKeywordCategory'])) { - foreach($this->_dms->callbacks['onPostAddKeywordCategory'] as $callback) { + if(isset($this->callbacks['onPostAddKeywordCategory'])) { + foreach($this->callbacks['onPostAddKeywordCategory'] as $callback) { /** @noinspection PhpStatementHasEmptyBodyInspection */ if(!call_user_func($callback[0], $callback[1], $category)) { } @@ -2265,8 +2278,8 @@ class SeedDMS_Core_DMS { $category = $this->getDocumentCategory($this->db->getInsertID('tblCategory')); /* Check if 'onPostAddDocumentCategory' callback is set */ - if(isset($this->_dms->callbacks['onPostAddDocumentCategory'])) { - foreach($this->_dms->callbacks['onPostAddDocumentCategory'] as $callback) { + if(isset($this->callbacks['onPostAddDocumentCategory'])) { + foreach($this->callbacks['onPostAddDocumentCategory'] as $callback) { /** @noinspection PhpStatementHasEmptyBodyInspection */ if(!call_user_func($callback[0], $callback[1], $category)) { }