From d1c11c04aaeb1b413a690218792d69e7719a9e84 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 10 Jan 2014 07:50:36 +0100 Subject: [PATCH] call the hook and let it do everything only if the hook returns null, than proceed with the regular removal --- controllers/class.RemoveDocument.php | 30 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/controllers/class.RemoveDocument.php b/controllers/class.RemoveDocument.php index 10cc56aad..c50fc5eac 100644 --- a/controllers/class.RemoveDocument.php +++ b/controllers/class.RemoveDocument.php @@ -31,28 +31,32 @@ class SeedDMS_Controller_RemoveDocument extends SeedDMS_Controller_Common { $folder = $document->getFolder(); - /* Get the notify list before removing the document */ + /* Get the document id and name before removing the document */ $docname = $document->getName(); $documentid = $document->getID(); if(!$this->callHook('preRemoveDocument')) { } - if (!$document->remove()) { - return false; - } else { + $result = $this->callHook('removeDocument', $document); + if($result === null) { + if (!$document->remove()) { + return false; + } else { + + if(!$this->callHook('postRemoveDocument')) { + } + + /* Remove the document from the fulltext index */ + if($index && $hits = $index->find('document_id:'.$documentid)) { + $hit = $hits[0]; + $index->delete($hit->id); + $index->commit(); + } - if(!$this->callHook('postRemoveDocument')) { } - - /* Remove the document from the fulltext index */ - if($index && $hits = $index->find('document_id:'.$documentid)) { - $hit = $hits[0]; - $index->delete($hit->id); - $index->commit(); - } - } + return true; } }