From 3739f9e658773fc463707d9e6a5d711e2b5656d4 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 3 May 2023 16:21:57 +0200 Subject: [PATCH 1/7] pass modification date to search() functions --- out/out.Search.php | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/out/out.Search.php b/out/out.Search.php index 1d65c6ffb..504af3a41 100644 --- a/out/out.Search.php +++ b/out/out.Search.php @@ -91,6 +91,31 @@ if(!empty($_GET["created"]["to"])) { } /* }}} */ +/* 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; +} +/* }}} */ + // 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 {{{ @@ -291,7 +316,7 @@ if($fullsearch) { $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, 'attributes'=>$attributes), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1)))); + $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))), ['by'=>'', 'dir'=>'desc']); if($searchresult === false) { $session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm'))); $dcount = 0; @@ -581,8 +606,8 @@ if($fullsearch) { 'status'=>$status, 'creationstartdate'=>$created['from'], //$createstartdate ? $createstartdate : array(), 'creationenddate'=>$created['to'], //$createenddate ? $createenddate : array(), - 'modificationstartdate'=>array(), - 'modificationenddate'=>array(), + 'modificationstartdate'=>$modified['from'], + 'modificationenddate'=>$modified['to'], 'categories'=>$categories, 'attributes'=>$attributes, 'mode'=>$resultmode, From 97a3da352ff197ab8fb5d7b229d8cabe4415054e Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 3 May 2023 16:23:11 +0200 Subject: [PATCH 2/7] propperly handle modification date --- views/bootstrap/class.Search.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index ecbd1e8e8..51c6712d4 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -913,7 +913,7 @@ $(document).ready(function() { $option[] = array(array('data-subtitle', $c.' ×')); $options[] = $option; } - } elseif(substr($facetname, 0, 5) == 'attr_' || $facetname == 'created') { + } elseif(substr($facetname, 0, 5) == 'attr_' || $facetname == 'created' || $facetname == 'modified') { /* Do not even create a list of options, because it isn't used */ } else { foreach($values as $v=>$c) { @@ -926,7 +926,7 @@ $(document).ready(function() { $options[] = $option; } } - if(substr($facetname, 0, 5) != 'attr_' && $facetname != 'created') { + if(substr($facetname, 0, 5) != 'attr_' && $facetname != 'created' && $facetname != 'modified') { $this->formField( getMLText($facetname), array( @@ -1115,6 +1115,7 @@ $(document).ready(function() { array_walk($oldtransval, function(&$v, $k){$v = getOverallStatusText($v);}); break; case 'created': + case 'modified': if(!empty($allparams[$facetname]['from']) || !empty($allparams[$facetname]['to'])) { array_walk($allparams[$facetname], function(&$v, $k){$v=getReadableDate($v);}); $oldvalue = $allparams[$facetname]; @@ -1238,7 +1239,7 @@ $(document).ready(function() { } } } - } elseif($facetname == 'created') { + } elseif($facetname == 'created' || $facetname == 'modified') { if(empty($allparams[$facetname]['from']) && empty($allparams[$facetname]['to'])) { $tt = array_keys($values); $content = '
'; @@ -1248,7 +1249,11 @@ $(document).ready(function() { $content .= $this->getDateChooser('', $facetname."[to]", $this->params['session']->getLanguage(), '', '' /*getReadableDate(min($tt))*/, getReadableDate(time()), null, '', true); $content .= ''; $content .= '
'; - $this->printAccordion(getMLText('creation_date'), $content); + if($facetname == 'created') + $this->printAccordion(getMLText('creation_date'), $content); + elseif($facetname == 'modified') { +// $this->printAccordion(getMLText('modification_date'), $content); + } } } else { /* Further filter makes only sense if the facet has more than 1 value From 14afb5f1b7be6a91be17a3da9e91c95c47ece9f5 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 3 May 2023 16:23:37 +0200 Subject: [PATCH 3/7] add more changes for 5.1.31 --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 1229f7584..ef20082a8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ - show preview of document in EditAttributes page - major overhaul of fulltext search, add new search tab for a more facetted based search +- add initial version of Dashboard -------------------------------------------------------------------------------- Changes in version 5.1.30 From 244066d34d2a64f1c4f14172bf7994cc4ab3ba5c Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 3 May 2023 16:24:33 +0200 Subject: [PATCH 4/7] default public status of attachments can be configured --- CHANGELOG | 1 + inc/inc.ClassSettings.php | 4 ++++ op/op.Ajax.php | 2 +- op/op.Settings.php | 1 + out/out.AddFile.php | 1 + views/bootstrap/class.AddFile.php | 3 ++- views/bootstrap/class.Settings.php | 1 + 7 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ef20082a8..aaffebcc9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ - major overhaul of fulltext search, add new search tab for a more facetted based search - add initial version of Dashboard +- default public status of attachments can be configured -------------------------------------------------------------------------------- Changes in version 5.1.30 diff --git a/inc/inc.ClassSettings.php b/inc/inc.ClassSettings.php index 6fad081d4..7172bda3c 100644 --- a/inc/inc.ClassSettings.php +++ b/inc/inc.ClassSettings.php @@ -122,6 +122,8 @@ class Settings { /* {{{ */ var $_proxyPassword = null; // enable removal of file from dropfolder after success import var $_removeFromDropFolder = false; + // uploaded attachements are not public by default + var $_uploadedAttachmentIsPublic = false; // Where the stop word file is located var $_stopWordsFile = null; // enable/disable lucene fulltext search @@ -740,6 +742,7 @@ class Settings { /* {{{ */ $this->_enableDuplicateSubFolderNames = Settings::boolval($tab["enableDuplicateSubFolderNames"]); $this->_overrideMimeType = Settings::boolval($tab["overrideMimeType"]); $this->_removeFromDropFolder = Settings::boolval($tab["removeFromDropFolder"]); + $this->_uploadedAttachmentIsPublic = Settings::boolval($tab["uploadedAttachmentIsPublic"]); } // XML Path: /configuration/advanced/notification @@ -1087,6 +1090,7 @@ class Settings { /* {{{ */ $this->setXMLAttributValue($node, "enableDuplicateSubFolderNames", $this->_enableDuplicateSubFolderNames); $this->setXMLAttributValue($node, "overrideMimeType", $this->_overrideMimeType); $this->setXMLAttributValue($node, "removeFromDropFolder", $this->_removeFromDropFolder); + $this->setXMLAttributValue($node, "uploadedAttachmentIsPublic", $this->_uploadedAttachmentIsPublic); // XML Path: /configuration/advanced/notification $node = $this->getXMLNode($xml, '/configuration/advanced', 'notification'); diff --git a/op/op.Ajax.php b/op/op.Ajax.php index d9dad164e..551749c14 100644 --- a/op/op.Ajax.php +++ b/op/op.Ajax.php @@ -927,7 +927,7 @@ switch($command) { $name = utf8_basename($userfilename); $comment = ''; $version = 0; - $public = false; + $public = $settings->_uploadedAttachmentIsPublic; $res = $document->addDocumentFile($name, $comment, $user, $userfiletmp, utf8_basename($userfilename),$fileType, $userfiletype, $version, $public); if (is_bool($res) && !$res) { diff --git a/op/op.Settings.php b/op/op.Settings.php index b8e06520d..b2a6b23f7 100644 --- a/op/op.Settings.php +++ b/op/op.Settings.php @@ -253,6 +253,7 @@ if ($action == "saveSettings") setBoolValue("enableDuplicateSubFolderNames"); setBoolValue("overrideMimeType"); setBoolValue("removeFromDropFolder"); + setBoolValue("uploadedAttachmentIsPublic"); // SETTINGS - ADVANCED - NOTIFICATION setBoolValue("enableOwnerNotification"); diff --git a/out/out.AddFile.php b/out/out.AddFile.php index 9b24a6a23..53ab2ec3d 100644 --- a/out/out.AddFile.php +++ b/out/out.AddFile.php @@ -55,6 +55,7 @@ if($view) { $view->setParam('document', $document); $view->setParam('strictformcheck', $settings->_strictFormCheck); $view->setParam('enablelargefileupload', $settings->_enableLargeFileUpload); + $view->setParam('uploadedattachmentispublic', $settings->_uploadedAttachmentIsPublic); $view->setParam('accessobject', $accessop); $view($_GET); exit; diff --git a/views/bootstrap/class.AddFile.php b/views/bootstrap/class.AddFile.php index a415a2dfa..a7b375e55 100644 --- a/views/bootstrap/class.AddFile.php +++ b/views/bootstrap/class.AddFile.php @@ -111,6 +111,7 @@ $(document).ready( function() { $document = $this->params['document']; $strictformcheck = $this->params['strictformcheck']; $enablelargefileupload = $this->params['enablelargefileupload']; + $uploadedattachmentispublic = $this->params['uploadedattachmentispublic']; $maxuploadsize = $this->params['maxuploadsize']; $this->htmlAddHeader(''."\n", 'js'); @@ -183,7 +184,7 @@ $(document).ready( function() { 'id'=>'public', 'name'=>'public', 'value'=>'true', - 'checked'=>true, + 'checked'=>$uploadedattachmentispublic, ) ); } diff --git a/views/bootstrap/class.Settings.php b/views/bootstrap/class.Settings.php index a68f7ff3c..1b1354832 100644 --- a/views/bootstrap/class.Settings.php +++ b/views/bootstrap/class.Settings.php @@ -515,6 +515,7 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk)) showConfigCheckbox('settings_enableDuplicateSubFolderNames', 'enableDuplicateSubFolderNames'); ?> showConfigCheckbox('settings_overrideMimeType', 'overrideMimeType'); ?> showConfigCheckbox('settings_removeFromDropFolder', 'removeFromDropFolder'); ?> +showConfigCheckbox('settings_uploadedAttachmentIsPublic', 'uploadedAttachmentIsPublic'); ?>