mirror of
https://codeberg.org/SeedDMS/paperless
synced 2024-11-26 15:32:08 +00:00
check if fulltext search is turned on
This commit is contained in:
parent
0eb85b8ebe
commit
8b642f78b1
|
@ -46,9 +46,12 @@ class SeedDMS_ExtPaperless_Settings { /* {{{ */
|
||||||
$settings = $view->getParam('settings');
|
$settings = $view->getParam('settings');
|
||||||
if($extname != 'paperless')
|
if($extname != 'paperless')
|
||||||
return;
|
return;
|
||||||
if(empty($settings->_extensions['paperless']['jwtsecret'])) {
|
if(empty($settings->_extensions['paperless']['jwtsecret']) || empty($settings->_enableFullSearch)) {
|
||||||
echo $view->contentSubHeading(getMLText($extname));
|
echo $view->contentSubHeading(getMLText($extname));
|
||||||
|
if(empty($settings->_extensions['paperless']['jwtsecret']))
|
||||||
echo $view->warningMsg(getMLText('paperless_jwtsecret_not_set'));
|
echo $view->warningMsg(getMLText('paperless_jwtsecret_not_set'));
|
||||||
|
if(empty($settings->_enableXsendfile))
|
||||||
|
echo $view->warningMsg(getMLText('paperless_needs_fulltextsearch'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -107,8 +110,7 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
if(file_exists($file))
|
if(file_exists($file))
|
||||||
$content = file_get_contents($file);
|
$content = file_get_contents($file);
|
||||||
} else {
|
} else {
|
||||||
$index = $fulltextservice->Indexer();
|
if($fulltextservice && $index = $fulltextservice->Indexer()) {
|
||||||
if($index) {
|
|
||||||
$lucenesearch = $fulltextservice->Search();
|
$lucenesearch = $fulltextservice->Search();
|
||||||
if($searchhit = $lucenesearch->getDocument($document->getID())) {
|
if($searchhit = $lucenesearch->getDocument($document->getID())) {
|
||||||
$idoc = $searchhit->getDocument();
|
$idoc = $searchhit->getDocument();
|
||||||
|
@ -264,8 +266,7 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
} elseif(!isset($settings->_extensions['paperless']['rootfolder']) || !($startfolder = $dms->getFolder($settings->_extensions['paperless']['rootfolder'])))
|
} elseif(!isset($settings->_extensions['paperless']['rootfolder']) || !($startfolder = $dms->getFolder($settings->_extensions['paperless']['rootfolder'])))
|
||||||
$startfolder = $dms->getFolder($settings->_rootFolderID);
|
$startfolder = $dms->getFolder($settings->_rootFolderID);
|
||||||
|
|
||||||
$index = $fulltextservice->Indexer();
|
if($fulltextservice && $index = $fulltextservice->Indexer()) {
|
||||||
if($index) {
|
|
||||||
$lucenesearch = $fulltextservice->Search();
|
$lucenesearch = $fulltextservice->Search();
|
||||||
$searchresult = $lucenesearch->search('', array('record_type'=>['document'], 'status'=>[2], 'user'=>[$userobj->getLogin()], 'startFolder'=>$startfolder, 'rootFolder'=>$startfolder), array('limit'=>20), array());
|
$searchresult = $lucenesearch->search('', array('record_type'=>['document'], 'status'=>[2], 'user'=>[$userobj->getLogin()], 'startFolder'=>$startfolder, 'rootFolder'=>$startfolder), array('limit'=>20), array());
|
||||||
if($searchresult === false) {
|
if($searchresult === false) {
|
||||||
|
@ -658,8 +659,7 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
/* more_like_id is set to find similar documents {{{ */
|
/* more_like_id is set to find similar documents {{{ */
|
||||||
if(isset($params['more_like_id'])) {
|
if(isset($params['more_like_id'])) {
|
||||||
|
|
||||||
$index = $fulltextservice->Indexer();
|
if($fulltextservice && $lucenesearch = $fulltextservice->Search()) {
|
||||||
$lucenesearch = $fulltextservice->Search();
|
|
||||||
if($searchhit = $lucenesearch->getDocument((int) $params['more_like_id'])) {
|
if($searchhit = $lucenesearch->getDocument((int) $params['more_like_id'])) {
|
||||||
$idoc = $searchhit->getDocument();
|
$idoc = $searchhit->getDocument();
|
||||||
if($idoc) {
|
if($idoc) {
|
||||||
|
@ -726,6 +726,7 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $response->withJson(array('count'=>0, 'next'=>null, 'previous'=>null, 'offset'=>0, 'limit'=>$limit, 'results'=>[]), 200);
|
return $response->withJson(array('count'=>0, 'next'=>null, 'previous'=>null, 'offset'=>0, 'limit'=>$limit, 'results'=>[]), 200);
|
||||||
/* Get all documents in the same folder and subfolders
|
/* Get all documents in the same folder and subfolders
|
||||||
|
@ -799,8 +800,7 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
$aend = (int) makeTsFromDate($params['created__date__lt']);
|
$aend = (int) makeTsFromDate($params['created__date__lt']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$index = $fulltextservice->Indexer();
|
if($fulltextservice && $lucenesearch = $fulltextservice->Search()) {
|
||||||
if($index) {
|
|
||||||
$logger->log('Query is '.$query, PEAR_LOG_DEBUG);
|
$logger->log('Query is '.$query, PEAR_LOG_DEBUG);
|
||||||
/*
|
/*
|
||||||
$logger->log('User is '.$userobj->getLogin(), PEAR_LOG_DEBUG);
|
$logger->log('User is '.$userobj->getLogin(), PEAR_LOG_DEBUG);
|
||||||
|
@ -813,7 +813,6 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
$logger->log('limit is '.$limit, PEAR_LOG_DEBUG);
|
$logger->log('limit is '.$limit, PEAR_LOG_DEBUG);
|
||||||
$logger->log('offset is '.$offset, PEAR_LOG_DEBUG);
|
$logger->log('offset is '.$offset, PEAR_LOG_DEBUG);
|
||||||
*/
|
*/
|
||||||
$lucenesearch = $fulltextservice->Search();
|
|
||||||
$searchresult = $lucenesearch->search($query, array('record_type'=>['document'], 'status'=>[2], 'user'=>[$userobj->getLogin()], 'category'=>$categorynames, 'created_start'=>$astart, 'created_end'=>$aend, 'modified_start'=>$mstart, 'modified_end'=>$mend, 'startFolder'=>$startfolder, 'rootFolder'=>$rootfolder, 'attributes'=>$cattrs), array('limit'=>$limit, 'offset'=>$offset), $order, array('no_facets'=>true));
|
$searchresult = $lucenesearch->search($query, array('record_type'=>['document'], 'status'=>[2], 'user'=>[$userobj->getLogin()], 'category'=>$categorynames, 'created_start'=>$astart, 'created_end'=>$aend, 'modified_start'=>$mstart, 'modified_end'=>$mend, 'startFolder'=>$startfolder, 'rootFolder'=>$rootfolder, 'attributes'=>$cattrs), array('limit'=>$limit, 'offset'=>$offset), $order, array('no_facets'=>true));
|
||||||
if($searchresult) {
|
if($searchresult) {
|
||||||
$recs = array();
|
$recs = array();
|
||||||
|
@ -899,8 +898,7 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
$logger->log(var_export($params, true), PEAR_LOG_DEBUG);
|
$logger->log(var_export($params, true), PEAR_LOG_DEBUG);
|
||||||
|
|
||||||
$list = [];
|
$list = [];
|
||||||
$index = $fulltextservice->Indexer();
|
if($fulltextservice && ($index = $fulltextservice->Indexer())) {
|
||||||
if($index) {
|
|
||||||
if($terms = $index->terms($query, $field)) {
|
if($terms = $index->terms($query, $field)) {
|
||||||
foreach($terms as $term)
|
foreach($terms as $term)
|
||||||
$list[] = implode(' ', $allterms).' '.$term->text;
|
$list[] = implode(' ', $allterms).' '.$term->text;
|
||||||
|
@ -993,9 +991,7 @@ class SeedDMS_ExtPaperless_RestAPI_Controller { /* {{{ */
|
||||||
'documents_inbox'=>0,
|
'documents_inbox'=>0,
|
||||||
);
|
);
|
||||||
|
|
||||||
$index = $fulltextservice->Indexer();
|
if($fulltextservice && ($lucenesearch = $fulltextservice->Search())) {
|
||||||
if($index) {
|
|
||||||
$lucenesearch = $fulltextservice->Search();
|
|
||||||
$searchresult = $lucenesearch->search('', array('record_type'=>['document'], 'status'=>[2], 'user'=>[$userobj->getLogin()], 'startFolder'=>$startfolder, 'rootFolder'=>$startfolder), array('limit'=>1), array(), array('no_facets'=>true));
|
$searchresult = $lucenesearch->search('', array('record_type'=>['document'], 'status'=>[2], 'user'=>[$userobj->getLogin()], 'startFolder'=>$startfolder, 'rootFolder'=>$startfolder), array('limit'=>1), array(), array('no_facets'=>true));
|
||||||
if($searchresult === false) {
|
if($searchresult === false) {
|
||||||
return $response->withStatus(500);
|
return $response->withStatus(500);
|
||||||
|
|
4
lang.php
4
lang.php
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
$__lang['en_GB'] = array(
|
$__lang['en_GB'] = array(
|
||||||
|
'paperless'=>'Paperless',
|
||||||
'paperless_upload_succeded'=>'Upload succeded',
|
'paperless_upload_succeded'=>'Upload succeded',
|
||||||
'paperless_upload_failed'=>'Upload failed',
|
'paperless_upload_failed'=>'Upload failed',
|
||||||
'paperless_missing_target_folder'=>'Missing target folder',
|
'paperless_missing_target_folder'=>'Missing target folder',
|
||||||
|
@ -7,8 +8,10 @@ $__lang['en_GB'] = array(
|
||||||
'paperless_upload_maxsize'=>'Max file size exceeded',
|
'paperless_upload_maxsize'=>'Max file size exceeded',
|
||||||
'paperless_token_has_expired'=>'Token has expired. Login again before you proceed.',
|
'paperless_token_has_expired'=>'Token has expired. Login again before you proceed.',
|
||||||
'paperless_jwtsecret_not_set'=>'The secret for the JSON Web Token is not set. This is required for successful login.',
|
'paperless_jwtsecret_not_set'=>'The secret for the JSON Web Token is not set. This is required for successful login.',
|
||||||
|
'paperless_needs_fulltextsearch'=>'The extension needs fulltext search to be on.',
|
||||||
);
|
);
|
||||||
$__lang['de_DE'] = array(
|
$__lang['de_DE'] = array(
|
||||||
|
'paperless'=>'Paperless',
|
||||||
'paperless_upload_succeded'=>'Erfolgreich hochgeladen',
|
'paperless_upload_succeded'=>'Erfolgreich hochgeladen',
|
||||||
'paperless_upload_failed'=>'Hochladen fehlgeschlagen',
|
'paperless_upload_failed'=>'Hochladen fehlgeschlagen',
|
||||||
'paperless_missing_target_folder'=>'Zielordner nicht vorhanden',
|
'paperless_missing_target_folder'=>'Zielordner nicht vorhanden',
|
||||||
|
@ -16,5 +19,6 @@ $__lang['de_DE'] = array(
|
||||||
'paperless_upload_maxsize'=>'Maximale Dateigröße überschritten',
|
'paperless_upload_maxsize'=>'Maximale Dateigröße überschritten',
|
||||||
'paperless_token_has_expired'=>'Token abgelaufen. Melden Sie sich bitte neu an.',
|
'paperless_token_has_expired'=>'Token abgelaufen. Melden Sie sich bitte neu an.',
|
||||||
'paperless_jwtsecret_not_set'=>'Das Geheimnis des JSON Web Token ist nicht gesetzt. Dies ist für eine erfolgreiche Anmeldung erforderlich.',
|
'paperless_jwtsecret_not_set'=>'Das Geheimnis des JSON Web Token ist nicht gesetzt. Dies ist für eine erfolgreiche Anmeldung erforderlich.',
|
||||||
|
'paperless_needs_fulltextsearch'=>'Die Erweiterung erfordert eine konfigurierte Volltextsuche .',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user