add more callbacks

This commit is contained in:
Uwe Steinmann 2016-04-04 07:39:39 +02:00
parent 5c32c6edbe
commit ae14f25d58
3 changed files with 72 additions and 5 deletions

View File

@ -1287,7 +1287,16 @@ class SeedDMS_Core_DMS {
if (!$res) if (!$res)
return false; 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)) if (!$this->db->getResult($queryStr))
return false; 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) { /* {{{ */ function getKeywordCategory($id) { /* {{{ */
@ -1457,7 +1475,16 @@ class SeedDMS_Core_DMS {
if (!$this->db->getResult($queryStr)) if (!$this->db->getResult($queryStr))
return false; 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) { /* {{{ */ function getDocumentCategory($id) { /* {{{ */
@ -1523,7 +1550,16 @@ class SeedDMS_Core_DMS {
if (!$this->db->getResult($queryStr)) if (!$this->db->getResult($queryStr))
return false; 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;
} /* }}} */ } /* }}} */
/** /**

View File

@ -1798,7 +1798,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$db->startTransaction(); $db->startTransaction();
// FIXME: call a new function removeContent instead // remove content of document
foreach ($this->_content as $version) { foreach ($this->_content as $version) {
if (!$this->removeContent($version)) { if (!$this->removeContent($version)) {
$db->rollbackTransaction(); $db->rollbackTransaction();

View File

@ -482,6 +482,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
} }
$db->commitTransaction(); $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; return $newFolder;
} /* }}} */ } /* }}} */
@ -791,12 +799,28 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
} }
$db->commitTransaction(); $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); return array($document, $res);
} /* }}} */ } /* }}} */
function remove() { /* {{{ */ function remove() { /* {{{ */
$db = $this->_dms->getDB(); $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. // Do not delete the root folder.
if ($this->_id == $this->_dms->rootFolderID || !isset($this->_parentID) || ($this->_parentID == null) || ($this->_parentID == "") || ($this->_parentID == 0)) { if ($this->_id == $this->_dms->rootFolderID || !isset($this->_parentID) || ($this->_parentID == null) || ($this->_parentID == "") || ($this->_parentID == 0)) {
return false; return false;
@ -847,6 +871,13 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
} }
$db->commitTransaction(); $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; return true;
} /* }}} */ } /* }}} */