2011-03-10 14:13:39 +00:00
|
|
|
<?php
|
|
|
|
// MyDMS. Document Management System
|
2016-08-09 05:53:15 +00:00
|
|
|
// Copyright (C) 2002-2005 Markus Westphal
|
2011-03-10 14:13:39 +00:00
|
|
|
// Copyright (C) 2006-2008 Malcolm Cowe
|
2016-08-09 05:53:15 +00:00
|
|
|
// Copyright (C) 2010-2016 Uwe Steinmann
|
2011-03-10 14:13:39 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
2018-10-11 07:39:02 +00:00
|
|
|
if(!isset($settings))
|
|
|
|
require_once("../inc/inc.Settings.php");
|
|
|
|
require_once("inc/inc.Utils.php");
|
2022-11-09 08:25:45 +00:00
|
|
|
require_once("inc/inc.LogInit.php");
|
2018-10-11 07:39:02 +00:00
|
|
|
require_once("inc/inc.Language.php");
|
|
|
|
require_once("inc/inc.Init.php");
|
|
|
|
require_once("inc/inc.Extension.php");
|
|
|
|
require_once("inc/inc.DBInit.php");
|
|
|
|
require_once("inc/inc.ClassUI.php");
|
|
|
|
require_once("inc/inc.Authentication.php");
|
2013-01-25 07:23:06 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
function getTime() {
|
|
|
|
if (function_exists('microtime')) {
|
|
|
|
$tm = microtime();
|
|
|
|
$tm = explode(' ', $tm);
|
|
|
|
return (float) sprintf('%f', $tm[1] + $tm[0]);
|
|
|
|
}
|
|
|
|
return time();
|
|
|
|
}
|
|
|
|
|
2011-03-10 14:13:39 +00:00
|
|
|
// 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) {
|
|
|
|
$folderid=$settings->_rootFolderID;
|
2013-06-07 08:12:49 +00:00
|
|
|
} else {
|
2011-03-10 14:13:39 +00:00
|
|
|
$folderid = $_GET["folderid"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-18 11:49:27 +00:00
|
|
|
$includecontent = false;
|
|
|
|
if (isset($_GET["includecontent"]) && $_GET["includecontent"])
|
|
|
|
$includecontent = true;
|
|
|
|
|
2022-08-18 16:40:51 +00:00
|
|
|
$newowner = null;
|
|
|
|
if (isset($_GET["newowner"]) && is_numeric($_GET["newowner"]) && $_GET['newowner'] > 0) {
|
|
|
|
$newowner = $dms->getUser((int) $_GET['newowner']);
|
|
|
|
}
|
|
|
|
|
2024-04-30 08:46:27 +00:00
|
|
|
$newreviewer = null;
|
|
|
|
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']);
|
|
|
|
}
|
|
|
|
|
2022-09-14 16:08:34 +00:00
|
|
|
$changecategory = null;
|
|
|
|
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'];
|
|
|
|
}
|
|
|
|
|
2023-04-26 15:35:59 +00:00
|
|
|
/* 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"));
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
2023-04-26 15:35:59 +00:00
|
|
|
$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"));
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
2023-04-26 15:35:59 +00:00
|
|
|
$created['to'] = $createendts;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2023-05-03 14:21:57 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2023-04-26 15:35:59 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* }}} */
|
2011-03-10 14:13:39 +00:00
|
|
|
|
2023-04-26 15:35:59 +00:00
|
|
|
// category {{{
|
2013-06-07 08:12:49 +00:00
|
|
|
$categories = array();
|
2013-06-14 14:06:52 +00:00
|
|
|
$categorynames = array();
|
2021-11-19 12:49:07 +00:00
|
|
|
$category = array();
|
2020-09-12 10:52:44 +00:00
|
|
|
if(isset($_GET['category']) && $_GET['category']) {
|
2021-11-19 12:49:07 +00:00
|
|
|
$category = $_GET['category'];
|
2021-05-05 11:47:38 +00:00
|
|
|
foreach($_GET['category'] as $catid) {
|
2020-09-14 07:33:55 +00:00
|
|
|
if($catid) {
|
2023-04-23 17:01:08 +00:00
|
|
|
if(is_numeric($catid)) {
|
|
|
|
if($cat = $dms->getDocumentCategory($catid)) {
|
|
|
|
$categories[] = $cat;
|
|
|
|
$categorynames[] = $cat->getName();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$categorynames[] = $catid;
|
2022-03-04 07:20:45 +00:00
|
|
|
}
|
2020-09-14 07:33:55 +00:00
|
|
|
}
|
|
|
|
}
|
2023-04-26 15:35:59 +00:00
|
|
|
} /* }}} */
|
|
|
|
|
2023-05-03 15:38:01 +00:00
|
|
|
if (isset($_GET["orderby"]) && is_string($_GET["orderby"])) {
|
|
|
|
$orderby = $_GET["orderby"];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$orderby = "";
|
|
|
|
}
|
|
|
|
|
2023-04-26 15:35:59 +00:00
|
|
|
$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;
|
|
|
|
if($fullsearch) {
|
|
|
|
// Search in Fulltext {{{
|
|
|
|
if (isset($_GET["query"]) && is_string($_GET["query"])) {
|
|
|
|
$query = $_GET["query"];
|
|
|
|
// if(isset($_GET['action']) && ($_GET['action'] == 'typeahead'))
|
|
|
|
// $query .= '*';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$query = "";
|
2011-03-10 14:13:39 +00:00
|
|
|
}
|
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
//
|
|
|
|
// 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 = (integer)$_GET["pg"];
|
|
|
|
}
|
2022-09-13 18:03:56 +00:00
|
|
|
elseif (!strcasecmp($_GET["pg"], "all")) {
|
2013-06-07 08:12:49 +00:00
|
|
|
$pageNumber = "all";
|
|
|
|
}
|
|
|
|
}
|
2010-11-05 21:41:37 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
// --------------- Suche starten --------------------------------------------
|
2010-11-05 21:41:37 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
// Check to see if the search has been restricted to a particular
|
2023-04-26 15:35:59 +00:00
|
|
|
// mimetype. {{{
|
2020-09-12 10:52:44 +00:00
|
|
|
$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;
|
|
|
|
}
|
2015-08-10 19:43:15 +00:00
|
|
|
}
|
2023-04-26 15:35:59 +00:00
|
|
|
} /* }}} */
|
2013-06-07 08:12:49 +00:00
|
|
|
|
2023-04-26 15:35:59 +00:00
|
|
|
/* Creation date {{{
|
2023-04-21 15:55:56 +00:00
|
|
|
$createstartts = null;
|
|
|
|
$createstartdate = null;
|
|
|
|
$createendts = null;
|
|
|
|
$createenddate = null;
|
2023-04-26 15:35:59 +00:00
|
|
|
$created = [];
|
|
|
|
if(!empty($_GET["created"]["from"])) {
|
|
|
|
$createstartts = makeTsFromDate($_GET["created"]["from"]);
|
2023-04-21 15:55:56 +00:00
|
|
|
$createstartdate = array('year'=>(int)date('Y', $createstartts), 'month'=>(int)date('m', $createstartts), 'day'=>(int)date('d', $createstartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
2023-04-26 15:35:59 +00:00
|
|
|
if (!checkdate($createstartdate['month'], $createstartdate['day'], $createstartdate['year'])) {
|
|
|
|
UI::exitError(getMLText("search"),getMLText("invalid_create_date_end"));
|
|
|
|
}
|
|
|
|
$created['from'] = $createstartts;
|
2023-04-21 15:55:56 +00:00
|
|
|
}
|
2023-04-26 15:35:59 +00:00
|
|
|
if(!empty($_GET["created"]["to"])) {
|
|
|
|
$createendts = makeTsFromDate($_GET["created"]["to"]);
|
2023-04-21 15:55:56 +00:00
|
|
|
$createenddate = array('year'=>(int)date('Y', $createendts), 'month'=>(int)date('m', $createendts), 'day'=>(int)date('d', $createendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
2023-04-26 15:35:59 +00:00
|
|
|
if (!checkdate($createenddate['month'], $createenddate['day'], $createenddate['year'])) {
|
|
|
|
UI::exitError(getMLText("search"),getMLText("invalid_create_date_end"));
|
|
|
|
}
|
|
|
|
$created['to'] = $createendts;
|
2023-04-21 15:55:56 +00:00
|
|
|
}
|
2023-04-26 15:35:59 +00:00
|
|
|
}}} */
|
2023-04-21 15:55:56 +00:00
|
|
|
|
2020-09-12 10:52:44 +00:00
|
|
|
// status
|
2021-05-05 11:47:38 +00:00
|
|
|
if(isset($_GET['status']))
|
|
|
|
$status = $_GET['status'];
|
|
|
|
else
|
|
|
|
$status = array();
|
2020-09-12 10:52:44 +00:00
|
|
|
|
2021-11-19 12:49:07 +00:00
|
|
|
// record_type
|
|
|
|
if(isset($_GET['record_type']))
|
|
|
|
$record_type = $_GET['record_type'];
|
|
|
|
else
|
|
|
|
$record_type = array();
|
|
|
|
|
2023-03-04 08:04:58 +00:00
|
|
|
if (isset($_GET["attributes"]))
|
|
|
|
$attributes = $_GET["attributes"];
|
|
|
|
else
|
|
|
|
$attributes = array();
|
|
|
|
|
2023-04-25 10:28:05 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-03 15:38:01 +00:00
|
|
|
/* 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'=>''];
|
|
|
|
}
|
|
|
|
|
2023-04-25 10:28:05 +00:00
|
|
|
//print_r($attributes);exit;
|
2020-12-17 17:34:40 +00:00
|
|
|
// Check to see if the search has been restricted to a particular sub-tree in
|
|
|
|
// the folder hierarchy.
|
|
|
|
$startFolder = null;
|
2021-05-05 11:47:38 +00:00
|
|
|
if (isset($_GET["folderfullsearchid"]) && is_numeric($_GET["folderfullsearchid"]) && $_GET["folderfullsearchid"]>0) {
|
|
|
|
$targetid = $_GET["folderfullsearchid"];
|
2020-12-17 17:34:40 +00:00
|
|
|
$startFolder = $dms->getFolder($targetid);
|
|
|
|
if (!is_object($startFolder)) {
|
|
|
|
UI::exitError(getMLText("search"),getMLText("invalid_folder_id"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$rootFolder = $dms->getFolder($settings->_rootFolderID);
|
|
|
|
|
2020-09-12 10:52:44 +00:00
|
|
|
$startTime = getTime();
|
|
|
|
if($settings->_fullSearchEngine == 'lucene') {
|
|
|
|
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
|
|
|
|
}
|
|
|
|
|
2013-06-17 08:49:55 +00:00
|
|
|
if(strlen($query) < 4 && strpos($query, '*')) {
|
|
|
|
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
|
2020-09-12 10:52:44 +00:00
|
|
|
$dcount = 0;
|
2015-09-28 10:32:41 +00:00
|
|
|
$totalPages = 0;
|
2013-06-17 08:49:55 +00:00
|
|
|
$entries = array();
|
|
|
|
$searchTime = 0;
|
2013-06-07 08:12:49 +00:00
|
|
|
} else {
|
2015-08-19 18:15:04 +00:00
|
|
|
$startTime = getTime();
|
2023-01-07 11:18:30 +00:00
|
|
|
// $limit = 20;
|
2020-12-18 09:54:53 +00:00
|
|
|
$total = 0;
|
2020-09-09 17:49:15 +00:00
|
|
|
$index = $fulltextservice->Indexer();
|
2020-09-12 10:52:44 +00:00
|
|
|
if($index) {
|
2023-04-22 17:41:15 +00:00
|
|
|
if(!empty($settings->_suggestTerms) && !empty($_GET['query'])) {
|
2023-04-23 17:02:42 +00:00
|
|
|
$st = preg_split("/[\s,]+/", trim($_GET['query']));
|
|
|
|
if($lastterm = end($st))
|
|
|
|
$terms = $index->terms($lastterm, $settings->_suggestTerms);
|
2023-04-21 11:03:08 +00:00
|
|
|
}
|
2020-09-12 10:52:44 +00:00
|
|
|
$lucenesearch = $fulltextservice->Search();
|
2023-05-03 15:38:01 +00:00
|
|
|
$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, 'attributes'=>$attributes), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1))), $order);
|
2020-09-12 10:52:44 +00:00
|
|
|
if($searchresult === false) {
|
|
|
|
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
|
|
|
|
$dcount = 0;
|
|
|
|
$fcount = 0;
|
|
|
|
$totalPages = 0;
|
|
|
|
$entries = array();
|
|
|
|
$facets = array();
|
2023-12-15 16:13:28 +00:00
|
|
|
$stats = array();
|
2020-09-12 10:52:44 +00:00
|
|
|
$searchTime = 0;
|
|
|
|
} else {
|
|
|
|
$entries = array();
|
|
|
|
$facets = $searchresult['facets'];
|
2023-12-15 16:13:28 +00:00
|
|
|
$stats = $searchresult['stats'] ?? null;
|
2020-12-12 15:29:56 +00:00
|
|
|
$dcount = 0;
|
2020-09-12 10:52:44 +00:00
|
|
|
$fcount = 0;
|
2023-01-06 12:46:33 +00:00
|
|
|
if($searchresult['hits']) {
|
2020-09-12 10:52:44 +00:00
|
|
|
foreach($searchresult['hits'] as $hit) {
|
2020-12-12 15:29:56 +00:00
|
|
|
if($hit['document_id'][0] == 'D') {
|
|
|
|
if($tmp = $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 = $dms->getFolder(substr($hit['document_id'], 1))) {
|
|
|
|
// if($tmp->getAccessMode($user) >= M_READ) {
|
|
|
|
$entries[] = $tmp;
|
|
|
|
$fcount++;
|
|
|
|
// }
|
2020-09-12 10:52:44 +00:00
|
|
|
}
|
2013-08-13 20:09:40 +00:00
|
|
|
}
|
2013-06-17 08:49:55 +00:00
|
|
|
}
|
2021-11-19 12:49:07 +00:00
|
|
|
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 ;
|
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
2022-09-13 18:03:56 +00:00
|
|
|
if(/* $pageNumber != 'all' && */$searchresult['count'] > $limit) {
|
2020-12-12 15:29:56 +00:00
|
|
|
$totalPages = (int) ($searchresult['count']/$limit);
|
|
|
|
if($searchresult['count']%$limit)
|
2020-09-12 10:52:44 +00:00
|
|
|
$totalPages++;
|
2020-09-14 14:34:46 +00:00
|
|
|
// if($limit > 0)
|
|
|
|
// $entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
|
2020-09-12 10:52:44 +00:00
|
|
|
} else {
|
|
|
|
$totalPages = 1;
|
|
|
|
}
|
2020-12-21 14:48:58 +00:00
|
|
|
$total = $searchresult['count'];
|
2010-11-05 21:41:37 +00:00
|
|
|
}
|
2020-09-12 10:52:44 +00:00
|
|
|
$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();
|
2023-12-15 16:13:28 +00:00
|
|
|
$stats = array();
|
2020-09-12 10:52:44 +00:00
|
|
|
$searchTime = 0;
|
2010-11-05 21:41:37 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
// }}}
|
|
|
|
} else {
|
|
|
|
// Search in Database {{{
|
|
|
|
if (isset($_GET["query"]) && is_string($_GET["query"])) {
|
|
|
|
$query = $_GET["query"];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$query = "";
|
|
|
|
}
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
/* Select if only documents (0x01), only folders (0x02) or both (0x03)
|
|
|
|
* are found
|
|
|
|
*/
|
|
|
|
$resultmode = 0x03;
|
2015-06-02 06:52:36 +00:00
|
|
|
if (isset($_GET["resultmode"]) && is_numeric($_GET["resultmode"])) {
|
|
|
|
$resultmode = $_GET['resultmode'];
|
|
|
|
}
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
$mode = "AND";
|
|
|
|
if (isset($_GET["mode"]) && is_numeric($_GET["mode"]) && $_GET["mode"]==0) {
|
|
|
|
$mode = "OR";
|
|
|
|
}
|
2010-11-05 21:41:37 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
$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
|
2017-01-18 13:45:40 +00:00
|
|
|
case 5: // id
|
2013-06-07 08:12:49 +00:00
|
|
|
$searchin[$si] = $si;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if none is checkd search all
|
2017-01-18 13:45:40 +00:00
|
|
|
if (count($searchin)==0) $searchin=array(1, 2, 3, 4, 5);
|
2013-06-07 08:12:49 +00:00
|
|
|
|
|
|
|
// Check to see if the search has been restricted to a particular sub-tree in
|
|
|
|
// the folder hierarchy.
|
2014-07-08 06:30:59 +00:00
|
|
|
if (isset($_GET["targetid"]) && is_numeric($_GET["targetid"]) && $_GET["targetid"]>0) {
|
|
|
|
$targetid = $_GET["targetid"];
|
2013-06-07 08:12:49 +00:00
|
|
|
$startFolder = $dms->getFolder($targetid);
|
|
|
|
}
|
|
|
|
else {
|
2020-12-18 09:54:53 +00:00
|
|
|
$startFolder = $dms->getRootFolder();
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
|
|
|
if (!is_object($startFolder)) {
|
2015-11-16 07:08:30 +00:00
|
|
|
UI::exitError(getMLText("search"),getMLText("invalid_folder_id"));
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check to see if the search has been restricted to a particular
|
2023-04-26 15:35:59 +00:00
|
|
|
/* document owner. {{{
|
2020-09-12 10:52:44 +00:00
|
|
|
$owner = array();
|
2020-09-14 14:34:46 +00:00
|
|
|
$ownerobjs = array();
|
2020-09-12 10:52:44 +00:00
|
|
|
if (isset($_GET["owner"])) {
|
2021-05-05 11:47:38 +00:00
|
|
|
$owner = $_GET['owner'];
|
2020-09-12 10:52:44 +00:00
|
|
|
if (!is_array($_GET['owner'])) {
|
2021-05-05 11:47:38 +00:00
|
|
|
if(!empty($_GET['owner']) && $o = $dms->getUser($_GET['owner'])) {
|
2020-09-14 14:34:46 +00:00
|
|
|
$ownerobjs[] = $o;
|
|
|
|
} else
|
|
|
|
UI::exitError(getMLText("search"),getMLText("unknown_owner"));
|
2020-09-12 10:52:44 +00:00
|
|
|
} else {
|
|
|
|
foreach($_GET["owner"] as $l) {
|
2021-05-05 11:47:38 +00:00
|
|
|
if($o = $dms->getUser($l)) {
|
2020-09-14 14:34:46 +00:00
|
|
|
$ownerobjs[] = $o;
|
|
|
|
}
|
2020-09-12 10:52:44 +00:00
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
2023-04-26 15:35:59 +00:00
|
|
|
} }}} */
|
2013-06-07 08:12:49 +00:00
|
|
|
|
2023-04-26 15:35:59 +00:00
|
|
|
/* Creation date {{{
|
2021-05-05 11:47:38 +00:00
|
|
|
$createstartdate = array();
|
|
|
|
$createenddate = array();
|
|
|
|
if(!empty($_GET["createstart"])) {
|
|
|
|
$createstartts = makeTsFromDate($_GET["createstart"]);
|
|
|
|
$createstartdate = array('year'=>(int)date('Y', $createstartts), 'month'=>(int)date('m', $createstartts), 'day'=>(int)date('d', $createstartts), 'hour'=>0, 'minute'=>0, 'second'=>0);
|
2013-01-24 10:13:08 +00:00
|
|
|
}
|
2021-05-05 11:47:38 +00:00
|
|
|
if ($createstartdate && !checkdate($createstartdate['month'], $createstartdate['day'], $createstartdate['year'])) {
|
2015-11-16 07:06:55 +00:00
|
|
|
UI::exitError(getMLText("search"),getMLText("invalid_create_date_end"));
|
2010-11-05 21:41:37 +00:00
|
|
|
}
|
2021-05-05 11:47:38 +00:00
|
|
|
if(!empty($_GET["createend"])) {
|
|
|
|
$createendts = makeTsFromDate($_GET["createend"]);
|
|
|
|
$createenddate = array('year'=>(int)date('Y', $createendts), 'month'=>(int)date('m', $createendts), 'day'=>(int)date('d', $createendts), 'hour'=>23, 'minute'=>59, 'second'=>59);
|
2013-01-24 10:13:08 +00:00
|
|
|
}
|
2021-05-05 11:47:38 +00:00
|
|
|
if ($createenddate && !checkdate($createenddate['month'], $createenddate['day'], $createenddate['year'])) {
|
2015-11-16 07:06:55 +00:00
|
|
|
UI::exitError(getMLText("search"),getMLText("invalid_create_date_end"));
|
2010-11-05 21:41:37 +00:00
|
|
|
}
|
2023-04-26 15:35:59 +00:00
|
|
|
}}} */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2021-05-05 11:47:38 +00:00
|
|
|
/* Status date {{{ */
|
2021-03-15 15:08:51 +00:00
|
|
|
$statusstartdate = array();
|
2021-05-05 11:47:38 +00:00
|
|
|
$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);
|
2021-03-15 15:08:51 +00:00
|
|
|
}
|
2021-05-05 11:47:38 +00:00
|
|
|
if ($statusstartdate && !checkdate($statusstartdate['month'], $statusstartdate['day'], $statusstartdate['year'])) {
|
|
|
|
UI::exitError(getMLText("search"),getMLText("invalid_status_date_start"));
|
2021-03-15 15:08:51 +00:00
|
|
|
}
|
2021-05-05 11:47:38 +00:00
|
|
|
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);
|
2021-03-15 15:08:51 +00:00
|
|
|
}
|
2021-05-05 11:47:38 +00:00
|
|
|
if ($statusenddate && !checkdate($statusenddate['month'], $statusenddate['day'], $statusenddate['year'])) {
|
2021-03-15 15:08:51 +00:00
|
|
|
UI::exitError(getMLText("search"),getMLText("invalid_status_date_end"));
|
|
|
|
}
|
2021-05-05 11:47:38 +00:00
|
|
|
/* }}} */
|
2021-03-15 15:08:51 +00:00
|
|
|
|
2021-05-05 11:47:38 +00:00
|
|
|
/* Expiration date {{{ */
|
2013-06-07 08:12:49 +00:00
|
|
|
$expstartdate = array();
|
2021-05-05 11:47:38 +00:00
|
|
|
$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);
|
2013-01-24 10:13:08 +00:00
|
|
|
if (!checkdate($expstartdate['month'], $expstartdate['day'], $expstartdate['year'])) {
|
|
|
|
UI::exitError(getMLText("search"),getMLText("invalid_expiration_date_start"));
|
|
|
|
}
|
|
|
|
}
|
2021-05-05 11:47:38 +00:00
|
|
|
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'])) {
|
2013-01-24 10:13:08 +00:00
|
|
|
UI::exitError(getMLText("search"),getMLText("invalid_expiration_date_end"));
|
|
|
|
}
|
|
|
|
}
|
2021-05-05 11:47:38 +00:00
|
|
|
/* }}} */
|
2011-03-10 14:13:39 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
// status
|
2021-05-05 11:47:38 +00:00
|
|
|
$status = isset($_GET['status']) ? $_GET['status'] : array();
|
|
|
|
/*
|
2013-06-07 08:12:49 +00:00
|
|
|
$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;
|
2011-03-10 14:13:39 +00:00
|
|
|
}
|
2021-05-05 11:47:38 +00:00
|
|
|
*/
|
2011-03-10 14:13:39 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
2014-07-23 18:51:45 +00:00
|
|
|
// if($status)
|
|
|
|
// $resultmode = 0x01;
|
2013-06-07 08:12:49 +00:00
|
|
|
|
|
|
|
if (isset($_GET["attributes"]))
|
|
|
|
$attributes = $_GET["attributes"];
|
|
|
|
else
|
|
|
|
$attributes = array();
|
|
|
|
|
2021-03-12 09:06:54 +00:00
|
|
|
foreach($attributes as $attrdefid=>$attribute) {
|
|
|
|
$attrdef = $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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
//
|
|
|
|
// 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;
|
2023-01-07 11:18:30 +00:00
|
|
|
// $limit = 15;
|
2013-06-07 08:12:49 +00:00
|
|
|
if (isset($_GET["pg"])) {
|
|
|
|
if (is_numeric($_GET["pg"]) && $_GET["pg"]>0) {
|
|
|
|
$pageNumber = (int) $_GET["pg"];
|
|
|
|
}
|
|
|
|
elseif (!strcasecmp($_GET["pg"], "all")) {
|
2022-08-18 11:49:27 +00:00
|
|
|
$pageNumber = "all";
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
2010-11-05 21:41:37 +00:00
|
|
|
}
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
// ---------------- Start searching -----------------------------------------
|
|
|
|
$startTime = getTime();
|
2019-06-26 16:03:07 +00:00
|
|
|
$resArr = $dms->search(array(
|
|
|
|
'query'=>$query,
|
|
|
|
'limit'=>0,
|
|
|
|
'offset'=>0 /*$limit, ($pageNumber-1)*$limit*/,
|
|
|
|
'logicalmode'=>$mode,
|
|
|
|
'searchin'=>$searchin,
|
|
|
|
'startFolder'=>$startFolder,
|
2020-09-14 14:34:46 +00:00
|
|
|
'owner'=>$ownerobjs,
|
2019-06-26 16:03:07 +00:00
|
|
|
'status'=>$status,
|
2023-04-26 15:35:59 +00:00
|
|
|
'creationstartdate'=>$created['from'], //$createstartdate ? $createstartdate : array(),
|
|
|
|
'creationenddate'=>$created['to'], //$createenddate ? $createenddate : array(),
|
2023-05-03 14:21:57 +00:00
|
|
|
'modificationstartdate'=>$modified['from'],
|
|
|
|
'modificationenddate'=>$modified['to'],
|
2019-06-26 16:03:07 +00:00
|
|
|
'categories'=>$categories,
|
|
|
|
'attributes'=>$attributes,
|
|
|
|
'mode'=>$resultmode,
|
2021-05-05 11:47:38 +00:00
|
|
|
'expirationstartdate'=>$expstartdate ? $expstartdate : array(),
|
|
|
|
'expirationenddate'=>$expenddate ? $expenddate : array(),
|
|
|
|
'statusstartdate'=>$statusstartdate ? $statusstartdate : array(),
|
|
|
|
'statusenddate'=>$statusenddate ? $statusenddate : array(),
|
2019-06-26 16:03:07 +00:00
|
|
|
'orderby'=>$orderby
|
|
|
|
));
|
2020-12-15 20:39:10 +00:00
|
|
|
$total = $resArr['totalDocs'] + $resArr['totalFolders'];
|
2013-06-07 08:12:49 +00:00
|
|
|
$searchTime = getTime() - $startTime;
|
|
|
|
$searchTime = round($searchTime, 2);
|
2011-03-10 14:13:39 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
$entries = array();
|
2015-03-17 05:36:33 +00:00
|
|
|
$fcount = 0;
|
2022-08-18 11:49:27 +00:00
|
|
|
if(!isset($_GET['action']) || $_GET['action'] != 'export') {
|
|
|
|
if($resArr['folders']) {
|
|
|
|
foreach ($resArr['folders'] as $entry) {
|
|
|
|
if ($entry->getAccessMode($user) >= M_READ) {
|
|
|
|
$entries[] = $entry;
|
|
|
|
$fcount++;
|
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
2012-08-28 06:24:05 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-17 05:36:33 +00:00
|
|
|
$dcount = 0;
|
2013-06-07 08:12:49 +00:00
|
|
|
if($resArr['docs']) {
|
|
|
|
foreach ($resArr['docs'] as $entry) {
|
|
|
|
if ($entry->getAccessMode($user) >= M_READ) {
|
2022-08-18 11:49:27 +00:00
|
|
|
if($entry->getLatestContent()) {
|
|
|
|
$entry->verifyLastestContentExpriry();
|
|
|
|
$entries[] = $entry;
|
|
|
|
$dcount++;
|
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
2012-08-28 06:24:05 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-18 11:49:27 +00:00
|
|
|
$totalPages = 1;
|
2022-09-13 18:03:56 +00:00
|
|
|
if ((!isset($_GET['action']) || $_GET['action'] != 'export') /*&& (!isset($_GET["pg"]) || strcasecmp($_GET["pg"], "all"))*/) {
|
2017-10-26 04:32:36 +00:00
|
|
|
$totalPages = (int) (count($entries)/$limit);
|
|
|
|
if(count($entries)%$limit)
|
|
|
|
$totalPages++;
|
2022-09-13 18:03:56 +00:00
|
|
|
if($pageNumber != 'all')
|
|
|
|
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
|
2017-10-26 04:32:36 +00:00
|
|
|
} else
|
|
|
|
$totalPages = 1;
|
2020-09-12 10:52:44 +00:00
|
|
|
$facets = array();
|
2023-12-15 16:13:28 +00:00
|
|
|
$stats = array();
|
2013-06-07 08:12:49 +00:00
|
|
|
// }}}
|
2011-03-10 14:13:39 +00:00
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
|
2012-10-05 19:49:24 +00:00
|
|
|
// -------------- Output results --------------------------------------------
|
2011-03-10 14:13:39 +00:00
|
|
|
|
2016-10-04 14:54:16 +00:00
|
|
|
if($settings->_showSingleSearchHit && count($entries) == 1) {
|
2013-01-25 09:34:23 +00:00
|
|
|
$entry = $entries[0];
|
2019-08-08 07:16:54 +00:00
|
|
|
if($entry->isType('document')) {
|
2013-01-25 09:34:23 +00:00
|
|
|
header('Location: ../out/out.ViewDocument.php?documentid='.$entry->getID());
|
|
|
|
exit;
|
2019-08-08 07:16:54 +00:00
|
|
|
} elseif($entry->isType('folder')) {
|
2013-01-25 09:34:23 +00:00
|
|
|
header('Location: ../out/out.ViewFolder.php?folderid='.$entry->getID());
|
|
|
|
exit;
|
2011-03-10 14:13:39 +00:00
|
|
|
}
|
2012-08-28 06:24:05 +00:00
|
|
|
} else {
|
2013-01-25 09:34:23 +00:00
|
|
|
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
2022-08-18 11:18:00 +00:00
|
|
|
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
|
|
|
|
$accessop = new SeedDMS_AccessOperation($dms, null, $user, $settings);
|
2013-01-25 09:34:23 +00:00
|
|
|
if($view) {
|
2020-09-12 10:52:44 +00:00
|
|
|
$view->setParam('facets', $facets);
|
2023-12-15 16:13:28 +00:00
|
|
|
$view->setParam('stats', $stats);
|
2019-10-21 07:32:07 +00:00
|
|
|
$view->setParam('accessobject', $accessop);
|
2022-08-18 11:18:00 +00:00
|
|
|
$view->setParam('query', $query);
|
|
|
|
$view->setParam('includecontent', $includecontent);
|
2022-08-24 05:54:04 +00:00
|
|
|
$view->setParam('marks', isset($_GET['marks']) ? $_GET['marks'] : array());
|
2022-08-18 16:40:51 +00:00
|
|
|
$view->setParam('newowner', $newowner);
|
2024-04-30 08:46:27 +00:00
|
|
|
$view->setParam('newreviewer', $newreviewer);
|
|
|
|
$view->setParam('newapprover', $newapprover);
|
2022-09-14 16:08:34 +00:00
|
|
|
$view->setParam('changecategory', $changecategory);
|
|
|
|
$view->setParam('removecategory', $removecategory);
|
2022-08-18 11:18:00 +00:00
|
|
|
$view->setParam('searchhits', $entries);
|
2023-01-09 14:31:05 +00:00
|
|
|
$view->setParam('terms', $terms);
|
2022-08-18 11:18:00 +00:00
|
|
|
$view->setParam('totalpages', $totalPages);
|
|
|
|
$view->setParam('pagenumber', $pageNumber);
|
|
|
|
$view->setParam('limit', $limit);
|
|
|
|
$view->setParam('searchtime', $searchTime);
|
|
|
|
$view->setParam('urlparams', $_GET);
|
|
|
|
$view->setParam('cachedir', $settings->_cacheDir);
|
2020-02-28 08:48:43 +00:00
|
|
|
$view->setParam('onepage', $settings->_onePageMode); // do most navigation by reloading areas of pages with ajax
|
2019-06-26 16:03:07 +00:00
|
|
|
$view->setParam('showtree', showtree());
|
|
|
|
$view->setParam('enableRecursiveCount', $settings->_enableRecursiveCount);
|
|
|
|
$view->setParam('maxRecursiveCount', $settings->_maxRecursiveCount);
|
2020-12-14 09:46:05 +00:00
|
|
|
$view->setParam('total', $total);
|
2015-03-17 05:36:33 +00:00
|
|
|
$view->setParam('totaldocs', $dcount /*resArr['totalDocs']*/);
|
|
|
|
$view->setParam('totalfolders', $fcount /*resArr['totalFolders']*/);
|
2021-11-10 07:33:52 +00:00
|
|
|
$view->setParam('fullsearch', $fullsearch);
|
2023-04-23 17:02:57 +00:00
|
|
|
$view->setParam('facetsearch', $facetsearch);
|
2013-06-07 13:26:09 +00:00
|
|
|
$view->setParam('mode', isset($mode) ? $mode : '');
|
2019-06-26 16:03:07 +00:00
|
|
|
$view->setParam('orderby', isset($orderby) ? $orderby : '');
|
2020-12-13 08:37:38 +00:00
|
|
|
$view->setParam('defaultsearchmethod', !empty($_GET["fullsearch"]) || $settings->_defaultSearchMethod);
|
2015-06-08 07:15:33 +00:00
|
|
|
$view->setParam('resultmode', isset($resultmode) ? $resultmode : '');
|
2013-06-07 13:26:09 +00:00
|
|
|
$view->setParam('searchin', isset($searchin) ? $searchin : array());
|
|
|
|
$view->setParam('startfolder', isset($startFolder) ? $startFolder : null);
|
2013-06-07 08:12:49 +00:00
|
|
|
$view->setParam('owner', $owner);
|
2023-04-26 15:35:59 +00:00
|
|
|
$view->setParam('createstartdate', $createstartts);
|
|
|
|
$view->setParam('createenddate', $createendts);
|
|
|
|
$view->setParam('created', $created);
|
2023-05-03 16:24:09 +00:00
|
|
|
$view->setParam('modifystartdate', $modifystartts);
|
|
|
|
$view->setParam('modifyenddate', $modifyendts);
|
|
|
|
$view->setParam('modified', $modified);
|
2021-05-05 12:32:58 +00:00
|
|
|
$view->setParam('expstartdate', !empty($expstartdate) ? getReadableDate($expstartts) : '');
|
|
|
|
$view->setParam('expenddate', !empty($expenddate) ? getReadableDate($expendts) : '');
|
|
|
|
$view->setParam('statusstartdate', !empty($statusstartdate) ? getReadableDate($statusstartts) : '');
|
|
|
|
$view->setParam('statusenddate', !empty($statusenddate) ? getReadableDate($statusendts) : '');
|
2021-11-19 12:49:07 +00:00
|
|
|
$view->setParam('status', $status);
|
2021-12-03 09:48:47 +00:00
|
|
|
$view->setParam('recordtype', isset($record_type) ? $record_type : null);
|
2013-06-07 13:26:09 +00:00
|
|
|
$view->setParam('categories', isset($categories) ? $categories : '');
|
2021-11-19 12:49:07 +00:00
|
|
|
$view->setParam('category', $category);
|
2020-09-12 10:52:44 +00:00
|
|
|
$view->setParam('mimetype', isset($mimetype) ? $mimetype : '');
|
2013-06-07 13:26:09 +00:00
|
|
|
$view->setParam('attributes', isset($attributes) ? $attributes : '');
|
2014-11-13 06:54:35 +00:00
|
|
|
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_document, SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_folder, SeedDMS_Core_AttributeDefinition::objtype_all));
|
2013-06-07 08:12:49 +00:00
|
|
|
$view->setParam('attrdefs', $attrdefs);
|
|
|
|
$allCats = $dms->getDocumentCategories();
|
|
|
|
$view->setParam('allcategories', $allCats);
|
|
|
|
$allUsers = $dms->getAllUsers($settings->_sortUsersInList);
|
|
|
|
$view->setParam('allusers', $allUsers);
|
|
|
|
$view->setParam('workflowmode', $settings->_workflowMode);
|
|
|
|
$view->setParam('enablefullsearch', $settings->_enableFullSearch);
|
2014-04-10 19:38:33 +00:00
|
|
|
$view->setParam('previewWidthList', $settings->_previewWidthList);
|
2023-04-21 17:05:54 +00:00
|
|
|
$view->setParam('convertToPdf', $settings->_convertToPdf);
|
2022-08-18 08:02:13 +00:00
|
|
|
$view->setParam('previewConverters', isset($settings->_converters['preview']) ? $settings->_converters['preview'] : array());
|
|
|
|
$view->setParam('conversionmgr', $conversionmgr);
|
2016-02-15 09:57:37 +00:00
|
|
|
$view->setParam('timeout', $settings->_cmdTimeout);
|
2019-01-18 12:07:39 +00:00
|
|
|
$view->setParam('xsendfile', $settings->_enableXsendfile);
|
2022-08-18 11:18:00 +00:00
|
|
|
$view->setParam('showsinglesearchhit', $settings->_showSingleSearchHit);
|
2015-12-14 08:47:23 +00:00
|
|
|
$view($_GET);
|
2013-01-25 09:34:23 +00:00
|
|
|
exit;
|
|
|
|
}
|
2012-08-28 06:24:05 +00:00
|
|
|
}
|