mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-11 09:35:00 +00:00
update full text engine
also index content if file size is less the a configured size (Closes: #270)
This commit is contained in:
parent
8770aaecb3
commit
04d7fdf258
|
@ -285,6 +285,7 @@ for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
|
|||
}
|
||||
}
|
||||
|
||||
$filesize = SeedDMS_Core_File::fileSize($userfiletmp);
|
||||
$res = $folder->addDocument($name, $comment, $expires, $user, $keywords,
|
||||
$cats, $userfiletmp, basename($userfilename),
|
||||
$fileType, $userfiletype, $sequence,
|
||||
|
@ -306,7 +307,7 @@ for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
|
|||
$index = $indexconf['Indexer']::open($settings->_luceneDir);
|
||||
if($index) {
|
||||
$indexconf['Indexer']::init($settings->_stopWordsFile);
|
||||
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, true));
|
||||
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($filesize < $settings->_maxSizeForFullText)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,18 @@ if (count($document->getContent())==1) {
|
|||
if (!$document->remove()) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
||||
} else {
|
||||
/* Remove the document from the fulltext index */
|
||||
if($settings->_enableFullSearch) {
|
||||
$index = $indexconf['Indexer']::open($settings->_luceneDir);
|
||||
if($index) {
|
||||
$lucenesearch = new $indexconf['Search']($index);
|
||||
if($hit = $lucenesearch->getDocument($documentid)) {
|
||||
$index->delete($hit->id);
|
||||
$index->commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($notifier){
|
||||
$subject = "document_deleted_email_subject";
|
||||
$message = "document_deleted_email_body";
|
||||
|
@ -115,6 +127,21 @@ else {
|
|||
if (!$document->removeContent($version)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
||||
} else {
|
||||
/* Remove the document from the fulltext index and reindex latest version */
|
||||
if($settings->_enableFullSearch) {
|
||||
$index = $indexconf['Indexer']::open($settings->_luceneDir);
|
||||
if($index) {
|
||||
$lucenesearch = new $indexconf['Search']($index);
|
||||
if($hit = $lucenesearch->getDocument($document->getID())) {
|
||||
$index->delete($hit->id);
|
||||
}
|
||||
$version = $document->getLatestContent();
|
||||
$indexconf['Indexer']::init($settings->_stopWordsFile);
|
||||
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($version->getFileSize() < $settings->_maxSizeForFullText)));
|
||||
$index->commit();
|
||||
}
|
||||
}
|
||||
|
||||
// Notify affected users.
|
||||
if ($notifier){
|
||||
$nl=$document->getNotifyList();
|
||||
|
|
|
@ -227,11 +227,25 @@ if ($_FILES['userfile']['error'] == 0) {
|
|||
$attributes = array();
|
||||
}
|
||||
|
||||
$filesize = SeedDMS_Core_File::fileSize($userfiletmp);
|
||||
$contentResult=$document->addContent($comment, $user, $userfiletmp, basename($userfilename), $fileType, $userfiletype, $reviewers, $approvers, $version=0, $attributes, $workflow);
|
||||
if (is_bool($contentResult) && !$contentResult) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
||||
}
|
||||
else {
|
||||
if($settings->_enableFullSearch) {
|
||||
$index = $indexconf['Indexer']::open($settings->_luceneDir);
|
||||
if($index) {
|
||||
$lucenesearch = new $indexconf['Search']($index);
|
||||
if($hit = $lucenesearch->getDocument((int) $document->getId())) {
|
||||
$index->delete($hit->id);
|
||||
}
|
||||
$indexconf['Indexer']::init($settings->_stopWordsFile);
|
||||
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($filesize < $settings->_maxSizeForFullText)));
|
||||
$index->commit();
|
||||
}
|
||||
}
|
||||
|
||||
// Send notification to subscribers.
|
||||
if ($notifier){
|
||||
$notifyList = $document->getNotifyList();
|
||||
|
|
|
@ -150,34 +150,29 @@ if( move_uploaded_file( $source_file_path, $target_file_path ) ) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
$filesize = SeedDMS_Core_File::fileSize($userfiletmp);
|
||||
$contentResult=$document->addContent($comment, $user, $userfiletmp, basename($userfilename), $fileType, $userfiletype, $reviewers, $approvers);
|
||||
unlink($userfiletmp);
|
||||
if (is_bool($contentResult) && !$contentResult) {
|
||||
echo getMLText("error_occured");
|
||||
} else {
|
||||
if($settings->_enableFullSearch) {
|
||||
$index = $indexconf['Indexer']::open($settings->_luceneDir);
|
||||
if($index) {
|
||||
$lucenesearch = new $indexconf['Search']($index);
|
||||
if($hit = $lucenesearch->getDocument((int) $document->getId())) {
|
||||
$index->delete($hit->id);
|
||||
}
|
||||
$indexconf['Indexer']::init($settings->_stopWordsFile);
|
||||
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($filesize < $settings->_maxSizeForFullText)));
|
||||
$index->commit();
|
||||
}
|
||||
}
|
||||
|
||||
// Send notification to subscribers.
|
||||
if ($notifier){
|
||||
$notifyList = $document->getNotifyList();
|
||||
$folder = $document->getFolder();
|
||||
/*
|
||||
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("document_updated_email");
|
||||
$message = getMLText("document_updated_email")."\r\n";
|
||||
$message .=
|
||||
getMLText("document").": ".$document->getName()."\r\n".
|
||||
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
|
||||
getMLText("comment").": ".$document->getComment()."\r\n".
|
||||
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
|
||||
|
||||
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
|
||||
foreach ($document->_notifyList["groups"] as $grp) {
|
||||
$notifier->toGroup($user, $grp, $subject, $message);
|
||||
}
|
||||
|
||||
// if user is not owner send notification to owner
|
||||
if ($user->getID()!= $document->getOwner()->getID())
|
||||
$notifier->toIndividual($user, $document->getOwner(), $subject, $message);
|
||||
*/
|
||||
$subject = "document_updated_email_subject";
|
||||
$message = "document_updated_email_body";
|
||||
$params = array();
|
||||
|
@ -205,20 +200,6 @@ if( move_uploaded_file( $source_file_path, $target_file_path ) ) {
|
|||
$notifyList = $document->getNotifyList();
|
||||
$folder = $document->getFolder();
|
||||
// Send notification to subscribers.
|
||||
/*
|
||||
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("expiry_changed_email");
|
||||
$message = getMLText("expiry_changed_email")."\r\n";
|
||||
$message .=
|
||||
getMLText("document").": ".$document->getName()."\r\n".
|
||||
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
|
||||
getMLText("comment").": ".$document->getComment()."\r\n".
|
||||
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
|
||||
|
||||
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
|
||||
foreach ($document->_notifyList["groups"] as $grp) {
|
||||
$notifier->toGroup($user, $grp, $subject, $message);
|
||||
}
|
||||
*/
|
||||
$subject = "expiry_changed_email_subject";
|
||||
$message = "expiry_changed_email_body";
|
||||
$params = array();
|
||||
|
|
Loading…
Reference in New Issue
Block a user