call hooks like in updateDocument

This commit is contained in:
Uwe Steinmann 2019-01-17 18:27:38 +01:00
parent 35fa67ae93
commit e0bbc4bab5

View File

@ -63,8 +63,8 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
$maxsizeforfulltext = $this->getParam('maxsizeforfulltext');
$defaultaccessdocs = $this->getParam('defaultaccessdocs');
$result = $this->callHook('addDocument');
if($result === null) {
$document = $this->callHook('addDocument');
if($document === null) {
$filesize = SeedDMS_Core_File::fileSize($userfiletmp);
$res = $folder->addDocument($name, $comment, $expires, $owner, $keywords,
$cats, $userfiletmp, utf8_basename($userfilename),
@ -87,13 +87,6 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
}
}
if($index) {
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($filesize < $settings->_maxSizeForFullText));
if(!$this->callHook('preIndexDocument', $document, $idoc)) {
}
$index->addDocument($idoc);
}
/* Add a default notification for the owner of the document */
if($settings->_enableOwnerNotification) {
$res = $document->addNotify($user->getID(), true);
@ -107,13 +100,24 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
if($document->getGroupAccessMode($notgroup) >= M_READ)
$res = $document->addNotify($notgroup->getID(), false);
}
if(!$this->callHook('postAddDocument', $document)) {
}
$result = $document;
} elseif($result === false) {
if(empty($this->errormsg))
$this->errormsg = 'hook_addDocument_failed';
return false;
}
return $result;
if($index && $document) {
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($filesize < $settings->_maxSizeForFullText));
if(false !== $this->callHook('preIndexDocument', $document, $idoc)) {
$index->addDocument($idoc);
$index->commit();
}
}
if(!$this->callHook('postAddDocument', $document)) {
}
return $document;
} /* }}} */
}