From ae14f25d58c17b73fc93b6571c93c259593f2cb2 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 4 Apr 2016 07:39:39 +0200 Subject: [PATCH] add more callbacks --- SeedDMS_Core/Core/inc.ClassDMS.php | 44 ++++++++++++++++++++++--- SeedDMS_Core/Core/inc.ClassDocument.php | 2 +- SeedDMS_Core/Core/inc.ClassFolder.php | 31 +++++++++++++++++ 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index f0b911c7d..69dce6f88 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -1287,7 +1287,16 @@ class SeedDMS_Core_DMS { if (!$res) return false; - return $this->getUser($this->db->getInsertID()); + $user = $this->getUser($this->db->getInsertID()); + + /* Check if 'onPostAddUser' callback is set */ + if(isset($this->_dms->callbacks['onPostAddUser'])) { + $callback = $this->_dms->callbacks['onPostUser']; + if(!call_user_func($callback[0], $callback[1], $user)) { + } + } + + return $user; } /* }}} */ /** @@ -1378,7 +1387,16 @@ class SeedDMS_Core_DMS { if (!$this->db->getResult($queryStr)) return false; - return $this->getGroup($this->db->getInsertID()); + $group = $this->getGroup($this->db->getInsertID()); + + /* Check if 'onPostAddGroup' callback is set */ + if(isset($this->_dms->callbacks['onPostAddGroup'])) { + $callback = $this->_dms->callbacks['onPostAddGroup']; + if(!call_user_func($callback[0], $callback[1], $group)) { + } + } + + return $group; } /* }}} */ function getKeywordCategory($id) { /* {{{ */ @@ -1457,7 +1475,16 @@ class SeedDMS_Core_DMS { if (!$this->db->getResult($queryStr)) return false; - return $this->getKeywordCategory($this->db->getInsertID()); + $category = $this->getKeywordCategory($this->db->getInsertID()); + + /* Check if 'onPostAddKeywordCategory' callback is set */ + if(isset($this->_dms->callbacks['onPostAddKeywordCategory'])) { + $callback = $this->_dms->callbacks['onPostAddKeywordCategory']; + if(!call_user_func($callback[0], $callback[1], $category)) { + } + } + + return $category; } /* }}} */ function getDocumentCategory($id) { /* {{{ */ @@ -1523,7 +1550,16 @@ class SeedDMS_Core_DMS { if (!$this->db->getResult($queryStr)) return false; - return $this->getDocumentCategory($this->db->getInsertID()); + $category = $this->getDocumentCategory($this->db->getInsertID()); + + /* Check if 'onPostAddDocumentCategory' callback is set */ + if(isset($this->_dms->callbacks['onPostAddDocumentCategory'])) { + $callback = $this->_dms->callbacks['onPostAddDocumentCategory']; + if(!call_user_func($callback[0], $callback[1], $category)) { + } + } + + return $category; } /* }}} */ /** diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index 21c5791ba..02ad69daa 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -1798,7 +1798,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ $db->startTransaction(); - // FIXME: call a new function removeContent instead + // remove content of document foreach ($this->_content as $version) { if (!$this->removeContent($version)) { $db->rollbackTransaction(); diff --git a/SeedDMS_Core/Core/inc.ClassFolder.php b/SeedDMS_Core/Core/inc.ClassFolder.php index 3d9ef1f76..9a8302ddf 100644 --- a/SeedDMS_Core/Core/inc.ClassFolder.php +++ b/SeedDMS_Core/Core/inc.ClassFolder.php @@ -482,6 +482,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { } $db->commitTransaction(); + + /* Check if 'onPostAddSubFolder' callback is set */ + if(isset($this->_dms->callbacks['onPostAddSubFolder'])) { + $callback = $this->_dms->callbacks['onPostAddSubFolder']; + if(!call_user_func($callback[0], $callback[1], $newFolder)) { + } + } + return $newFolder; } /* }}} */ @@ -791,12 +799,28 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { } $db->commitTransaction(); + + /* Check if 'onPostAddDocument' callback is set */ + if(isset($this->_dms->callbacks['onPostAddDocument'])) { + $callback = $this->_dms->callbacks['onPostAddDocument']; + if(!call_user_func($callback[0], $callback[1], $document)) { + } + } + return array($document, $res); } /* }}} */ function remove() { /* {{{ */ $db = $this->_dms->getDB(); + /* Check if 'onPreRemoveFolder' callback is set */ + if(isset($this->_dms->callbacks['onPreRemoveFolder'])) { + $callback = $this->_dms->callbacks['onPreRemoveFolder']; + if(!call_user_func($callback[0], $callback[1], $this)) { + return false; + } + } + // Do not delete the root folder. if ($this->_id == $this->_dms->rootFolderID || !isset($this->_parentID) || ($this->_parentID == null) || ($this->_parentID == "") || ($this->_parentID == 0)) { return false; @@ -847,6 +871,13 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { } $db->commitTransaction(); + /* Check if 'onPostRemoveFolder' callback is set */ + if(isset($this->_dms->callbacks['onPostRemoveFolder'])) { + $callback = $this->_dms->callbacks['onPostRemoveFolder']; + if(!call_user_func($callback[0], $callback[1], $this->_id)) { + } + } + return true; } /* }}} */