mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-15 09:39:17 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
e1f976e646
|
@ -46,7 +46,7 @@ class UI extends UI_Default {
|
|||
* @return object an object of a class implementing the view
|
||||
*/
|
||||
static public function factory($theme, $class='', $params=array()) { /* {{{ */
|
||||
global $settings, $dms, $user, $session, $extMgr, $request, $logger, $notifier;
|
||||
global $settings, $dms, $user, $session, $extMgr, $request, $logger, $notifier, $fulltextservice;
|
||||
if(!$class) {
|
||||
$class = 'Bootstrap';
|
||||
$class = 'Style';
|
||||
|
@ -138,6 +138,7 @@ class UI extends UI_Default {
|
|||
$view->setParam('request', $request);
|
||||
$view->setParam('logger', $logger);
|
||||
$view->setParam('notifier', $notifier);
|
||||
$view->setParam('fulltextservice', $fulltextservice);
|
||||
// $view->setParam('settings', $settings);
|
||||
$view->setParam('sitename', $settings->_siteName);
|
||||
$view->setParam('rootfolderid', $settings->_rootFolderID);
|
||||
|
|
|
@ -1424,16 +1424,644 @@ class SeedDMS_FolderTree { /* {{{ */
|
|||
class SeedDMS_Search { /* {{{ */
|
||||
protected $dms;
|
||||
|
||||
protected $user;
|
||||
|
||||
protected $fulltextservice;
|
||||
|
||||
protected $settings;
|
||||
|
||||
public function __construct($dms, $settings) {
|
||||
public $searchparams;
|
||||
|
||||
protected $dcount;
|
||||
|
||||
protected $fcount;
|
||||
|
||||
protected $totalPages;
|
||||
|
||||
protected $entries;
|
||||
|
||||
protected $terms;
|
||||
|
||||
protected $searchTime;
|
||||
|
||||
public function __construct($dms, $user, $fulltextservice, $settings) {
|
||||
$this->dms = $dms;
|
||||
$this->user = $user;
|
||||
$this->fulltextservice = $fulltextservice;
|
||||
$this->settings = $settings;
|
||||
$this->searchparams = [];
|
||||
$this->dcount = 0;
|
||||
$this->fcount = 0;
|
||||
$this->totalPages = 0;
|
||||
$this->entries = array();
|
||||
$this->terms = array();
|
||||
$this->searchTime = 0;
|
||||
}
|
||||
|
||||
public function createSearchFromQuery($urlquery) { /* {{{ */
|
||||
protected function getTime() { /* {{{ */
|
||||
if (function_exists('microtime')) {
|
||||
$tm = microtime();
|
||||
$tm = explode(' ', $tm);
|
||||
return (float) sprintf('%f', $tm[1] + $tm[0]);
|
||||
}
|
||||
return time();
|
||||
} /* }}} */
|
||||
|
||||
public function search() { /* {{{ */
|
||||
public function createSearchFromQuery($get) { /* {{{ */
|
||||
|
||||
/* Creation date {{{ */
|
||||
$createstartts = null;
|
||||
$createstartdate = null;
|
||||
$createendts = null;
|
||||
$createenddate = null;
|
||||
$created['from'] = null;
|
||||
$created['to'] = null;
|
||||
if(!empty($get["created"]["from"])) {
|
||||
$createstartts = makeTsFromDate($get["created"]["from"]);
|
||||
$createstartdate = array('year'=>(int)date('Y', $createstartts), 'month'=>(int)date('m', $createstartts), 'day'=>(int)date('d', $createstartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
||||
if (!checkdate($createstartdate['month'], $createstartdate['day'], $createstartdate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_create_date_end"));
|
||||
}
|
||||
$created['from'] = $createstartts;
|
||||
}
|
||||
if(!empty($get["created"]["to"])) {
|
||||
$createendts = makeTsFromDate($get["created"]["to"]);
|
||||
$createenddate = array('year'=>(int)date('Y', $createendts), 'month'=>(int)date('m', $createendts), 'day'=>(int)date('d', $createendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
||||
if (!checkdate($createenddate['month'], $createenddate['day'], $createenddate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_create_date_end"));
|
||||
}
|
||||
$created['to'] = $createendts;
|
||||
}
|
||||
$this->searchparams['created'] = $created;
|
||||
/* }}} */
|
||||
|
||||
/* Modification date {{{ */
|
||||
$modifystartts = null;
|
||||
$modifystartdate = null;
|
||||
$modifyendts = null;
|
||||
$modifyenddate = null;
|
||||
$modified['from'] = null;
|
||||
$modified['to'] = null;
|
||||
if(!empty($get["modified"]["from"])) {
|
||||
$modifystartts = makeTsFromDate($get["modified"]["from"]);
|
||||
$modifystartdate = array('year'=>(int)date('Y', $modifystartts), 'month'=>(int)date('m', $modifystartts), 'day'=>(int)date('d', $modifystartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
||||
if (!checkdate($modifystartdate['month'], $modifystartdate['day'], $modifystartdate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_modification_date_end"));
|
||||
}
|
||||
$modified['from'] = $modifystartts;
|
||||
}
|
||||
if(!empty($get["modified"]["to"])) {
|
||||
$modifyendts = makeTsFromDate($get["modified"]["to"]);
|
||||
$modifyenddate = array('year'=>(int)date('Y', $modifyendts), 'month'=>(int)date('m', $modifyendts), 'day'=>(int)date('d', $modifyendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
||||
if (!checkdate($modifyenddate['month'], $modifyenddate['day'], $modifyenddate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_modification_date_end"));
|
||||
}
|
||||
$modified['to'] = $modifyendts;
|
||||
}
|
||||
$this->searchparams['modified'] = $modified;
|
||||
/* }}} */
|
||||
|
||||
/* Filesize {{{ */
|
||||
$filesizestart = 0;
|
||||
$filesizeend = 0;
|
||||
$filesize['from'] = null;
|
||||
$filesize['to'] = null;
|
||||
if(!empty($get["filesize"]["from"])) {
|
||||
$filesizestart = $get["filesize"]["from"];
|
||||
$filesize['from'] = $get["filesize"]["from"];
|
||||
}
|
||||
if(!empty($get["filesize"]["to"])) {
|
||||
$filesizeend = $get["filesize"]["to"];
|
||||
$filesize['to'] = $get["filesize"]["to"];
|
||||
}
|
||||
$this->searchparams['filesize'] = $filesize;
|
||||
/* }}} */
|
||||
|
||||
// Check to see if the search has been restricted to a particular
|
||||
// document owner.
|
||||
// $get['owner'] can be a name of an array of names or ids {{{
|
||||
$owner = [];
|
||||
$ownernames = []; // Needed by fulltext search
|
||||
$ownerobjs = []; // Needed by database search
|
||||
if(!empty($get["owner"])) {
|
||||
$owner = $get['owner'];
|
||||
if (!is_array($get['owner'])) {
|
||||
if(is_numeric($get['owner']))
|
||||
$o = $dms->getUser($get['owner']);
|
||||
else
|
||||
$o = $dms->getUserByLogin($get['owner']);
|
||||
if($o) {
|
||||
$ownernames[] = $o->getLogin();
|
||||
$ownerobjs[] = $o;
|
||||
}
|
||||
} else {
|
||||
foreach($get["owner"] as $l) {
|
||||
if($l) {
|
||||
if(is_numeric($l))
|
||||
$o = $dms->getUser($l);
|
||||
else
|
||||
$o = $dms->getUserByLogin($l);
|
||||
if($o) {
|
||||
$ownernames[] = $o->getLogin();
|
||||
$ownerobjs[] = $o;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->searchparams['ownernames'] = $ownernames;
|
||||
$this->searchparams['ownerobjs'] = $ownerobjs;
|
||||
/* }}} */
|
||||
|
||||
// category {{{
|
||||
$categories = array();
|
||||
$categorynames = array();
|
||||
$category = array();
|
||||
if(isset($get['category']) && $get['category']) {
|
||||
$category = $get['category'];
|
||||
foreach($get['category'] as $catid) {
|
||||
if($catid) {
|
||||
if(is_numeric($catid)) {
|
||||
if($cat = $dms->getDocumentCategory($catid)) {
|
||||
$categories[] = $cat;
|
||||
$categorynames[] = $cat->getName();
|
||||
}
|
||||
} else {
|
||||
$categorynames[] = $catid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->searchparams['categorynames'] = $categorynames;
|
||||
$this->searchparams['categories'] = $categories;
|
||||
/* }}} */
|
||||
|
||||
if (isset($get["orderby"]) && is_string($get["orderby"])) {
|
||||
$orderby = $get["orderby"];
|
||||
} else {
|
||||
$orderby = "";
|
||||
}
|
||||
$this->searchparams['orderby'] = $orderby;
|
||||
|
||||
$limit = (isset($get["limit"]) && is_numeric($get["limit"])) ? (int) $get['limit'] : 20;
|
||||
$this->searchparams['limit'] = $limit;
|
||||
$fullsearch = ((!isset($get["fullsearch"]) && $this->settings->_defaultSearchMethod == 'fulltext') || !empty($get["fullsearch"])) && $this->settings->_enableFullSearch;
|
||||
$this->searchparams['fullsearch'] = $fullsearch;
|
||||
$facetsearch = !empty($get["facetsearch"]) && $this->settings->_enableFullSearch;
|
||||
$this->searchparams['facetsearch'] = $facetsearch;
|
||||
|
||||
if (isset($get["query"]) && is_string($get["query"])) {
|
||||
$query = $get["query"];
|
||||
} else {
|
||||
$query = "";
|
||||
}
|
||||
$this->searchparams['query'] = $query;
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->searchparams['mimetype'] = $mimetype;
|
||||
/* }}} */
|
||||
|
||||
// status
|
||||
$status = isset($get['status']) ? $get['status'] : array();
|
||||
$this->searchparams['status'] = $status;
|
||||
|
||||
// Get the page number to display. If the result set contains more than
|
||||
// 25 entries, it is displayed across multiple pages.
|
||||
//
|
||||
// This requires that a page number variable be used to track which page the
|
||||
// user is interested in, and an extra clause on the select statement.
|
||||
//
|
||||
// Default page to display is always one.
|
||||
$pageNumber=1;
|
||||
if (isset($get["pg"])) {
|
||||
if (is_numeric($get["pg"]) && $get["pg"]>0) {
|
||||
$pageNumber = (int) $get["pg"];
|
||||
}
|
||||
elseif (!strcasecmp($get["pg"], "all")) {
|
||||
$pageNumber = "all";
|
||||
}
|
||||
}
|
||||
$this->searchparams['pageNumber'] = $pageNumber;
|
||||
|
||||
if($fullsearch) {
|
||||
// Search in Fulltext {{{
|
||||
|
||||
// record_type
|
||||
if(isset($get['record_type']))
|
||||
$record_type = $get['record_type'];
|
||||
else
|
||||
$record_type = array();
|
||||
$this->searchparams['record_type'] = $record_type;
|
||||
|
||||
if (isset($get["attributes"]))
|
||||
$attributes = $get["attributes"];
|
||||
else
|
||||
$attributes = array();
|
||||
|
||||
foreach($attributes as $an=>&$av) {
|
||||
if(substr($an, 0, 5) == 'attr_') {
|
||||
$tmp = explode('_', $an);
|
||||
if($attrdef = $dms->getAttributeDefinition($tmp[1])) {
|
||||
switch($attrdef->getType()) {
|
||||
/* Turn dates into timestamps */
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
foreach(['from', 'to'] as $kk)
|
||||
if(!empty($av[$kk])) {
|
||||
if(!is_numeric($av[$kk])) {
|
||||
$av[$kk] = makeTsFromDate($av[$kk]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->searchparams['attributes'] = $attributes;
|
||||
|
||||
/* Create $order array for fulltext search */
|
||||
$order = ['by'=>'', 'dir'=>''];
|
||||
switch($orderby) {
|
||||
case 'dd':
|
||||
$order = ['by'=>'created', 'dir'=>'desc'];
|
||||
break;
|
||||
case 'd':
|
||||
$order = ['by'=>'created', 'dir'=>'asc'];
|
||||
break;
|
||||
case 'nd':
|
||||
$order = ['by'=>'title', 'dir'=>'desc'];
|
||||
break;
|
||||
case 'n':
|
||||
$order = ['by'=>'title', 'dir'=>'asc'];
|
||||
break;
|
||||
case 'id':
|
||||
$order = ['by'=>'id', 'dir'=>'desc'];
|
||||
break;
|
||||
case 'i':
|
||||
$order = ['by'=>'id', 'dir'=>'asc'];
|
||||
break;
|
||||
default:
|
||||
$order = ['by'=>'', 'dir'=>''];
|
||||
}
|
||||
$this->searchparams['order'] = $order;
|
||||
|
||||
// Check to see if the search has been restricted to a particular sub-tree in
|
||||
// the folder hierarchy.
|
||||
$startFolder = null;
|
||||
if (isset($get["folderfullsearchid"]) && is_numeric($get["folderfullsearchid"]) && $get["folderfullsearchid"]>0) {
|
||||
$targetid = $get["folderfullsearchid"];
|
||||
$startFolder = $this->dms->getFolder($targetid);
|
||||
if (!is_object($startFolder)) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_folder_id"));
|
||||
}
|
||||
}
|
||||
$this->searchparams['startFolder'] = $startFolder;
|
||||
|
||||
$rootFolder = $this->dms->getFolder($this->settings->_rootFolderID);
|
||||
$this->searchparams['rootFolder'] = $rootFolder;
|
||||
|
||||
// }}}
|
||||
} else {
|
||||
// Search in Database {{{
|
||||
|
||||
/* Select if only documents (0x01), only folders (0x02) or both (0x03)
|
||||
* are found
|
||||
*/
|
||||
$resultmode = 0x03;
|
||||
if (isset($get["resultmode"]) && is_numeric($get["resultmode"])) {
|
||||
$resultmode = $get['resultmode'];
|
||||
}
|
||||
$this->searchparams['resultmode'] = $resultmode;
|
||||
|
||||
$mode = "AND";
|
||||
if (isset($get["mode"]) && is_numeric($get["mode"]) && $get["mode"]==0) {
|
||||
$mode = "OR";
|
||||
}
|
||||
$this->searchparams['mode'] = $mode;
|
||||
|
||||
$searchin = array();
|
||||
if (isset($get['searchin']) && is_array($get["searchin"])) {
|
||||
foreach ($get["searchin"] as $si) {
|
||||
if (isset($si) && is_numeric($si)) {
|
||||
switch ($si) {
|
||||
case 1: // keywords
|
||||
case 2: // name
|
||||
case 3: // comment
|
||||
case 4: // attributes
|
||||
case 5: // id
|
||||
$searchin[$si] = $si;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if none is checkd search all
|
||||
if (count($searchin)==0) $searchin=array(1, 2, 3, 4, 5);
|
||||
$this->searchparams['searchin'] = $searchin;
|
||||
|
||||
// Check to see if the search has been restricted to a particular sub-tree in
|
||||
// the folder hierarchy.
|
||||
if (isset($get["targetid"]) && is_numeric($get["targetid"]) && $get["targetid"]>0) {
|
||||
$targetid = $get["targetid"];
|
||||
$startFolder = $this->dms->getFolder($targetid);
|
||||
}
|
||||
else {
|
||||
$startFolder = $this->dms->getRootFolder();
|
||||
}
|
||||
if (!is_object($startFolder)) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_folder_id"));
|
||||
}
|
||||
$this->searchparams['startFolder'] = $startFolder;
|
||||
|
||||
/* Revision date {{{ */
|
||||
$revisionstartts = null;
|
||||
$revisionstartdate = array();
|
||||
$revisionendts = null;
|
||||
$revisionenddate = array();
|
||||
$revised['from'] = null;
|
||||
$revised['to'] = null;
|
||||
if(!empty($get["revisiondatestart"])) {
|
||||
$revisionstartts = makeTsFromDate($get["revisiondatestart"]);
|
||||
$revisionstartdate = array('year'=>(int)date('Y', $revisionstartts), 'month'=>(int)date('m', $revisionstartts), 'day'=>(int)date('d', $revisionstartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
||||
if (!checkdate($revisionstartdate['month'], $revisionstartdate['day'], $revisionstartdate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_revision_date_start"));
|
||||
}
|
||||
$revised['from'] = $revisionstartts;
|
||||
}
|
||||
if(!empty($get["revisiondateend"])) {
|
||||
$revisionendts = makeTsFromDate($get["revisiondateend"]);
|
||||
$revisionenddate = array('year'=>(int)date('Y', $revisionendts), 'month'=>(int)date('m', $revisionendts), 'day'=>(int)date('d', $revisionendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
||||
if (!checkdate($revisionenddate['month'], $revisionenddate['day'], $revisionenddate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_revision_date_end"));
|
||||
}
|
||||
$revised['to'] = $revisionendts;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* Status date {{{ */
|
||||
$statusstartdate = array();
|
||||
$statusenddate = array();
|
||||
if(!empty($get["statusdatestart"])) {
|
||||
$statusstartts = makeTsFromDate($get["statusdatestart"]);
|
||||
$statusstartdate = array('year'=>(int)date('Y', $statusstartts), 'month'=>(int)date('m', $statusstartts), 'day'=>(int)date('d', $statusstartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
||||
}
|
||||
$this->searchparams['statusstartdate'] = $statusstartdate;
|
||||
if ($statusstartdate && !checkdate($statusstartdate['month'], $statusstartdate['day'], $statusstartdate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_status_date_start"));
|
||||
}
|
||||
|
||||
if(!empty($get["statusdateend"])) {
|
||||
$statusendts = makeTsFromDate($get["statusdateend"]);
|
||||
$statusenddate = array('year'=>(int)date('Y', $statusendts), 'month'=>(int)date('m', $statusendts), 'day'=>(int)date('d', $statusendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
||||
}
|
||||
if ($statusenddate && !checkdate($statusenddate['month'], $statusenddate['day'], $statusenddate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_status_date_end"));
|
||||
}
|
||||
$this->searchparams['statusenddate'] = $statusenddate;
|
||||
/* }}} */
|
||||
|
||||
/* Expiration date {{{ */
|
||||
$expstartdate = array();
|
||||
$expenddate = array();
|
||||
if(!empty($get["expirationstart"])) {
|
||||
$expstartts = makeTsFromDate($get["expirationstart"]);
|
||||
$expstartdate = array('year'=>(int)date('Y', $expstartts), 'month'=>(int)date('m', $expstartts), 'day'=>(int)date('d', $expstartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
||||
if (!checkdate($expstartdate['month'], $expstartdate['day'], $expstartdate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_expiration_date_start"));
|
||||
}
|
||||
}
|
||||
if(!empty($get["expirationend"])) {
|
||||
$expendts = makeTsFromDate($get["expirationend"]);
|
||||
$expenddate = array('year'=>(int)date('Y', $expendts), 'month'=>(int)date('m', $expendts), 'day'=>(int)date('d', $expendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
||||
if (!checkdate($expenddate['month'], $expenddate['day'], $expenddate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_expiration_date_end"));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
$reception = array();
|
||||
if (isset($get["reception"])){
|
||||
$reception = $get["reception"];
|
||||
}
|
||||
|
||||
/* Do not search for folders if result shall be filtered by status.
|
||||
* If this is not done, unexplainable results will be delivered.
|
||||
* e.g. a search for expired documents of a given user will list
|
||||
* also all folders of that user because the status doesn't apply
|
||||
* to folders.
|
||||
*/
|
||||
// if($status)
|
||||
// $resultmode = 0x01;
|
||||
|
||||
if (isset($get["attributes"]))
|
||||
$attributes = $get["attributes"];
|
||||
else
|
||||
$attributes = array();
|
||||
|
||||
foreach($attributes as $attrdefid=>$attribute) {
|
||||
$attrdef = $this->dms->getAttributeDefinition($attrdefid);
|
||||
if($attribute) {
|
||||
if($attrdef->getType() == SeedDMS_Core_AttributeDefinition::type_date) {
|
||||
if(is_array($attribute)) {
|
||||
if(!empty($attributes[$attrdefid]['from']))
|
||||
$attributes[$attrdefid]['from'] = date('Y-m-d', makeTsFromDate($attribute['from']));
|
||||
if(!empty($attributes[$attrdefid]['to']))
|
||||
$attributes[$attrdefid]['to'] = date('Y-m-d', makeTsFromDate($attribute['to']));
|
||||
} else {
|
||||
$attributes[$attrdefid] = date('Y-m-d', makeTsFromDate($attribute));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->searchparams['attributes'] = $attributes;
|
||||
|
||||
// }}}
|
||||
}
|
||||
return $this->searchparams;
|
||||
} /* }}} */
|
||||
|
||||
public function setSearchParam($name, $value) {
|
||||
$this->searchparams[$name] = $value;
|
||||
}
|
||||
|
||||
public function search() { /* {{{ */
|
||||
if($this->searchparams['fullsearch']) {
|
||||
if($this->settings->_fullSearchEngine == 'lucene') {
|
||||
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
|
||||
}
|
||||
|
||||
$startTime = $this->getTime();
|
||||
$total = 0;
|
||||
$index = $this->fulltextservice->Indexer();
|
||||
if($index) {
|
||||
if(!empty($this->settings->_suggestTerms) && !empty($get['query'])) {
|
||||
$st = preg_split("/[\s,]+/", trim($get['query']));
|
||||
if($lastterm = end($st))
|
||||
$this->terms = $index->terms($lastterm, $this->settings->_suggestTerms);
|
||||
}
|
||||
$limit = $this->searchparams['limit'];
|
||||
$lucenesearch = $this->fulltextservice->Search();
|
||||
$searchresult = $lucenesearch->search($this->searchparams['query'],
|
||||
array(
|
||||
'record_type'=>$this->searchparams['record_type'],
|
||||
'owner'=>$this->searchparams['ownernames'],
|
||||
'status'=>$this->searchparams['status'],
|
||||
'category'=>$this->searchparams['categorynames'],
|
||||
'user'=>$this->user->isAdmin() ? [] : [$this->user->getLogin()],
|
||||
'mimetype'=>$this->searchparams['mimetype'],
|
||||
'startFolder'=>$this->searchparams['startFolder'],
|
||||
'rootFolder'=>$this->searchparams['rootFolder'],
|
||||
'created_start'=>$this->searchparams['created']['from'],
|
||||
'created_end'=>$this->searchparams['created']['to'],
|
||||
'modified_start'=>$this->searchparams['modified']['from'],
|
||||
'modified_end'=>$this->searchparams['modified']['to'],
|
||||
'filesize_start'=>$this->searchparams['filesize']['from'],
|
||||
'filesize_end'=>$this->searchparams['filesize']['to'],
|
||||
'attributes'=>$this->searchparams['attributes']
|
||||
), ($this->searchparams['pageNumber'] == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($this->searchparams['pageNumber']-1))), $this->searchparams['order']);
|
||||
if($searchresult !== false) {
|
||||
$entries = array();
|
||||
$facets = $searchresult['facets'];
|
||||
$stats = $searchresult['stats'] ?? null;
|
||||
$dcount = 0;
|
||||
$fcount = 0;
|
||||
if($searchresult['hits']) {
|
||||
foreach($searchresult['hits'] as $hit) {
|
||||
if($hit['document_id'][0] == 'D') {
|
||||
if($tmp = $this->dms->getDocument(substr($hit['document_id'], 1))) {
|
||||
// if($tmp->getAccessMode($user) >= M_READ) {
|
||||
$tmp->verifyLastestContentExpriry();
|
||||
$entries[] = $tmp;
|
||||
$dcount++;
|
||||
// }
|
||||
}
|
||||
} elseif($hit['document_id'][0] == 'F') {
|
||||
if($tmp = $this->dms->getFolder(substr($hit['document_id'], 1))) {
|
||||
// if($tmp->getAccessMode($user) >= M_READ) {
|
||||
$entries[] = $tmp;
|
||||
$fcount++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($facets['record_type'])) {
|
||||
$fcount = isset($facets['record_type']['folder']) ? $facets['record_type']['folder'] : 0;
|
||||
$dcount = isset($facets['record_type']['document']) ? $facets['record_type']['document'] : 0 ;
|
||||
}
|
||||
}
|
||||
$this->fcount = $fcount;
|
||||
$this->dcount = $dcount;
|
||||
$this->stats = $stats;
|
||||
$this->entries = $entries;
|
||||
$this->facets = $facets;
|
||||
$totalPages = 0;
|
||||
if($limit > 0) {
|
||||
if($searchresult['count'] > $limit) {
|
||||
$totalPages = (int) ($searchresult['count']/$limit);
|
||||
if($searchresult['count']%$limit)
|
||||
$totalPages++;
|
||||
} else {
|
||||
$totalPages = 1;
|
||||
}
|
||||
}
|
||||
$this->total = $searchresult['count'];
|
||||
$this->totalPages = $totalPages;
|
||||
}
|
||||
$searchTime = $this->getTime() - $startTime;
|
||||
$this->searchTime = round($searchTime, 2);
|
||||
}
|
||||
} else {
|
||||
// ---------------- Start searching -----------------------------------------
|
||||
$startTime = $this->getTime();
|
||||
$resArr = $this->dms->search(array(
|
||||
'query'=>$query,
|
||||
'limit'=>0,
|
||||
'offset'=>0,
|
||||
'logicalmode'=>$mode,
|
||||
'searchin'=>$searchin,
|
||||
'startFolder'=>$startFolder,
|
||||
'owner'=>$ownerobjs,
|
||||
'status'=>$status,
|
||||
'mimetype'=>$mimetype,
|
||||
'creationstartdate'=>$created['from'],
|
||||
'creationenddate'=>$created['to'],
|
||||
'modificationstartdate'=>$modified['from'],
|
||||
'modificationenddate'=>$modified['to'],
|
||||
'filesizestart'=>$filesize['from'],
|
||||
'filesizeend'=>$filesize['to'],
|
||||
'categories'=>$categories,
|
||||
'attributes'=>$attributes,
|
||||
'mode'=>$resultmode,
|
||||
'expirationstartdate'=>$expstartdate ? $expstartdate : array(),
|
||||
'expirationenddate'=>$expenddate ? $expenddate : array(),
|
||||
'revisionstartdate'=>$revisionstartdate ? $revisionstartdate : array(),
|
||||
'revisionenddate'=>$revisionenddate ? $revisionenddate : array(),
|
||||
'reception'=>$reception,
|
||||
'statusstartdate'=>$statusstartdate ? $statusstartdate : array(),
|
||||
'statusenddate'=>$statusenddate ? $statusenddate : array(),
|
||||
'orderby'=>$orderby
|
||||
));
|
||||
$this->total = $resArr['totalDocs'] + $resArr['totalFolders'];
|
||||
$searchTime = $this->getTime() - $startTime;
|
||||
$this->searchTime = round($searchTime, 2);
|
||||
|
||||
$entries = array();
|
||||
$fcount = 0;
|
||||
if($resArr['folders']) {
|
||||
foreach ($resArr['folders'] as $entry) {
|
||||
if ($entry->getAccessMode($user) >= M_READ) {
|
||||
$entries[] = $entry;
|
||||
$fcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->fcount = $fcount;
|
||||
$dcount = 0;
|
||||
if($resArr['docs']) {
|
||||
foreach ($resArr['docs'] as $entry) {
|
||||
if ($entry->getAccessMode($user) >= M_READ) {
|
||||
if($entry->getLatestContent()) {
|
||||
$entry->verifyLastestContentExpriry();
|
||||
$entries[] = $entry;
|
||||
$dcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->dcount = $dcount;
|
||||
$totalPages = (int) (count($entries)/$limit);
|
||||
if(count($entries)%$limit)
|
||||
$totalPages++;
|
||||
if($pageNumber != 'all')
|
||||
$this->entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
|
||||
$this->totalPages = $totalPages;
|
||||
$this->facets = array();
|
||||
$this->stats = array();
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
public function getFolderCount() {
|
||||
return $this->fcount;
|
||||
}
|
||||
|
||||
public function getDocumentCount() {
|
||||
return $this->dcount;
|
||||
}
|
||||
|
||||
public function getTotal() {
|
||||
return $this->total;
|
||||
}
|
||||
} /* }}} */
|
||||
|
|
|
@ -29,55 +29,57 @@ require_once("inc/inc.DBInit.php");
|
|||
require_once("inc/inc.ClassUI.php");
|
||||
require_once("inc/inc.Authentication.php");
|
||||
|
||||
function getTime() {
|
||||
function getTime() { /* {{{ */
|
||||
if (function_exists('microtime')) {
|
||||
$tm = microtime();
|
||||
$tm = explode(' ', $tm);
|
||||
return (float) sprintf('%f', $tm[1] + $tm[0]);
|
||||
}
|
||||
return time();
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
$get = $_GET;
|
||||
|
||||
// Redirect to the search page if the navigation search button has been
|
||||
// selected without supplying any search terms.
|
||||
if (isset($_GET["navBar"])) {
|
||||
if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {
|
||||
if (isset($get["navBar"])) {
|
||||
if (!isset($get["folderid"]) || !is_numeric($get["folderid"]) || intval($get["folderid"])<1) {
|
||||
$folderid=$settings->_rootFolderID;
|
||||
} else {
|
||||
$folderid = $_GET["folderid"];
|
||||
$folderid = $get["folderid"];
|
||||
}
|
||||
}
|
||||
|
||||
$includecontent = false;
|
||||
if (isset($_GET["includecontent"]) && $_GET["includecontent"])
|
||||
if (isset($get["includecontent"]) && $get["includecontent"])
|
||||
$includecontent = true;
|
||||
|
||||
$skipdefaultcols = false;
|
||||
if (isset($_GET["skipdefaultcols"]) && $_GET["skipdefaultcols"])
|
||||
if (isset($get["skipdefaultcols"]) && $get["skipdefaultcols"])
|
||||
$skipdefaultcols = true;
|
||||
|
||||
$newowner = null;
|
||||
if (isset($_GET["newowner"]) && is_numeric($_GET["newowner"]) && $_GET['newowner'] > 0) {
|
||||
$newowner = $dms->getUser((int) $_GET['newowner']);
|
||||
if (isset($get["newowner"]) && is_numeric($get["newowner"]) && $get['newowner'] > 0) {
|
||||
$newowner = $dms->getUser((int) $get['newowner']);
|
||||
}
|
||||
|
||||
$newreviewer = null;
|
||||
if (isset($_GET["newreviewer"]) && is_numeric($_GET["newreviewer"]) && $_GET['newreviewer'] > 0) {
|
||||
$newreviewer = $dms->getUser((int) $_GET['newreviewer']);
|
||||
if (isset($get["newreviewer"]) && is_numeric($get["newreviewer"]) && $get['newreviewer'] > 0) {
|
||||
$newreviewer = $dms->getUser((int) $get['newreviewer']);
|
||||
}
|
||||
|
||||
$newapprover = null;
|
||||
if (isset($_GET["newapprover"]) && is_numeric($_GET["newapprover"]) && $_GET['newapprover'] > 0) {
|
||||
$newapprover = $dms->getUser((int) $_GET['newapprover']);
|
||||
if (isset($get["newapprover"]) && is_numeric($get["newapprover"]) && $get['newapprover'] > 0) {
|
||||
$newapprover = $dms->getUser((int) $get['newapprover']);
|
||||
}
|
||||
|
||||
$changecategory = null;
|
||||
if (isset($_GET["changecategory"]) && is_numeric($_GET["changecategory"]) && $_GET['changecategory'] > 0) {
|
||||
$changecategory = $dms->getDocumentCategory((int) $_GET['changecategory']);
|
||||
if (isset($get["changecategory"]) && is_numeric($get["changecategory"]) && $get['changecategory'] > 0) {
|
||||
$changecategory = $dms->getDocumentCategory((int) $get['changecategory']);
|
||||
}
|
||||
$removecategory = 0;
|
||||
if (isset($_GET["removecategory"]) && is_numeric($_GET["removecategory"]) && $_GET['removecategory'] > 0) {
|
||||
$removecategory = (int) $_GET['removecategory'];
|
||||
if (isset($get["removecategory"]) && is_numeric($get["removecategory"]) && $get['removecategory'] > 0) {
|
||||
$removecategory = (int) $get['removecategory'];
|
||||
}
|
||||
|
||||
/* Creation date {{{ */
|
||||
|
@ -87,16 +89,16 @@ $createendts = null;
|
|||
$createenddate = null;
|
||||
$created['from'] = null;
|
||||
$created['to'] = null;
|
||||
if(!empty($_GET["created"]["from"])) {
|
||||
$createstartts = makeTsFromDate($_GET["created"]["from"]);
|
||||
if(!empty($get["created"]["from"])) {
|
||||
$createstartts = makeTsFromDate($get["created"]["from"]);
|
||||
$createstartdate = array('year'=>(int)date('Y', $createstartts), 'month'=>(int)date('m', $createstartts), 'day'=>(int)date('d', $createstartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
||||
if (!checkdate($createstartdate['month'], $createstartdate['day'], $createstartdate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_create_date_end"));
|
||||
}
|
||||
$created['from'] = $createstartts;
|
||||
}
|
||||
if(!empty($_GET["created"]["to"])) {
|
||||
$createendts = makeTsFromDate($_GET["created"]["to"]);
|
||||
if(!empty($get["created"]["to"])) {
|
||||
$createendts = makeTsFromDate($get["created"]["to"]);
|
||||
$createenddate = array('year'=>(int)date('Y', $createendts), 'month'=>(int)date('m', $createendts), 'day'=>(int)date('d', $createendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
||||
if (!checkdate($createenddate['month'], $createenddate['day'], $createenddate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_create_date_end"));
|
||||
|
@ -112,16 +114,16 @@ $modifyendts = null;
|
|||
$modifyenddate = null;
|
||||
$modified['from'] = null;
|
||||
$modified['to'] = null;
|
||||
if(!empty($_GET["modified"]["from"])) {
|
||||
$modifystartts = makeTsFromDate($_GET["modified"]["from"]);
|
||||
if(!empty($get["modified"]["from"])) {
|
||||
$modifystartts = makeTsFromDate($get["modified"]["from"]);
|
||||
$modifystartdate = array('year'=>(int)date('Y', $modifystartts), 'month'=>(int)date('m', $modifystartts), 'day'=>(int)date('d', $modifystartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
||||
if (!checkdate($modifystartdate['month'], $modifystartdate['day'], $modifystartdate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_modification_date_end"));
|
||||
}
|
||||
$modified['from'] = $modifystartts;
|
||||
}
|
||||
if(!empty($_GET["modified"]["to"])) {
|
||||
$modifyendts = makeTsFromDate($_GET["modified"]["to"]);
|
||||
if(!empty($get["modified"]["to"])) {
|
||||
$modifyendts = makeTsFromDate($get["modified"]["to"]);
|
||||
$modifyenddate = array('year'=>(int)date('Y', $modifyendts), 'month'=>(int)date('m', $modifyendts), 'day'=>(int)date('d', $modifyendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
||||
if (!checkdate($modifyenddate['month'], $modifyenddate['day'], $modifyenddate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_modification_date_end"));
|
||||
|
@ -135,35 +137,35 @@ $filesizestart = 0;
|
|||
$filesizeend = 0;
|
||||
$filesize['from'] = null;
|
||||
$filesize['to'] = null;
|
||||
if(!empty($_GET["filesize"]["from"])) {
|
||||
$filesizestart = $_GET["filesize"]["from"];
|
||||
$filesize['from'] = $_GET["filesize"]["from"];
|
||||
if(!empty($get["filesize"]["from"])) {
|
||||
$filesizestart = $get["filesize"]["from"];
|
||||
$filesize['from'] = $get["filesize"]["from"];
|
||||
}
|
||||
if(!empty($_GET["filesize"]["to"])) {
|
||||
$filesizeend = $_GET["filesize"]["to"];
|
||||
$filesize['to'] = $_GET["filesize"]["to"];
|
||||
if(!empty($get["filesize"]["to"])) {
|
||||
$filesizeend = $get["filesize"]["to"];
|
||||
$filesize['to'] = $get["filesize"]["to"];
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
// Check to see if the search has been restricted to a particular
|
||||
// document owner.
|
||||
// $_GET['owner'] can be a name of an array of names or ids {{{
|
||||
// $get['owner'] can be a name of an array of names or ids {{{
|
||||
$owner = [];
|
||||
$ownernames = []; // Needed by fulltext search
|
||||
$ownerobjs = []; // Needed by database search
|
||||
if(!empty($_GET["owner"])) {
|
||||
$owner = $_GET['owner'];
|
||||
if (!is_array($_GET['owner'])) {
|
||||
if(is_numeric($_GET['owner']))
|
||||
$o = $dms->getUser($_GET['owner']);
|
||||
if(!empty($get["owner"])) {
|
||||
$owner = $get['owner'];
|
||||
if (!is_array($get['owner'])) {
|
||||
if(is_numeric($get['owner']))
|
||||
$o = $dms->getUser($get['owner']);
|
||||
else
|
||||
$o = $dms->getUserByLogin($_GET['owner']);
|
||||
$o = $dms->getUserByLogin($get['owner']);
|
||||
if($o) {
|
||||
$ownernames[] = $o->getLogin();
|
||||
$ownerobjs[] = $o;
|
||||
}
|
||||
} else {
|
||||
foreach($_GET["owner"] as $l) {
|
||||
foreach($get["owner"] as $l) {
|
||||
if($l) {
|
||||
if(is_numeric($l))
|
||||
$o = $dms->getUser($l);
|
||||
|
@ -178,40 +180,39 @@ if(!empty($_GET["owner"])) {
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
// category {{{
|
||||
$categories = array();
|
||||
$categorynames = array();
|
||||
$category = array();
|
||||
if(isset($_GET['category']) && $_GET['category']) {
|
||||
$category = $_GET['category'];
|
||||
foreach($_GET['category'] as $catid) {
|
||||
if($catid) {
|
||||
if(is_numeric($catid)) {
|
||||
if($cat = $dms->getDocumentCategory($catid)) {
|
||||
$categories[] = $cat;
|
||||
$categorynames[] = $cat->getName();
|
||||
}
|
||||
} else {
|
||||
$categorynames[] = $catid;
|
||||
// category {{{
|
||||
$categories = array();
|
||||
$categorynames = array();
|
||||
$category = array();
|
||||
if(isset($get['category']) && $get['category']) {
|
||||
$category = $get['category'];
|
||||
foreach($get['category'] as $catid) {
|
||||
if($catid) {
|
||||
if(is_numeric($catid)) {
|
||||
if($cat = $dms->getDocumentCategory($catid)) {
|
||||
$categories[] = $cat;
|
||||
$categorynames[] = $cat->getName();
|
||||
}
|
||||
} else {
|
||||
$categorynames[] = $catid;
|
||||
}
|
||||
}
|
||||
} /* }}} */
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
if (isset($_GET["orderby"]) && is_string($_GET["orderby"])) {
|
||||
$orderby = $_GET["orderby"];
|
||||
}
|
||||
else {
|
||||
$orderby = "";
|
||||
}
|
||||
if (isset($get["orderby"]) && is_string($get["orderby"])) {
|
||||
$orderby = $get["orderby"];
|
||||
} else {
|
||||
$orderby = "";
|
||||
}
|
||||
|
||||
$terms = [];
|
||||
$limit = (isset($_GET["limit"]) && is_numeric($_GET["limit"])) ? (int) $_GET['limit'] : 20;
|
||||
$fullsearch = ((!isset($_GET["fullsearch"]) && $settings->_defaultSearchMethod == 'fulltext') || !empty($_GET["fullsearch"])) && $settings->_enableFullSearch;
|
||||
$facetsearch = !empty($_GET["facetsearch"]) && $settings->_enableFullSearch;
|
||||
$limit = (isset($get["limit"]) && is_numeric($get["limit"])) ? (int) $get['limit'] : 20;
|
||||
$fullsearch = ((!isset($get["fullsearch"]) && $settings->_defaultSearchMethod == 'fulltext') || !empty($get["fullsearch"])) && $settings->_enableFullSearch;
|
||||
$facetsearch = !empty($get["facetsearch"]) && $settings->_enableFullSearch;
|
||||
|
||||
if (isset($_GET["query"]) && is_string($_GET["query"])) {
|
||||
$query = $_GET["query"];
|
||||
if (isset($get["query"]) && is_string($get["query"])) {
|
||||
$query = $get["query"];
|
||||
} else {
|
||||
$query = "";
|
||||
}
|
||||
|
@ -219,12 +220,12 @@ if (isset($_GET["query"]) && is_string($_GET["query"])) {
|
|||
// 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'];
|
||||
if (isset($get["mimetype"])) {
|
||||
if (!is_array($get['mimetype'])) {
|
||||
if(!empty($get['mimetype']))
|
||||
$mimetype[] = $get['mimetype'];
|
||||
} else {
|
||||
foreach($_GET["mimetype"] as $l) {
|
||||
foreach($get["mimetype"] as $l) {
|
||||
if($l)
|
||||
$mimetype[] = $l;
|
||||
}
|
||||
|
@ -232,7 +233,7 @@ if (isset($_GET["mimetype"])) {
|
|||
} /* }}} */
|
||||
|
||||
// status
|
||||
$status = isset($_GET['status']) ? $_GET['status'] : array();
|
||||
$status = isset($get['status']) ? $get['status'] : array();
|
||||
|
||||
// Get the page number to display. If the result set contains more than
|
||||
// 25 entries, it is displayed across multiple pages.
|
||||
|
@ -242,11 +243,11 @@ $status = isset($_GET['status']) ? $_GET['status'] : array();
|
|||
//
|
||||
// Default page to display is always one.
|
||||
$pageNumber=1;
|
||||
if (isset($_GET["pg"])) {
|
||||
if (is_numeric($_GET["pg"]) && $_GET["pg"]>0) {
|
||||
$pageNumber = (int) $_GET["pg"];
|
||||
if (isset($get["pg"])) {
|
||||
if (is_numeric($get["pg"]) && $get["pg"]>0) {
|
||||
$pageNumber = (int) $get["pg"];
|
||||
}
|
||||
elseif (!strcasecmp($_GET["pg"], "all")) {
|
||||
elseif (!strcasecmp($get["pg"], "all")) {
|
||||
$pageNumber = "all";
|
||||
}
|
||||
}
|
||||
|
@ -255,13 +256,13 @@ if($fullsearch) {
|
|||
// Search in Fulltext {{{
|
||||
|
||||
// record_type
|
||||
if(isset($_GET['record_type']))
|
||||
$record_type = $_GET['record_type'];
|
||||
if(isset($get['record_type']))
|
||||
$record_type = $get['record_type'];
|
||||
else
|
||||
$record_type = array();
|
||||
|
||||
if (isset($_GET["attributes"]))
|
||||
$attributes = $_GET["attributes"];
|
||||
if (isset($get["attributes"]))
|
||||
$attributes = $get["attributes"];
|
||||
else
|
||||
$attributes = array();
|
||||
|
||||
|
@ -313,8 +314,8 @@ if($fullsearch) {
|
|||
// Check to see if the search has been restricted to a particular sub-tree in
|
||||
// the folder hierarchy.
|
||||
$startFolder = null;
|
||||
if (isset($_GET["folderfullsearchid"]) && is_numeric($_GET["folderfullsearchid"]) && $_GET["folderfullsearchid"]>0) {
|
||||
$targetid = $_GET["folderfullsearchid"];
|
||||
if (isset($get["folderfullsearchid"]) && is_numeric($get["folderfullsearchid"]) && $get["folderfullsearchid"]>0) {
|
||||
$targetid = $get["folderfullsearchid"];
|
||||
$startFolder = $dms->getFolder($targetid);
|
||||
if (!is_object($startFolder)) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_folder_id"));
|
||||
|
@ -323,7 +324,6 @@ if($fullsearch) {
|
|||
|
||||
$rootFolder = $dms->getFolder($settings->_rootFolderID);
|
||||
|
||||
$startTime = getTime();
|
||||
if($settings->_fullSearchEngine == 'lucene') {
|
||||
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
|
||||
}
|
||||
|
@ -331,6 +331,7 @@ if($fullsearch) {
|
|||
if(strlen($query) < 4 && strpos($query, '*')) {
|
||||
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
|
||||
$dcount = 0;
|
||||
$fcount = 0;
|
||||
$totalPages = 0;
|
||||
$entries = array();
|
||||
$searchTime = 0;
|
||||
|
@ -340,13 +341,30 @@ if($fullsearch) {
|
|||
$total = 0;
|
||||
$index = $fulltextservice->Indexer();
|
||||
if($index) {
|
||||
if(!empty($settings->_suggestTerms) && !empty($_GET['query'])) {
|
||||
$st = preg_split("/[\s,]+/", trim($_GET['query']));
|
||||
if(!empty($settings->_suggestTerms) && !empty($get['query'])) {
|
||||
$st = preg_split("/[\s,]+/", trim($get['query']));
|
||||
if($lastterm = end($st))
|
||||
$terms = $index->terms($lastterm, $settings->_suggestTerms);
|
||||
}
|
||||
$lucenesearch = $fulltextservice->Search();
|
||||
$searchresult = $lucenesearch->search($query, array('record_type'=>$record_type, 'owner'=>$ownernames, 'status'=>$status, 'category'=>$categorynames, 'user'=>$user->isAdmin() ? [] : [$user->getLogin()], 'mimetype'=>$mimetype, 'startFolder'=>$startFolder, 'rootFolder'=>$rootFolder, 'created_start'=>$createstartts, 'created_end'=>$createendts, 'modified_start'=>$modifystartts, 'modified_end'=>$modifyendts, 'filesize_start'=>$filesizestart, 'filesize_end'=>$filesizeend, 'attributes'=>$attributes), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1))), $order);
|
||||
$searchresult = $lucenesearch->search($query,
|
||||
array(
|
||||
'record_type'=>$record_type,
|
||||
'owner'=>$ownernames,
|
||||
'status'=>$status,
|
||||
'category'=>$categorynames,
|
||||
'user'=>$user->isAdmin() ? [] : [$user->getLogin()],
|
||||
'mimetype'=>$mimetype,
|
||||
'startFolder'=>$startFolder,
|
||||
'rootFolder'=>$rootFolder,
|
||||
'created_start'=>$created['from'],
|
||||
'created_end'=>$created['to'],
|
||||
'modified_start'=>$modified['from'],
|
||||
'modified_end'=>$modified['to'],
|
||||
'filesize_start'=>$filesize['from'],
|
||||
'filesize_end'=>$filesize['to'],
|
||||
'attributes'=>$attributes
|
||||
), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1))), $order);
|
||||
if($searchresult === false) {
|
||||
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
|
||||
$dcount = 0;
|
||||
|
@ -419,18 +437,18 @@ if($fullsearch) {
|
|||
* are found
|
||||
*/
|
||||
$resultmode = 0x03;
|
||||
if (isset($_GET["resultmode"]) && is_numeric($_GET["resultmode"])) {
|
||||
$resultmode = $_GET['resultmode'];
|
||||
if (isset($get["resultmode"]) && is_numeric($get["resultmode"])) {
|
||||
$resultmode = $get['resultmode'];
|
||||
}
|
||||
|
||||
$mode = "AND";
|
||||
if (isset($_GET["mode"]) && is_numeric($_GET["mode"]) && $_GET["mode"]==0) {
|
||||
if (isset($get["mode"]) && is_numeric($get["mode"]) && $get["mode"]==0) {
|
||||
$mode = "OR";
|
||||
}
|
||||
|
||||
$searchin = array();
|
||||
if (isset($_GET['searchin']) && is_array($_GET["searchin"])) {
|
||||
foreach ($_GET["searchin"] as $si) {
|
||||
if (isset($get['searchin']) && is_array($get["searchin"])) {
|
||||
foreach ($get["searchin"] as $si) {
|
||||
if (isset($si) && is_numeric($si)) {
|
||||
switch ($si) {
|
||||
case 1: // keywords
|
||||
|
@ -450,8 +468,8 @@ if($fullsearch) {
|
|||
|
||||
// Check to see if the search has been restricted to a particular sub-tree in
|
||||
// the folder hierarchy.
|
||||
if (isset($_GET["targetid"]) && is_numeric($_GET["targetid"]) && $_GET["targetid"]>0) {
|
||||
$targetid = $_GET["targetid"];
|
||||
if (isset($get["targetid"]) && is_numeric($get["targetid"]) && $get["targetid"]>0) {
|
||||
$targetid = $get["targetid"];
|
||||
$startFolder = $dms->getFolder($targetid);
|
||||
}
|
||||
else {
|
||||
|
@ -462,36 +480,42 @@ if($fullsearch) {
|
|||
}
|
||||
|
||||
/* Revision date {{{ */
|
||||
$revisionstartts = null;
|
||||
$revisionstartdate = array();
|
||||
$revisionendts = null;
|
||||
$revisionenddate = array();
|
||||
if(!empty($_GET["revisiondatestart"])) {
|
||||
$revisionstartts = makeTsFromDate($_GET["revisiondatestart"]);
|
||||
$revised['from'] = null;
|
||||
$revised['to'] = null;
|
||||
if(!empty($get["revisiondatestart"])) {
|
||||
$revisionstartts = makeTsFromDate($get["revisiondatestart"]);
|
||||
$revisionstartdate = array('year'=>(int)date('Y', $revisionstartts), 'month'=>(int)date('m', $revisionstartts), 'day'=>(int)date('d', $revisionstartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
||||
if (!checkdate($revisionstartdate['month'], $revisionstartdate['day'], $revisionstartdate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_revision_date_start"));
|
||||
}
|
||||
$revised['from'] = $revisionstartts;
|
||||
}
|
||||
if(!empty($_GET["revisiondateend"])) {
|
||||
$revisionendts = makeTsFromDate($_GET["revisiondateend"]);
|
||||
if(!empty($get["revisiondateend"])) {
|
||||
$revisionendts = makeTsFromDate($get["revisiondateend"]);
|
||||
$revisionenddate = array('year'=>(int)date('Y', $revisionendts), 'month'=>(int)date('m', $revisionendts), 'day'=>(int)date('d', $revisionendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
||||
if (!checkdate($revisionenddate['month'], $revisionenddate['day'], $revisionenddate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_revision_date_end"));
|
||||
}
|
||||
$revised['to'] = $revisionendts;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* Status date {{{ */
|
||||
$statusstartdate = array();
|
||||
$statusenddate = array();
|
||||
if(!empty($_GET["statusdatestart"])) {
|
||||
$statusstartts = makeTsFromDate($_GET["statusdatestart"]);
|
||||
if(!empty($get["statusdatestart"])) {
|
||||
$statusstartts = makeTsFromDate($get["statusdatestart"]);
|
||||
$statusstartdate = array('year'=>(int)date('Y', $statusstartts), 'month'=>(int)date('m', $statusstartts), 'day'=>(int)date('d', $statusstartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
||||
}
|
||||
if ($statusstartdate && !checkdate($statusstartdate['month'], $statusstartdate['day'], $statusstartdate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_status_date_start"));
|
||||
}
|
||||
if(!empty($_GET["statusdateend"])) {
|
||||
$statusendts = makeTsFromDate($_GET["statusdateend"]);
|
||||
if(!empty($get["statusdateend"])) {
|
||||
$statusendts = makeTsFromDate($get["statusdateend"]);
|
||||
$statusenddate = array('year'=>(int)date('Y', $statusendts), 'month'=>(int)date('m', $statusendts), 'day'=>(int)date('d', $statusendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
||||
}
|
||||
if ($statusenddate && !checkdate($statusenddate['month'], $statusenddate['day'], $statusenddate['year'])) {
|
||||
|
@ -502,15 +526,15 @@ if($fullsearch) {
|
|||
/* Expiration date {{{ */
|
||||
$expstartdate = array();
|
||||
$expenddate = array();
|
||||
if(!empty($_GET["expirationstart"])) {
|
||||
$expstartts = makeTsFromDate($_GET["expirationstart"]);
|
||||
if(!empty($get["expirationstart"])) {
|
||||
$expstartts = makeTsFromDate($get["expirationstart"]);
|
||||
$expstartdate = array('year'=>(int)date('Y', $expstartts), 'month'=>(int)date('m', $expstartts), 'day'=>(int)date('d', $expstartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
||||
if (!checkdate($expstartdate['month'], $expstartdate['day'], $expstartdate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_expiration_date_start"));
|
||||
}
|
||||
}
|
||||
if(!empty($_GET["expirationend"])) {
|
||||
$expendts = makeTsFromDate($_GET["expirationend"]);
|
||||
if(!empty($get["expirationend"])) {
|
||||
$expendts = makeTsFromDate($get["expirationend"]);
|
||||
$expenddate = array('year'=>(int)date('Y', $expendts), 'month'=>(int)date('m', $expendts), 'day'=>(int)date('d', $expendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
||||
if (!checkdate($expenddate['month'], $expenddate['day'], $expenddate['year'])) {
|
||||
UI::exitError(getMLText("search"),getMLText("invalid_expiration_date_end"));
|
||||
|
@ -519,8 +543,8 @@ if($fullsearch) {
|
|||
/* }}} */
|
||||
|
||||
$reception = array();
|
||||
if (isset($_GET["reception"])){
|
||||
$reception = $_GET["reception"];
|
||||
if (isset($get["reception"])){
|
||||
$reception = $get["reception"];
|
||||
}
|
||||
|
||||
/* Do not search for folders if result shall be filtered by status.
|
||||
|
@ -532,8 +556,8 @@ if($fullsearch) {
|
|||
// if($status)
|
||||
// $resultmode = 0x01;
|
||||
|
||||
if (isset($_GET["attributes"]))
|
||||
$attributes = $_GET["attributes"];
|
||||
if (isset($get["attributes"]))
|
||||
$attributes = $get["attributes"];
|
||||
else
|
||||
$attributes = array();
|
||||
|
||||
|
@ -558,15 +582,15 @@ if($fullsearch) {
|
|||
$resArr = $dms->search(array(
|
||||
'query'=>$query,
|
||||
'limit'=>0,
|
||||
'offset'=>0 /*$limit, ($pageNumber-1)*$limit*/,
|
||||
'offset'=>0,
|
||||
'logicalmode'=>$mode,
|
||||
'searchin'=>$searchin,
|
||||
'startFolder'=>$startFolder,
|
||||
'owner'=>$ownerobjs,
|
||||
'status'=>$status,
|
||||
'mimetype'=>$mimetype,
|
||||
'creationstartdate'=>$created['from'], //$createstartdate ? $createstartdate : array(),
|
||||
'creationenddate'=>$created['to'], //$createenddate ? $createenddate : array(),
|
||||
'creationstartdate'=>$created['from'],
|
||||
'creationenddate'=>$created['to'],
|
||||
'modificationstartdate'=>$modified['from'],
|
||||
'modificationenddate'=>$modified['to'],
|
||||
'filesizestart'=>$filesize['from'],
|
||||
|
@ -589,7 +613,7 @@ if($fullsearch) {
|
|||
|
||||
$entries = array();
|
||||
$fcount = 0;
|
||||
// if(!isset($_GET['action']) || $_GET['action'] != 'export') {
|
||||
// if(!isset($get['action']) || $get['action'] != 'export') {
|
||||
if($resArr['folders']) {
|
||||
foreach ($resArr['folders'] as $entry) {
|
||||
if ($entry->getAccessMode($user) >= M_READ) {
|
||||
|
@ -612,7 +636,7 @@ if($fullsearch) {
|
|||
}
|
||||
}
|
||||
$totalPages = 1;
|
||||
if ((!isset($_GET['action']) || $_GET['action'] != 'export') /*&& (!isset($_GET["pg"]) || strcasecmp($_GET["pg"], "all"))*/) {
|
||||
if ((!isset($get['action']) || $get['action'] != 'export') /*&& (!isset($get["pg"]) || strcasecmp($get["pg"], "all"))*/) {
|
||||
$totalPages = (int) (count($entries)/$limit);
|
||||
if(count($entries)%$limit)
|
||||
$totalPages++;
|
||||
|
@ -647,7 +671,7 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
|
|||
$view->setParam('query', $query);
|
||||
$view->setParam('includecontent', $includecontent);
|
||||
$view->setParam('skipdefaultcols', $skipdefaultcols);
|
||||
$view->setParam('marks', isset($_GET['marks']) ? $_GET['marks'] : array());
|
||||
$view->setParam('marks', isset($get['marks']) ? $get['marks'] : array());
|
||||
$view->setParam('newowner', $newowner);
|
||||
$view->setParam('newreviewer', $newreviewer);
|
||||
$view->setParam('newapprover', $newapprover);
|
||||
|
@ -659,7 +683,7 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
|
|||
$view->setParam('pagenumber', $pageNumber);
|
||||
$view->setParam('limit', $limit);
|
||||
$view->setParam('searchtime', $searchTime);
|
||||
$view->setParam('urlparams', $_GET);
|
||||
$view->setParam('urlparams', $get);
|
||||
$view->setParam('cachedir', $settings->_cacheDir);
|
||||
$view->setParam('onepage', $settings->_onePageMode); // do most navigation by reloading areas of pages with ajax
|
||||
$view->setParam('showtree', showtree());
|
||||
|
@ -672,21 +696,21 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
|
|||
$view->setParam('facetsearch', $facetsearch);
|
||||
$view->setParam('mode', isset($mode) ? $mode : '');
|
||||
$view->setParam('orderby', isset($orderby) ? $orderby : '');
|
||||
$view->setParam('defaultsearchmethod', !empty($_GET["fullsearch"]) || $settings->_defaultSearchMethod);
|
||||
$view->setParam('defaultsearchmethod', !empty($get["fullsearch"]) || $settings->_defaultSearchMethod);
|
||||
$view->setParam('resultmode', isset($resultmode) ? $resultmode : '');
|
||||
$view->setParam('searchin', isset($searchin) ? $searchin : array());
|
||||
$view->setParam('startfolder', isset($startFolder) ? $startFolder : null);
|
||||
$view->setParam('owner', $owner);
|
||||
$view->setParam('createstartdate', $createstartts);
|
||||
$view->setParam('createenddate', $createendts);
|
||||
$view->setParam('createstartdate', $created['from']);
|
||||
$view->setParam('createenddate', $created['to']);
|
||||
$view->setParam('created', $created);
|
||||
$view->setParam('revisionstartdate', !empty($revisionstartdate) ? getReadableDate($revisionstartts) : '');
|
||||
$view->setParam('revisionenddate', !empty($revisionenddate) ? getReadableDate($revisionendts) : '');
|
||||
$view->setParam('modifystartdate', $modifystartts);
|
||||
$view->setParam('modifyenddate', $modifyendts);
|
||||
$view->setParam('modifystartdate', $modified['from']);
|
||||
$view->setParam('modifyenddate', $modified['to']);
|
||||
$view->setParam('modified', $modified);
|
||||
$view->setParam('filesizestart', $filesizestart);
|
||||
$view->setParam('filesizeend', $filesizeend);
|
||||
$view->setParam('filesizestart', $filesize['from']);
|
||||
$view->setParam('filesizeend', $filesize['to']);
|
||||
$view->setParam('filesize', $filesize);
|
||||
$view->setParam('expstartdate', !empty($expstartdate) ? getReadableDate($expstartts) : '');
|
||||
$view->setParam('expenddate', !empty($expenddate) ? getReadableDate($expendts) : '');
|
||||
|
@ -714,7 +738,7 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
|
|||
$view->setParam('xsendfile', $settings->_enableXsendfile);
|
||||
$view->setParam('reception', $reception);
|
||||
$view->setParam('showsinglesearchhit', $settings->_showSingleSearchHit);
|
||||
$view($_GET);
|
||||
$view($get);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user