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.LogInit.php");
|
|
|
|
require_once("inc/inc.Utils.php");
|
|
|
|
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.ClassAccessOperation.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"];
|
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
/*
|
2011-03-10 14:13:39 +00:00
|
|
|
if(strlen($_GET["query"])==0) {
|
|
|
|
header("Location: ../out/out.SearchForm.php?folderid=".$folderid);
|
|
|
|
} else {
|
2012-12-14 08:08:03 +00:00
|
|
|
if(isset($_GET["fullsearch"]) && $_GET["fullsearch"]) {
|
2011-03-10 14:13:39 +00:00
|
|
|
header("Location: ../op/op.SearchFulltext.php?folderid=".$folderid."&query=".$_GET["query"]);
|
|
|
|
}
|
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
*/
|
2011-03-10 14:13:39 +00:00
|
|
|
}
|
|
|
|
|
2016-02-03 13:46:06 +00:00
|
|
|
if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSearch) {
|
2013-06-07 08:12:49 +00:00
|
|
|
// Search in Fulltext {{{
|
|
|
|
if (isset($_GET["query"]) && is_string($_GET["query"])) {
|
|
|
|
$query = $_GET["query"];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$query = "";
|
|
|
|
}
|
2011-03-10 14:13:39 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
// category
|
|
|
|
$categories = array();
|
2013-06-14 14:06:52 +00:00
|
|
|
$categorynames = array();
|
2013-06-07 08:12:49 +00:00
|
|
|
if(isset($_GET['categoryids']) && $_GET['categoryids']) {
|
|
|
|
foreach($_GET['categoryids'] as $catid) {
|
|
|
|
if($catid > 0) {
|
|
|
|
$category = $dms->getDocumentCategory($catid);
|
2013-06-14 14:06:52 +00:00
|
|
|
$categories[] = $category;
|
|
|
|
$categorynames[] = $category->getName();
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
|
|
|
}
|
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"];
|
|
|
|
}
|
|
|
|
else if (!strcasecmp($_GET["pg"], "all")) {
|
|
|
|
$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
|
|
|
|
// document owner.
|
|
|
|
$owner = null;
|
|
|
|
if (isset($_GET["ownerid"]) && is_numeric($_GET["ownerid"]) && $_GET["ownerid"]!=-1) {
|
|
|
|
$owner = $dms->getUser($_GET["ownerid"]);
|
|
|
|
if (!is_object($owner)) {
|
|
|
|
UI::exitError(getMLText("search_results"),getMLText("unknown_owner"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$startTime = getTime();
|
|
|
|
if($settings->_enableFullSearch) {
|
2015-08-10 19:43:15 +00:00
|
|
|
if($settings->_fullSearchEngine == 'lucene') {
|
|
|
|
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
|
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
|
|
|
|
2013-06-17 08:49:55 +00:00
|
|
|
if(strlen($query) < 4 && strpos($query, '*')) {
|
|
|
|
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
|
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();
|
2015-08-10 19:43:15 +00:00
|
|
|
$index = $indexconf['Indexer']::open($settings->_luceneDir);
|
|
|
|
$lucenesearch = new $indexconf['Search']($index);
|
2013-06-17 08:49:55 +00:00
|
|
|
$hits = $lucenesearch->search($query, $owner ? $owner->getLogin() : '', '', $categorynames);
|
2013-08-13 20:09:40 +00:00
|
|
|
if($hits === false) {
|
|
|
|
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
|
2015-09-28 10:32:41 +00:00
|
|
|
$totalPages = 0;
|
2013-08-13 20:09:40 +00:00
|
|
|
$entries = array();
|
|
|
|
$searchTime = 0;
|
2013-06-17 08:49:55 +00:00
|
|
|
} else {
|
2013-08-13 20:09:40 +00:00
|
|
|
$entries = array();
|
2015-08-19 18:15:04 +00:00
|
|
|
$dcount = 0;
|
|
|
|
$fcount = 0;
|
2013-08-13 20:09:40 +00:00
|
|
|
if($hits) {
|
|
|
|
foreach($hits as $hit) {
|
|
|
|
if($tmp = $dms->getDocument($hit['document_id'])) {
|
|
|
|
if($tmp->getAccessMode($user) >= M_READ) {
|
2016-02-09 16:33:23 +00:00
|
|
|
$tmp->verifyLastestContentExpriry();
|
2013-08-13 20:09:40 +00:00
|
|
|
$entries[] = $tmp;
|
2015-08-19 18:15:04 +00:00
|
|
|
$dcount++;
|
2013-08-13 20:09:40 +00:00
|
|
|
}
|
2013-06-17 08:49:55 +00:00
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
2010-11-05 21:41:37 +00:00
|
|
|
}
|
2015-09-28 10:32:41 +00:00
|
|
|
$limit = 20;
|
|
|
|
if($pageNumber != 'all' && count($entries) > $limit) {
|
|
|
|
$totalPages = (int) (count($entries)/$limit);
|
|
|
|
if(count($entries)%$limit)
|
|
|
|
$totalPages++;
|
|
|
|
if($limit > 0)
|
|
|
|
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
|
|
|
|
} else {
|
|
|
|
$totalPages = 1;
|
|
|
|
}
|
2010-11-05 21:41:37 +00:00
|
|
|
}
|
2013-06-17 08:49:55 +00:00
|
|
|
$searchTime = getTime() - $startTime;
|
|
|
|
$searchTime = round($searchTime, 2);
|
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
|
|
|
|
2019-06-26 16:03:07 +00:00
|
|
|
if (isset($_GET["orderby"]) && is_string($_GET["orderby"])) {
|
|
|
|
$orderby = $_GET["orderby"];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$orderby = "";
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
$targetid = $settings->_rootFolderID;
|
|
|
|
$startFolder = $dms->getFolder($targetid);
|
|
|
|
}
|
|
|
|
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
|
|
|
|
// document owner.
|
|
|
|
$owner = null;
|
|
|
|
if (isset($_GET["ownerid"]) && is_numeric($_GET["ownerid"]) && $_GET["ownerid"]!=-1) {
|
|
|
|
$owner = $dms->getUser($_GET["ownerid"]);
|
|
|
|
if (!is_object($owner)) {
|
2015-11-16 07:08:30 +00:00
|
|
|
UI::exitError(getMLText("search"),getMLText("unknown_owner"));
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is the search restricted to documents created between two specific dates?
|
|
|
|
$startdate = array();
|
|
|
|
$stopdate = array();
|
|
|
|
if (isset($_GET["creationdate"]) && $_GET["creationdate"]!=null) {
|
|
|
|
$creationdate = true;
|
|
|
|
} else {
|
|
|
|
$creationdate = false;
|
2010-11-05 21:41:37 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 10:13:08 +00:00
|
|
|
if(isset($_GET["createstart"])) {
|
|
|
|
$tmp = explode("-", $_GET["createstart"]);
|
2015-10-30 07:02:57 +00:00
|
|
|
$startdate = array('year'=>(int)$tmp[0], 'month'=>(int)$tmp[1], 'day'=>(int)$tmp[2], 'hour'=>0, 'minute'=>0, 'second'=>0);
|
2013-01-24 10:13:08 +00:00
|
|
|
} else {
|
2013-06-07 08:12:49 +00:00
|
|
|
if(isset($_GET["createstartyear"]))
|
|
|
|
$startdate = array('year'=>$_GET["createstartyear"], 'month'=>$_GET["createstartmonth"], 'day'=>$_GET["createstartday"], 'hour'=>0, 'minute'=>0, 'second'=>0);
|
2013-01-24 10:13:08 +00:00
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
if ($startdate && !checkdate($startdate['month'], $startdate['day'], $startdate['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
|
|
|
}
|
2013-01-24 10:13:08 +00:00
|
|
|
if(isset($_GET["createend"])) {
|
|
|
|
$tmp = explode("-", $_GET["createend"]);
|
2015-10-30 07:02:57 +00:00
|
|
|
$stopdate = array('year'=>(int)$tmp[0], 'month'=>(int)$tmp[1], 'day'=>(int)$tmp[2], 'hour'=>23, 'minute'=>59, 'second'=>59);
|
2013-01-24 10:13:08 +00:00
|
|
|
} else {
|
2013-06-07 08:12:49 +00:00
|
|
|
if(isset($_GET["createendyear"]))
|
|
|
|
$stopdate = array('year'=>$_GET["createendyear"], 'month'=>$_GET["createendmonth"], 'day'=>$_GET["createendday"], 'hour'=>23, 'minute'=>59, 'second'=>59);
|
2013-01-24 10:13:08 +00:00
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
if ($stopdate && !checkdate($stopdate['month'], $stopdate['day'], $stopdate['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
|
|
|
}
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
$expstartdate = array();
|
|
|
|
$expstopdate = array();
|
|
|
|
if (isset($_GET["expirationdate"]) && $_GET["expirationdate"]!=null) {
|
|
|
|
$expirationdate = true;
|
|
|
|
} else {
|
|
|
|
$expirationdate = false;
|
|
|
|
}
|
|
|
|
|
2013-01-24 10:13:08 +00:00
|
|
|
if(isset($_GET["expirationstart"]) && $_GET["expirationstart"]) {
|
|
|
|
$tmp = explode("-", $_GET["expirationstart"]);
|
2015-11-16 07:02:32 +00:00
|
|
|
$expstartdate = array('year'=>(int)$tmp[0], 'month'=>(int)$tmp[1], 'day'=>(int)$tmp[2], '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"));
|
|
|
|
}
|
|
|
|
} else {
|
2013-06-14 14:06:52 +00:00
|
|
|
// $expstartdate = array('year'=>$_GET["expirationstartyear"], 'month'=>$_GET["expirationstartmonth"], 'day'=>$_GET["expirationstartday"], 'hour'=>0, 'minute'=>0, 'second'=>0);
|
2013-01-24 10:13:08 +00:00
|
|
|
$expstartdate = array();
|
|
|
|
}
|
|
|
|
if(isset($_GET["expirationend"]) && $_GET["expirationend"]) {
|
|
|
|
$tmp = explode("-", $_GET["expirationend"]);
|
2015-11-16 07:02:32 +00:00
|
|
|
$expstopdate = array('year'=>(int)$tmp[0], 'month'=>(int)$tmp[1], 'day'=>(int)$tmp[2], 'hour'=>0, 'minute'=>0, 'second'=>0);
|
2013-01-24 10:13:08 +00:00
|
|
|
if (!checkdate($expstopdate['month'], $expstopdate['day'], $expstopdate['year'])) {
|
|
|
|
UI::exitError(getMLText("search"),getMLText("invalid_expiration_date_end"));
|
|
|
|
}
|
|
|
|
} else {
|
2013-06-14 14:06:52 +00:00
|
|
|
//$expstopdate = array('year'=>$_GET["expirationendyear"], 'month'=>$_GET["expirationendmonth"], 'day'=>$_GET["expirationendday"], 'hour'=>23, 'minute'=>59, 'second'=>59);
|
2013-01-24 10:13:08 +00:00
|
|
|
$expstopdate = array();
|
|
|
|
}
|
2011-03-10 14:13:39 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
// status
|
|
|
|
$status = array();
|
|
|
|
if (isset($_GET["pendingReview"])){
|
|
|
|
$status[] = S_DRAFT_REV;
|
|
|
|
}
|
|
|
|
if (isset($_GET["pendingApproval"])){
|
|
|
|
$status[] = S_DRAFT_APP;
|
|
|
|
}
|
|
|
|
if (isset($_GET["inWorkflow"])){
|
|
|
|
$status[] = S_IN_WORKFLOW;
|
|
|
|
}
|
|
|
|
if (isset($_GET["released"])){
|
|
|
|
$status[] = S_RELEASED;
|
|
|
|
}
|
|
|
|
if (isset($_GET["rejected"])){
|
|
|
|
$status[] = S_REJECTED;
|
|
|
|
}
|
|
|
|
if (isset($_GET["obsolete"])){
|
|
|
|
$status[] = S_OBSOLETE;
|
|
|
|
}
|
|
|
|
if (isset($_GET["expired"])){
|
|
|
|
$status[] = S_EXPIRED;
|
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;
|
2012-10-09 09:59:25 +00:00
|
|
|
|
2013-06-07 08:12:49 +00:00
|
|
|
// category
|
|
|
|
$categories = array();
|
|
|
|
if(isset($_GET['categoryids']) && $_GET['categoryids']) {
|
|
|
|
foreach($_GET['categoryids'] as $catid) {
|
|
|
|
if($catid > 0)
|
|
|
|
$categories[] = $dms->getDocumentCategory($catid);
|
|
|
|
}
|
2010-11-05 21:41:37 +00:00
|
|
|
}
|
2013-06-07 08:12:49 +00:00
|
|
|
|
|
|
|
/* Do not search for folders if result shall be filtered by categories. */
|
2014-07-23 18:51:45 +00:00
|
|
|
// if($categories)
|
|
|
|
// $resultmode = 0x01;
|
2013-06-07 08:12:49 +00:00
|
|
|
|
|
|
|
if (isset($_GET["attributes"]))
|
|
|
|
$attributes = $_GET["attributes"];
|
|
|
|
else
|
|
|
|
$attributes = array();
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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;
|
|
|
|
$limit = 15;
|
|
|
|
if (isset($_GET["pg"])) {
|
|
|
|
if (is_numeric($_GET["pg"]) && $_GET["pg"]>0) {
|
|
|
|
$pageNumber = (int) $_GET["pg"];
|
|
|
|
}
|
|
|
|
elseif (!strcasecmp($_GET["pg"], "all")) {
|
2015-12-14 10:46:29 +00:00
|
|
|
// $limit = 0;
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
2010-11-05 21:41:37 +00:00
|
|
|
}
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2010-11-05 21:41:37 +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,
|
|
|
|
'owner'=>$owner,
|
|
|
|
'status'=>$status,
|
|
|
|
'creationstartdate'=>$creationdate ? $startdate : array(),
|
|
|
|
'creationenddate'=>$creationdate ? $stopdate : array(),
|
|
|
|
'modificationstartdate'=>array(),
|
|
|
|
'modificationenddate'=>array(),
|
|
|
|
'categories'=>$categories,
|
|
|
|
'attributes'=>$attributes,
|
|
|
|
'mode'=>$resultmode,
|
|
|
|
'expirationstartdate'=>$expirationdate ? $expstartdate : array(),
|
|
|
|
'expirationenddate'=>$expirationdate ? $expstopdate : array(),
|
|
|
|
'orderby'=>$orderby
|
|
|
|
));
|
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;
|
2013-06-07 08:12:49 +00:00
|
|
|
if($resArr['folders']) {
|
|
|
|
foreach ($resArr['folders'] as $entry) {
|
|
|
|
if ($entry->getAccessMode($user) >= M_READ) {
|
|
|
|
$entries[] = $entry;
|
2015-03-17 05:36:33 +00:00
|
|
|
$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) {
|
2016-02-16 11:21:48 +00:00
|
|
|
$entry->verifyLastestContentExpriry();
|
2013-06-07 08:12:49 +00:00
|
|
|
$entries[] = $entry;
|
2015-03-17 05:36:33 +00:00
|
|
|
$dcount++;
|
2013-06-07 08:12:49 +00:00
|
|
|
}
|
2012-08-28 06:24:05 +00:00
|
|
|
}
|
|
|
|
}
|
2017-10-26 04:32:36 +00:00
|
|
|
if (!isset($_GET["pg"]) || strcasecmp($_GET["pg"], "all")) {
|
|
|
|
$totalPages = (int) (count($entries)/$limit);
|
|
|
|
if(count($entries)%$limit)
|
|
|
|
$totalPages++;
|
2015-03-17 05:36:33 +00:00
|
|
|
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
|
2017-10-26 04:32:36 +00:00
|
|
|
} else
|
|
|
|
$totalPages = 1;
|
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];
|
2015-02-05 06:38:56 +00:00
|
|
|
if(get_class($entry) == $dms->getClassname('document')) {
|
2013-01-25 09:34:23 +00:00
|
|
|
header('Location: ../out/out.ViewDocument.php?documentid='.$entry->getID());
|
|
|
|
exit;
|
2015-02-05 06:38:56 +00:00
|
|
|
} elseif(get_class($entry) == $dms->getClassname('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']));
|
2015-03-17 05:36:33 +00:00
|
|
|
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'query'=>$query, 'searchhits'=>$entries, 'totalpages'=>$totalPages, 'pagenumber'=>$pageNumber, 'searchtime'=>$searchTime, 'urlparams'=>$_GET, 'cachedir'=>$settings->_cacheDir));
|
2013-01-25 09:34:23 +00:00
|
|
|
if($view) {
|
2019-06-26 16:03:07 +00:00
|
|
|
$view->setParam('showtree', showtree());
|
|
|
|
$view->setParam('enableRecursiveCount', $settings->_enableRecursiveCount);
|
|
|
|
$view->setParam('maxRecursiveCount', $settings->_maxRecursiveCount);
|
2015-03-17 05:36:33 +00:00
|
|
|
$view->setParam('totaldocs', $dcount /*resArr['totalDocs']*/);
|
|
|
|
$view->setParam('totalfolders', $fcount /*resArr['totalFolders']*/);
|
2016-02-03 13:46:06 +00:00
|
|
|
$view->setParam('fullsearch', (isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSearch) ? true : false);
|
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 : '');
|
2016-02-03 13:46:06 +00:00
|
|
|
$view->setParam('defaultsearchmethod', $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);
|
2013-06-07 13:26:09 +00:00
|
|
|
$view->setParam('startdate', isset($startdate) ? $startdate : array());
|
|
|
|
$view->setParam('stopdate', isset($stopdate) ? $stopdate : array());
|
|
|
|
$view->setParam('expstartdate', isset($expstartdate) ? $expstartdate : array());
|
|
|
|
$view->setParam('expstopdate', isset($expstopdate) ? $expstopdate : array());
|
|
|
|
$view->setParam('creationdate', isset($creationdate) ? $creationdate : '');
|
|
|
|
$view->setParam('expirationdate', isset($expirationdate) ? $expirationdate: '');
|
|
|
|
$view->setParam('status', isset($status) ? $status : array());
|
|
|
|
$view->setParam('categories', isset($categories) ? $categories : '');
|
|
|
|
$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);
|
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);
|
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
|
|
|
}
|
2011-03-10 14:13:39 +00:00
|
|
|
?>
|