Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2024-10-07 08:25:46 +02:00
commit 79560a8164
13 changed files with 109 additions and 13 deletions

View File

@ -314,6 +314,8 @@
- clearing cache of js files works for a large number of files
- WebDAV returns `quota-used-bytes` and `quota-available-bytes`
- fix settings SeedDMS attributes in WebDAV server
- propperly check for duplicate folder names in op/op.Ajax.php
- add searching for file size (fulltext search)
--------------------------------------------------------------------------------
Changes in version 5.1.35

View File

@ -1169,10 +1169,10 @@ switch($command) {
$name = utf8_basename($userfilename);
/* Check if name already exists in the folder */
if(!$settings->_enableDuplicateDocNames) {
if($folder->hasDocumentByName($name)) {
if(!$settings->_enableDuplicateSubFolderNames) {
if($folder->hasSubFolderByName($name)) {
header('Content-Type: application/json');
echo json_encode(array('success'=>false, 'message'=>getMLText("document_duplicate_name")));
echo json_encode(array('success'=>false, 'message'=>getMLText("subfolder_duplicate_name")));
exit;
}
}

View File

@ -81,6 +81,7 @@ if($view) {
$view->setParam('folder', $folder);
$view->setParam('converters', $settings->_converters['fulltext']);
$view->setParam('timeout', $settings->_cmdTimeout);
$view->setParam('maxrequests', 1); // not yet used
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;

View File

@ -126,6 +126,21 @@ if(!empty($_GET["modified"]["to"])) {
}
/* }}} */
/* 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"];
}
/* }}} */
// 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 {{{
@ -358,7 +373,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, 'modified_start'=>$modifystartts, 'modified_end'=>$modifyendts, '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'=>$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);
if($searchresult === false) {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
$dcount = 0;
@ -680,6 +695,8 @@ if($fullsearch) {
'creationenddate'=>$created['to'], //$createenddate ? $createenddate : array(),
'modificationstartdate'=>$modified['from'],
'modificationenddate'=>$modified['to'],
'filesizestart'=>$filesize['from'],
'filesizeend'=>$filesize['to'],
'categories'=>$categories,
'attributes'=>$attributes,
'mode'=>$resultmode,
@ -793,6 +810,9 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
$view->setParam('modifystartdate', $modifystartts);
$view->setParam('modifyenddate', $modifyendts);
$view->setParam('modified', $modified);
$view->setParam('filesizestart', $filesizestart);
$view->setParam('filesizeend', $filesizeend);
$view->setParam('filesize', $filesize);
$view->setParam('expstartdate', !empty($expstartdate) ? getReadableDate($expstartts) : '');
$view->setParam('expenddate', !empty($expenddate) ? getReadableDate($expendts) : '');
$view->setParam('statusstartdate', !empty($statusstartdate) ? getReadableDate($statusstartts) : '');

View File

@ -108,7 +108,7 @@ class SeedDMS_View_BackupTools extends SeedDMS_Theme_Style {
print "<th></th>\n";
print "<th>".getMLText("folder")."</th>\n";
print "<th>".getMLText("creation_date")."</th>\n";
print "<th>".getMLText("file_size")."</th>\n";
print "<th>".getMLText("filesize")."</th>\n";
print "<th></th>\n";
print "</tr>\n</thead>\n<tbody>\n";
@ -170,7 +170,7 @@ class SeedDMS_View_BackupTools extends SeedDMS_Theme_Style {
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("creation_date")."</th>\n";
print "<th>".getMLText("file_size")."</th>\n";
print "<th>".getMLText("filesize")."</th>\n";
print "<th></th>\n";
print "</tr>\n</thead>\n<tbody>\n";

View File

@ -1644,6 +1644,7 @@ function getOverallStatusIcon($status) { /* {{{ */
} /* }}} */
function printFileChooserJs() { /* {{{ */
$maxfilesize = $this->getParam('maxfilesize');
?>
$(document).ready(function() {
/* Triggered after the file has been selected */
@ -1651,6 +1652,19 @@ $(document).ready(function() {
var input = $(this),
numFiles = input.get(0).files ? input.get(0).files.length : 1,
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
<?php if($maxfilesize): ?>
if(input.get(0).files[0].size > <?= $maxfilesize ?>) {
noty({
text: "<?= getMLText('uploading_maxsize') ?>",
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
timeout: 1500,
});
return;
}
<?php endif; ?>
input.trigger('fileselect', [numFiles, label]);
});

View File

@ -170,7 +170,7 @@ $('.folderselect').click(function(ev) {
if(is_dir($dir)) {
echo "<table class=\"table table-condensed\">\n";
echo "<thead>\n";
echo "<tr><th></th><th>".getMLText('name')."</th><th align=\"right\">".getMLText('file_size')."</th><th>".getMLText('date')."</th></tr>\n";
echo "<tr><th></th><th>".getMLText('name')."</th><th align=\"right\">".getMLText('filesize')."</th><th>".getMLText('date')."</th></tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
$finfo = finfo_open(FILEINFO_MIME_TYPE);

View File

@ -110,12 +110,13 @@ class SeedDMS_View_Indexer extends SeedDMS_Theme_Style {
function js() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$maxrequests = 5;
header('Content-Type: application/javascript; charset=UTF-8');
?>
var queue_count = 0; // Number of functions being called
var funcArray = []; // Array of functions waiting
var MAX_REQUESTS = 5; // Max requests
var MAX_REQUESTS = <?= $maxrequests ?>; // Max requests
var CALL_WAIT = 20; // 100ms
var docstoindex = 0; // total number of docs to index

View File

@ -43,7 +43,7 @@ class SeedDMS_View_LogManagement extends SeedDMS_Theme_Style {
print "<th></th>\n";
print "<th>".getMLText("name")."</th>\n";
print "<th>".getMLText("creation_date")."</th>\n";
print "<th class=\"d-none d-lg-table-cell\">".getMLText("file_size")."</th>\n";
print "<th class=\"d-none d-lg-table-cell\">".getMLText("filesize")."</th>\n";
print "<th></th>\n";
print "</tr>\n</thead>\n<tbody>\n";
$print_header=false;

View File

@ -74,7 +74,9 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Theme_Style {
if(is_string($txt))
echo $txt;
else {
echo $this->folderListRow($fld, true);
$extracontent = array();
$extracontent['below_title'] = $this->getListRowPath($fld);
echo $this->folderListRow($fld, true, $extracontent);
}
print "<td>";
if ($deleteaction) print "<a href='../op/op.ManageNotify.php?id=".$fld->getID()."&type=folder&action=del' class=\"btn btn-danger btn-mini btn-sm\"><i class=\"fa fa-remove\"></i> ".getMLText("delete")."</a>";
@ -113,7 +115,9 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Theme_Style {
if(is_string($txt))
echo $txt;
else {
echo $this->documentListRow($doc, $previewer, true);
$extracontent = array();
$extracontent['below_title'] = $this->getListRowPath($doc);
echo $this->documentListRow($doc, $previewer, true, 0, $extracontent);
}
print "<td>";
if ($deleteaction) print "<a href='../op/op.ManageNotify.php?id=".$doc->getID()."&type=document&action=del' class=\"btn btn-danger btn-mini btn-sm\"><i class=\"fa fa-remove\"></i> ".getMLText("delete")."</a>";

View File

@ -480,6 +480,7 @@ $(document).ready(function() {
$modifystartdate = $this->params['modifystartdate'];
$modifyenddate = $this->params['modifyenddate'];
$modified = $this->params['modified'];
$filesize = $this->params['filesize'];
$expstartdate = $this->params['expstartdate'];
$expenddate = $this->params['expenddate'];
$statusstartdate = $this->params['statusstartdate'];
@ -907,6 +908,24 @@ $(document).ready(function() {
getMLText("modification_date")." (".getMLText('to').")",
$this->getDateChooser(!empty($modified['to']) ? getReadableDate($modified['to']) : null, "modified[to]", $this->params['session']->getLanguage())
);
$this->formField(
getMLText("filesize")." (".getMLText('from').")",
array(
'element'=>'input',
'type'=>'number',
'name'=>'filesize[from]',
'value'=>$filesize['from']
)
);
$this->formField(
getMLText("filesize")." (".getMLText('to').")",
array(
'element'=>'input',
'type'=>'number',
'name'=>'filesize[to]',
'value'=>$filesize['to']
)
);
if(!isset($facets['owner'])) {
$options = array();
foreach ($allUsers as $currUser) {
@ -1028,7 +1047,7 @@ $(document).ready(function() {
$option[] = array(array('data-subtitle', $c.' ×'));
$options[] = $option;
}
} elseif(substr($facetname, 0, 5) == 'attr_' || $facetname == 'created' || $facetname == 'modified') {
} elseif(substr($facetname, 0, 5) == 'attr_' || $facetname == 'created' || $facetname == 'modified' || $facetname == 'filesize') {
/* Do not even create a list of options, because it isn't used */
} else {
foreach($values as $v=>$c) {
@ -1041,7 +1060,7 @@ $(document).ready(function() {
$options[] = $option;
}
}
if(substr($facetname, 0, 5) != 'attr_' && $facetname != 'created' && $facetname != 'modified') {
if(substr($facetname, 0, 5) != 'attr_' && $facetname != 'created' && $facetname != 'modified' && $facetname != 'filesize') {
$this->formField(
getMLText($facetname),
array(
@ -1258,6 +1277,14 @@ $(document).ready(function() {
$oldvalue = null;
}
break;
case 'filesize':
if(!empty($allparams[$facetname]['from']) || !empty($allparams[$facetname]['to'])) {
$oldvalue = $allparams[$facetname];
$oldtransval = $oldvalue; //$oldvalue['from'].' TO '.$oldvalue['to'];
} else {
$oldvalue = null;
}
break;
default:
$oldvalue = is_array($allparams[$facetname]) ? $allparams[$facetname] : [$allparams[$facetname]];
$oldtransval = $oldvalue;
@ -1390,6 +1417,18 @@ $(document).ready(function() {
$this->printAccordion(getMLText('modification_date'), $content);
}
}
} elseif($facetname == 'filesize') {
if(empty($allparams[$facetname]['from']) && empty($allparams[$facetname]['to'])) {
$tt = array_keys($values);
$content = '<div class="input-group">';
$content .= '<span class="input-group-text" style="border-right: 0;"> from </span>';
$content .= '<input class="form-control" name="'.$facetname.'[from]" type="text" value="">';
$content .= '<span class="input-group-text" style="border-left: 0; border-right: 0;"> to </span>';
$content .= '<input class="form-control" name="'.$facetname.'[to]" type="text" value="">';
$content .= '<button class="btn btn-primary" type="submit">Set</button>';
$content .= '</div>';
$this->printAccordion(getMLText('filesize'), $content);
}
} else {
/* Further filter makes only sense if the facet has more than 1 value
* or in case of 1 value, if that value has a count < $total. That second

View File

@ -1564,6 +1564,7 @@ function getOverallStatusIcon($status) { /* {{{ */
} /* }}} */
function printFileChooserJs() { /* {{{ */
$maxfilesize = $this->getParam('maxfilesize');
?>
$(document).ready(function() {
/* do not use bootstrap4 custom form element because it is difficult to localize
@ -1579,6 +1580,19 @@ $(document).ready(function() {
var input = $(this),
numFiles = input.get(0).files ? input.get(0).files.length : 1,
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
<?php if($maxfilesize): ?>
if(input.get(0).files[0].size > <?= $maxfilesize ?>) {
noty({
text: "<?= getMLText('uploading_maxsize') ?>",
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
timeout: 1500,
});
return;
}
<?php endif; ?>
input.trigger('fileselect', [numFiles, label]);
});

View File

@ -207,6 +207,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
$this->logger->log('check_auth: type='.$type.', user='.$user.' authenticated', PEAR_LOG_INFO);
$this->user = $controller->getUser();
/* Get diskspace and quota for later PROPFIND calls */
$this->diskspace = $this->user->getUsedDiskSpace();
$this->quota = $this->user->getQuota();
if(!$this->user) {