categoryids has been replaced by category

This commit is contained in:
Uwe Steinmann 2020-09-12 12:52:44 +02:00
parent b7d5f09e5a
commit d33eb59b4a

View File

@ -72,12 +72,12 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
// category
$categories = array();
$categorynames = array();
if(isset($_GET['categoryids']) && $_GET['categoryids']) {
foreach($_GET['categoryids'] as $catid) {
if($catid > 0) {
$category = $dms->getDocumentCategory($catid);
$categories[] = $category;
$categorynames[] = $category->getName();
if(isset($_GET['category']) && $_GET['category']) {
foreach($_GET['category'] as $catname) {
if($catname) {
$cat = $dms->getDocumentCategoryByName($catname);
$categories[] = $cat;
$categorynames[] = $cat->getName();
}
}
}
@ -104,64 +104,123 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
// Check to see if the search has been restricted to a particular
// document owner.
$owner = null;
if (isset($_GET["ownerid"]) && is_numeric($_GET["ownerid"]) && $_GET["ownerid"]!=-1) {
$owner = $dms->getUser($_GET["ownerid"]);
if (!is_object($owner)) {
UI::exitError(getMLText("search_results"),getMLText("unknown_owner"));
$owner = [];
if (isset($_GET["owner"])) {
if (!is_array($_GET['owner'])) {
if(!empty($_GET['owner']) && $o = $dms->getUserByLogin($_GET['owner']))
$owner[] = $o->getLogin();
else
UI::exitError(getMLText("search"),getMLText("unknown_owner"));
} else {
foreach($_GET["owner"] as $l) {
if($l && $o = $dms->getUserByLogin($l))
$owner[] = $o->getLogin();
}
}
}
$startTime = getTime();
if($settings->_enableFullSearch) {
if($settings->_fullSearchEngine == 'lucene') {
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
// Check to see if the search has been restricted to a particular
// mimetype.
$mimetype = [];
if (isset($_GET["mimetype"])) {
if (!is_array($_GET['mimetype'])) {
if(!empty($_GET['mimetype']))
$mimetype[] = $_GET['mimetype'];
} else {
foreach($_GET["mimetype"] as $l) {
if($l)
$mimetype[] = $l;
}
}
}
// status
$status = array();
if (isset($_GET["pendingReview"])){
$status[] = S_DRAFT_REV;
}
if (isset($_GET["pendingApproval"])){
$status[] = S_DRAFT_APP;
}
if (isset($_GET["inWorkflow"])){
$status[] = S_IN_WORKFLOW;
}
if (isset($_GET["released"])){
$status[] = S_RELEASED;
}
if (isset($_GET["rejected"])){
$status[] = S_REJECTED;
}
if (isset($_GET["obsolete"])){
$status[] = S_OBSOLETE;
}
if (isset($_GET["expired"])){
$status[] = S_EXPIRED;
}
$startTime = getTime();
if($settings->_fullSearchEngine == 'lucene') {
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
}
if(strlen($query) < 4 && strpos($query, '*')) {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
$dcount = 0;
$totalPages = 0;
$entries = array();
$searchTime = 0;
} else {
$startTime = getTime();
$index = $fulltextservice->Indexer();
$lucenesearch = $fulltextservice->Search();
$searchresult = $lucenesearch->search($query, $owner ? $owner->getLogin() : '', '', $categorynames, array(), $user->isAdmin() ? [] : [$user->getLogin()]);
if($searchresult === false) {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
$totalPages = 0;
$entries = array();
$searchTime = 0;
} else {
$entries = array();
$dcount = $searchresult['count']; //0;
$fcount = 0;
if($searchresult) {
foreach($searchresult['hits'] as $hit) {
if($tmp = $dms->getDocument($hit['document_id'])) {
if($tmp->getAccessMode($user) >= M_READ) {
$tmp->verifyLastestContentExpriry();
$entries[] = $tmp;
// $dcount++;
if($index) {
$lucenesearch = $fulltextservice->Search();
$searchresult = $lucenesearch->search($query, array('owner'=>$owner, 'status'=>$status, 'category'=>$categorynames, 'user'=>$user->isAdmin() ? [] : [$user->getLogin()], 'mimetype'=>$mimetype));
if($searchresult === false) {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
$dcount = 0;
$fcount = 0;
$totalPages = 0;
$entries = array();
$facets = array();
$searchTime = 0;
} else {
$entries = array();
$facets = $searchresult['facets'];
$dcount = $searchresult['count']; //0;
$fcount = 0;
if($searchresult) {
foreach($searchresult['hits'] as $hit) {
if($tmp = $dms->getDocument($hit['document_id'])) {
if($tmp->getAccessMode($user) >= M_READ) {
$tmp->verifyLastestContentExpriry();
$entries[] = $tmp;
// $dcount++;
}
}
}
}
$limit = 20;
if($pageNumber != 'all' && count($entries) > $limit) {
$totalPages = (int) (count($entries)/$limit);
if(count($entries)%$limit)
$totalPages++;
if($limit > 0)
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
} else {
$totalPages = 1;
}
}
$limit = 20;
if($pageNumber != 'all' && count($entries) > $limit) {
$totalPages = (int) (count($entries)/$limit);
if(count($entries)%$limit)
$totalPages++;
if($limit > 0)
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
} else {
$totalPages = 1;
}
$searchTime = getTime() - $startTime;
$searchTime = round($searchTime, 2);
} else {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_search_service')));
$dcount = 0;
$fcount = 0;
$totalPages = 0;
$entries = array();
$facets = array();
$searchTime = 0;
}
$searchTime = getTime() - $startTime;
$searchTime = round($searchTime, 2);
}
// }}}
} else {
@ -229,11 +288,15 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
// Check to see if the search has been restricted to a particular
// document owner.
$owner = null;
if (isset($_GET["ownerid"]) && is_numeric($_GET["ownerid"]) && $_GET["ownerid"]!=-1) {
$owner = $dms->getUser($_GET["ownerid"]);
if (!is_object($owner)) {
$owner = array();
if (isset($_GET["owner"])) {
if (!is_array($_GET['owner'])) {
UI::exitError(getMLText("search"),getMLText("unknown_owner"));
} else {
foreach($_GET["owner"] as $l) {
if($o = $dms->getUserByLogin($l))
$owner[] = $o;
}
}
}
@ -331,10 +394,14 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
// category
$categories = array();
if(isset($_GET['categoryids']) && $_GET['categoryids']) {
foreach($_GET['categoryids'] as $catid) {
if($catid > 0)
$categories[] = $dms->getDocumentCategory($catid);
$categorynames = array();
if(isset($_GET['category']) && $_GET['category']) {
foreach($_GET['category'] as $catname) {
if($catname) {
$cat = $dms->getDocumentCategoryByName($catname);
$categories[] = $cat;
$categorynames[] = $cat->getName();
}
}
}
@ -419,6 +486,7 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
} else
$totalPages = 1;
$facets = array();
// }}}
}
@ -437,6 +505,7 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'query'=>$query, 'searchhits'=>$entries, 'totalpages'=>$totalPages, 'pagenumber'=>$pageNumber, 'searchtime'=>$searchTime, 'urlparams'=>$_GET, 'cachedir'=>$settings->_cacheDir));
if($view) {
$view->setParam('facets', $facets);
$view->setParam('accessobject', $accessop);
$view->setParam('onepage', $settings->_onePageMode); // do most navigation by reloading areas of pages with ajax
$view->setParam('showtree', showtree());
@ -460,6 +529,8 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
$view->setParam('expirationdate', isset($expirationdate) ? $expirationdate: '');
$view->setParam('status', isset($status) ? $status : array());
$view->setParam('categories', isset($categories) ? $categories : '');
$view->setParam('category', isset($categorynames) ? $categorynames : '');
$view->setParam('mimetype', isset($mimetype) ? $mimetype : '');
$view->setParam('attributes', isset($attributes) ? $attributes : '');
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_document, SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_folder, SeedDMS_Core_AttributeDefinition::objtype_all));
$view->setParam('attrdefs', $attrdefs);