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

This commit is contained in:
Uwe Steinmann 2022-09-14 20:42:30 +02:00
commit 2ee4773357
4 changed files with 110 additions and 24 deletions

View File

@ -22,7 +22,7 @@
*/
class SeedDMS_Controller_Preview extends SeedDMS_Controller_Common {
public function version() {
public function version() { /* {{{ */
$dms = $this->params['dms'];
$settings = $this->params['settings'];
$conversionmgr = $this->params['conversionmgr'];
@ -72,7 +72,7 @@ class SeedDMS_Controller_Preview extends SeedDMS_Controller_Common {
}
} /* }}} */
public function file() {
public function file() { /* {{{ */
$dms = $this->params['dms'];
$settings = $this->params['settings'];
$conversionmgr = $this->params['conversionmgr'];

View File

@ -140,7 +140,7 @@ switch($command) {
if($hits) {
$result = array();
foreach($hits['docs'] as $hit) {
if ($hit->getAccessMode($user) >= M_READ) {
if($hit->getAccessMode($user, 'search') >= M_READ) {
if($hit->getLatestContent()) {
$result[] = $hit->getID().'#'.$hit->getName();
}
@ -164,26 +164,30 @@ switch($command) {
if(count($hits['folders']) == 1) {
$hit = $hits['folders'][0];
$basefolder = $dms->getFolder($hit->getID());
if($subquery = substr($query, $pos+1)) {
$hits = $dms->search($subquery, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=$basefolder, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array());
if($hits) {
if($basefolder->getAccessMode($user, 'search') >= M_READ) {
if($subquery = substr($query, $pos+1)) {
$hits = $dms->search($subquery, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=$basefolder, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array());
if($hits) {
$result = array();
foreach($hits['folders'] as $hit) {
if($hit->getAccessMode($user, 'search') >= M_READ)
$result[] = $hit->getID().'#'.$basefolder->getName().'/'.$hit->getName();
}
header('Content-Type: application/json');
echo json_encode($result);
return;
}
} else {
$subfolders = $basefolder->getSubFolders();
$subfolders = SeedDMS_Core_DMS::filterAccess($subfolders, $user, M_READ);
$result = array();
foreach($hits['folders'] as $hit) {
$result[] = $hit->getID().'#'.$basefolder->getName().'/'.$hit->getName();
foreach($subfolders as $subfolder) {
$result[] = $subfolder->getID().'#'.$basefolder->getName().'/'.$subfolder->getName();
}
header('Content-Type: application/json');
echo json_encode($result);
return;
}
} else {
$subfolders = $basefolder->getSubFolders();
$result = array();
foreach($subfolders as $subfolder) {
$result[] = $subfolder->getID().'#'.$basefolder->getName().'/'.$subfolder->getName();
}
header('Content-Type: application/json');
echo json_encode($result);
return;
}
}
}
@ -192,7 +196,8 @@ switch($command) {
if($hits) {
$result = array();
foreach($hits['folders'] as $hit) {
$result[] = $hit->getID().'#'.$hit->getName();
if($hit->getAccessMode($user, 'search') >= M_READ)
$result[] = $hit->getID().'#'.$hit->getName();
}
header('Content-Type: application/json');
echo json_encode($result);

View File

@ -58,6 +58,15 @@ if (isset($_GET["newowner"]) && is_numeric($_GET["newowner"]) && $_GET['newowner
$newowner = $dms->getUser((int) $_GET['newowner']);
}
$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'];
}
$fullsearch = ((!isset($_GET["fullsearch"]) && $settings->_defaultSearchMethod == 'fulltext') || !empty($_GET["fullsearch"])) && $settings->_enableFullSearch;
if($fullsearch) {
// Search in Fulltext {{{
@ -598,6 +607,8 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
$view->setParam('includecontent', $includecontent);
$view->setParam('marks', isset($_GET['marks']) ? $_GET['marks'] : array());
$view->setParam('newowner', $newowner);
$view->setParam('changecategory', $changecategory);
$view->setParam('removecategory', $removecategory);
$view->setParam('searchhits', $entries);
$view->setParam('totalpages', $totalPages);
$view->setParam('pagenumber', $pageNumber);

View File

@ -67,7 +67,6 @@ $(document).ready( function() {
var inputs = $('input[name^=\"marks\"]');
var values = {};
inputs.each(function() {
console.log(this.name+'='+this.checked);
if(this.checked)
values[this.name] = 1;
});
@ -75,22 +74,20 @@ $(document).ready( function() {
window.location.href = url;
});
/*
$('#changeowner').on('click', function(e) {
$('#changecategory').on('click', function(e) {
e.preventDefault();
var url = "";
url = $(this).attr('href')+'&newowner='+($('#newowner').val());
url = $(this).attr('href')+'&changecategory='+$('#batchcategory').val()+'&removecategory='+($('#removecategory').prop('checked') ? '1' : '0');
var inputs = $('input[name^=\"marks\"]');
var values = {};
inputs.each(function() {
console.log(this.name+'='+this.checked);
if(this.checked)
values[this.name] = 1;
});
url += '&'+$.param(values);
window.location.href = url;
});
*/
<?php if($this->getParam('theme') !== 'bootstrap4'): ?>
$('body').on('click', 'a.change-owner-btn', function(ev){
ev.preventDefault();
@ -292,6 +289,44 @@ $(document).ready(function() {
return self::show();
} /* }}} */
function changecategory() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$entries = $this->params['searchhits'];
$changecategory = $this->params['changecategory'];
$removecategory = $this->params['removecategory'];
$marks = $this->params['marks'];
if($changecategory && $user->isAdmin()) {
$j = $i = 0;
foreach($entries as $entry) {
if($entry->isType('document')) {
if(empty($marks) || !empty($marks['D'.$entry->getId()])) {
if(!$removecategory) {
if(!$entry->hasCategory($changecategory)) {
$entry->addCategories([$changecategory]);
$j++;
}
} else {
if($entry->hasCategory($changecategory)) {
$entry->removeCategories([$changecategory]);
$j++;
}
}
}
}
}
if($removecategory) {
$this->setParam('batchmsg', getMLText('batch_remove_category_msg', ['count'=>$j, 'catname'=>$changecategory->getName()]));
} else {
$this->setParam('batchmsg', getMLText('batch_add_category_msg', ['count'=>$j, 'catname'=>$changecategory->getName()]));
}
} else {
}
return self::show();
} /* }}} */
function opensearchsuggestion() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
@ -931,6 +966,41 @@ function typeahead() { /* {{{ */
$content = ob_get_clean();
$this->printAccordion(getMLText('batch_change_owner'), $content);
ob_start();
$cats = $dms->getDocumentCategories();
$options = array();
$options[] = array("-1", getMLText("choose_category"));
foreach ($cats as $currcat) {
$options[] = array($currcat->getID(), htmlspecialchars($currcat->getName()), false);
}
$this->formField(
null,
array(
'element'=>'select',
'id'=>'batchcategory',
'class'=>'chzn-select',
'options'=>$options,
'multiple'=>false,
'placeholder'=>getMLText('select_category'),
'attributes'=>array(array('style', 'width: 100%;'))
)
);
$this->formField(
getMLText("batch_remove_category"),
array(
'element'=>'input',
'type'=>'checkbox',
'id'=>'removecategory',
'value'=>'1',
)
);
// print $this->html_link('Search', array_merge($_GET, array('action'=>'changeowner')), array('class'=>'btn btn-primary', 'id'=>'changeowner'), "<i class=\"fa fa-user\"></i> ".getMLText("batch_change_owner"), false, true)."\n";
print $this->html_link('Search', array_merge($_GET, array('action'=>'changecategory')), array('class'=>'btn btn-primary change-category-btn mt-4', 'id'=>'changecategory'), "<i class=\"fa fa-user\"></i> ".getMLText("batch_change_category"), false, true)."\n";
$content = ob_get_clean();
$this->printAccordion(getMLText('batch_change_category'), $content);
}
// }}}