remove folders from fulltext index

This commit is contained in:
Uwe Steinmann 2020-12-14 07:08:14 +01:00
parent beaa54ac92
commit 44daf8cc10

View File

@ -44,17 +44,25 @@ class SeedDMS_Controller_RemoveFolder extends SeedDMS_Controller_Common {
/* Register a callback which removes each document from the fulltext index /* Register a callback which removes each document from the fulltext index
* The callback must return null other the removal will be canceled. * The callback must return null other the removal will be canceled.
*/ */
function removeFromIndex($fulltextservice, $document) { function removeFromIndex($arr, $document) {
$fulltextservice = $arr[0];
$lucenesearch = $fulltextservice->Search(); $lucenesearch = $fulltextservice->Search();
if($hit = $lucenesearch->getDocument($document->getID())) { $hit = null;
if($document->isType('document'))
$hit = $lucenesearch->getDocument($document->getID());
elseif($document->isType('folder'))
$hit = $lucenesearch->getFolder($document->getID());
if($hit) {
$index = $fulltextservice->Indexer(); $index = $fulltextservice->Indexer();
$index->delete($hit->id); $index->delete($hit->id);
$index->commit(); $index->commit();
} }
return null; return null;
} }
if($fulltextservice && ($index = $fulltextservice->Indexer())) if($fulltextservice && ($index = $fulltextservice->Indexer())) {
$dms->setCallback('onPreRemoveDocument', 'removeFromIndex', array($fulltextservice)); $dms->addCallback('onPreRemoveDocument', 'removeFromIndex', array($fulltextservice));
$dms->addCallback('onPreRemoveFolder', 'removeFromIndex', array($fulltextservice));
}
function removePreviews($arr, $document) { function removePreviews($arr, $document) {
$previewer = $arr[0]; $previewer = $arr[0];