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

This commit is contained in:
Uwe Steinmann 2022-07-08 18:46:17 +02:00
commit 418c42ae59
5 changed files with 227 additions and 71 deletions

View File

@ -22,41 +22,64 @@
*/
class SeedDMS_Controller_EmptyFolder extends SeedDMS_Controller_Common {
public function run() {
/* Register a callback which removes each document/folder from the fulltext index
* The callback must return null otherwise the removal will be canceled.
*/
static function removeFromIndex($arr, $object) { /* {{{ */
$fulltextservice = $arr[0];
$lucenesearch = $fulltextservice->Search();
$hit = null;
if($object->isType('document'))
$hit = $lucenesearch->getDocument($object->getID());
elseif($object->isType('folder'))
$hit = $lucenesearch->getFolder($object->getID());
if($hit) {
$index = $fulltextservice->Indexer();
$index->delete($hit->id);
$index->commit();
}
return null;
} /* }}} */
static function removePreviews($arr, $document) { /* {{{ */
$previewer = $arr[0];
$previewer->deleteDocumentPreviews($document);
return null;
} /* }}} */
public function run() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$settings = $this->params['settings'];
$folder = $this->params['folder'];
$index = $this->params['index'];
$indexconf = $this->params['indexconf'];
$fulltextservice = $this->params['fulltextservice'];
/* Get the document id and name before removing the document */
/* Get the folder id and name before removing the folder */
$foldername = $folder->getName();
$folderid = $folder->getID();
if(false === $this->callHook('preEmptyFolder')) {
if(empty($this->errormsg))
$this->errormsg = 'hook_preEmptyFolder_failed';
return null;
return false;
}
$result = $this->callHook('emptyFolder', $folder);
if($result === null) {
/* Register a callback which removes each document from the fulltext index
* The callback must return null other the removal will be canceled.
*/
function removeFromIndex($arr, $document) {
$index = $arr[0];
$indexconf = $arr[1];
$lucenesearch = new $indexconf['Search']($index);
if($hit = $lucenesearch->getDocument($document->getID())) {
$index->delete($hit->id);
$index->commit();
}
return null;
if($fulltextservice && ($index = $fulltextservice->Indexer())) {
/* Register a callback which is called by SeedDMS_Core when a folder
* or document is removed. The second parameter passed to this callback
* is the document or folder to be removed.
*/
$dms->addCallback('onPreRemoveDocument', 'SeedDMS_Controller_EmptyFolder::removeFromIndex', array($fulltextservice));
$dms->addCallback('onPreRemoveFolder', 'SeedDMS_Controller_EmptyFolder::removeFromIndex', array($fulltextservice));
}
if($index)
$dms->setCallback('onPreEmptyDocument', 'removeFromIndex', array($index, $indexconf));
/* Register another callback which removes the preview images of the document */
require_once("SeedDMS/Preview.php");
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir);
$dms->addCallback('onPreRemoveDocument', 'SeedDMS_Controller_EmptyFolder::removePreviews', array($previewer));
if (!$folder->emptyFolder()) {
$this->errormsg = 'error_occured';
@ -72,5 +95,5 @@ class SeedDMS_Controller_EmptyFolder extends SeedDMS_Controller_Common {
}
return true;
}
} /* }}} */
}

View File

@ -22,17 +22,17 @@
*/
class SeedDMS_Controller_RemoveFolder extends SeedDMS_Controller_Common {
/* Register a callback which removes each document from the fulltext index
/* Register a callback which removes each document/folder from the fulltext index
* The callback must return null otherwise the removal will be canceled.
*/
static function removeFromIndex($arr, $document) { /* {{{ */
static function removeFromIndex($arr, $object) { /* {{{ */
$fulltextservice = $arr[0];
$lucenesearch = $fulltextservice->Search();
$hit = null;
if($document->isType('document'))
$hit = $lucenesearch->getDocument($document->getID());
elseif($document->isType('folder'))
$hit = $lucenesearch->getFolder($document->getID());
if($object->isType('document'))
$hit = $lucenesearch->getDocument($object->getID());
elseif($object->isType('folder'))
$hit = $lucenesearch->getFolder($object->getID());
if($hit) {
$index = $fulltextservice->Indexer();
$index->delete($hit->id);
@ -55,7 +55,7 @@ class SeedDMS_Controller_RemoveFolder extends SeedDMS_Controller_Common {
$folder = $this->params['folder'];
$fulltextservice = $this->params['fulltextservice'];
/* Get the document id and name before removing the document */
/* Get the folder id and name before removing the folder */
$foldername = $folder->getName();
$folderid = $folder->getID();

View File

@ -88,6 +88,8 @@ if ($notifier) {
$notifier->sendDeleteFolderMail($folder, $user);
}
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_rm_folder')));
add_log_line("?folderid=".$folderid."&name=".$foldername);
header("Location:../out/out.ViewFolder.php?folderid=".$parent->getID()."&showtree=".$_POST["showtree"]);

View File

@ -777,9 +777,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$menuitems['index_folder'] = array('link'=>$this->params['settings']->_httpRoot."out/out.Indexer.php?folderid=". $folderID."&showtree=".showtree(), 'label'=>getMLText('index_folder'));
}
/* Check if hook exists because otherwise callHook() will override $menuitems */
if($this->hasHook('folderNavigationBar'))
$menuitems = $this->callHook('folderNavigationBar', $folder, $menuitems);
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'folderNavigationBar')) {
$menuitems = $hookObj->folderNavigationBar($this, $folder, $menuitems);
}
}
self::showNavigationBar($menuitems);
@ -884,9 +891,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$menuitems['groups'] = array('link'=>$this->params['settings']->_httpRoot."out/out.GroupView.php", 'label'=>getMLText('groups'));
}
/* Check if hook exists because otherwise callHook() will override $menuitems */
if($this->hasHook('accountNavigationBar'))
$menuitems = $this->callHook('accountNavigationBar', $menuitems);
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'accountNavigationBar')) {
$menuitems = $hookObj->accountNavigationBar($this, $menuitems);
}
}
self::showNavigationBar($menuitems);
@ -918,9 +932,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
if ($accessobject->check_view_access('RevisionSummary'))
$menuitems['revision_summary'] = array('link'=>"../out/out.RevisionSummary.php", 'label'=>getMLText('revision_summary'));
/* Check if hook exists because otherwise callHook() will override $menuitems */
if($this->hasHook('mydocumentsNavigationBar'))
$menuitems = $this->callHook('mydocumentsNavigationBar', $menuitems);
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'mydocumentsNavigationBar')) {
$menuitems = $hookObj->mydocumentsNavigationBar($this, $menuitems);
}
}
self::showNavigationBar($menuitems);
@ -1023,9 +1044,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
}
}
/* Check if hook exists because otherwise callHook() will override $menuitems */
if($this->hasHook('admintoolsNavigationBar'))
$menuitems = $this->callHook('admintoolsNavigationBar', $menuitems);
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'admintoolsNavigationBar')) {
$menuitems = $hookObj->admintoolsNavigationBar($this, $menuitems);
}
}
self::showNavigationBar($menuitems);
@ -1059,9 +1087,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
if($accessobject->check_view_access(array('AddEvent')))
$menuitems['addevent'] = array('link'=>$this->params['settings']->_httpRoot."out/out.AddEvent.php", 'label'=>getMLText('add_event'));
/* Check if hook exists because otherwise callHook() will override $menuitems */
if($this->hasHook('calendarNavigationBar'))
$menuitems = $this->callHook('calendarNavigationBar', $menuitems);
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'calendarNavigationBar')) {
$menuitems = $hookObj->calendarNavigationBar($this, $menuitems);
}
}
self::showNavigationBar($menuitems);
@ -3138,10 +3173,23 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
}
if($onepage)
$actions['view_document'] = '<a href="'.$this->params['settings']->_httpRoot.'out/out.ViewDocument.php?documentid='.$docID.'" title="'.getMLText("view_document").'"><i class="fa fa-eye"></i></a>';
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'documentRowAction')) {
$actions = $hookObj->documentRowAction($this, $document, $actions);
}
}
foreach($actions as $action) {
if(is_string($action))
$content .= $action;
}
if(!empty($extracontent['end_action_list']))
$content .= $extracontent['end_action_list'];
$content .= "</div>";
@ -3330,31 +3378,49 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
$content = '';
$content .= "<div class=\"list-action\">";
$actions = array();
if(!empty($extracontent['begin_action_list']))
$content .= $extracontent['begin_action_list'];
$subFolderAccessMode = $subFolder->getAccessMode($user);
if ($accessop->check_view_access('RemoveFolder')) {
if($subFolderAccessMode >= M_ALL) {
$content .= $this->printDeleteFolderButton($subFolder, 'splash_rm_folder', true);
$actions['remove_folder'] = $this->printDeleteFolderButton($subFolder, 'splash_rm_folder', true);
} else {
$content .= '<span style="padding: 2px; color: #CCC;"><i class="fa fa-remove"></i></span>';
$actions['remove_folder'] = '<span style="padding: 2px; color: #CCC;"><i class="fa fa-remove"></i></span>';
}
}
if ($accessop->check_view_access('EditFolder')) {
if($subFolderAccessMode >= M_READWRITE) {
$content .= '<a class_="btn btn-mini" href="'.$this->params['settings']->_httpRoot.'out/out.EditFolder.php?folderid='.$subFolder->getID().'" title="'.getMLText("edit_folder_props").'"><i class="fa fa-edit"></i></a>';
$actions['edit_folder'] = '<a class_="btn btn-mini" href="'.$this->params['settings']->_httpRoot.'out/out.EditFolder.php?folderid='.$subFolder->getID().'" title="'.getMLText("edit_folder_props").'"><i class="fa fa-edit"></i></a>';
} else {
$content .= '<span style="padding: 2px; color: #CCC;"><i class="fa fa-edit"></i></span>';
$content['edit_folder'] = '<span style="padding: 2px; color: #CCC;"><i class="fa fa-edit"></i></span>';
}
}
if($subFolderAccessMode >= M_READWRITE) {
$content .= $this->printAccessButton($subFolder, true);
$actions['folder_access'] = $this->printAccessButton($subFolder, true);
}
if($enableClipboard) {
$content .= '<a class="addtoclipboard" rel="F'.$subFolder->getID().'" msg="'.getMLText('splash_added_to_clipboard').'" title="'.getMLText("add_to_clipboard").'"><i class="fa fa-copy"></i></a>';
$actions['add_to_clipboard'] = '<a class="addtoclipboard" rel="F'.$subFolder->getID().'" msg="'.getMLText('splash_added_to_clipboard').'" title="'.getMLText("add_to_clipboard").'"><i class="fa fa-copy"></i></a>';
}
if($onepage)
$content .= '<a href="'.$this->params['settings']->_httpRoot.'out/out.ViewFolder.php?folderid='.$subFolder->getID().'" title="'.getMLText("view_folder").'"><i class="fa fa-eye"></i></a>';
$actions['view_folder'] = '<a href="'.$this->params['settings']->_httpRoot.'out/out.ViewFolder.php?folderid='.$subFolder->getID().'" title="'.getMLText("view_folder").'"><i class="fa fa-eye"></i></a>';
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'folderRowAction')) {
$actions = $hookObj->folderRowAction($this, $folder, $actions);
}
}
foreach($actions as $action) {
if(is_string($action))
$content .= $action;
}
if(!empty($extracontent['end_action_list']))
$content .= $extracontent['end_action_list'];
$content .= "</div>";

View File

@ -700,9 +700,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$menuitems['index_folder'] = array('link'=>$this->params['settings']->_httpRoot."out/out.Indexer.php?folderid=". $folderID."&showtree=".showtree(), 'label'=>getMLText('index_folder'));
}
/* Check if hook exists because otherwise callHook() will override $menuitems */
if($this->hasHook('folderNavigationBar'))
$menuitems = $this->callHook('folderNavigationBar', $folder, $menuitems);
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'folderNavigationBar')) {
$menuitems = $hookObj->folderNavigationBar($this, $folder, $menuitems);
}
}
self::showNavigationBar($menuitems);
} /* }}} */
@ -799,9 +806,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$menuitems['groups'] = array('link'=>$this->params['settings']->_httpRoot."out/out.GroupView.php", 'label'=>getMLText('groups'));
}
/* Check if hook exists because otherwise callHook() will override $menuitems */
if($this->hasHook('accountNavigationBar'))
$menuitems = $this->callHook('accountNavigationBar', $menuitems);
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'accountNavigationBar')) {
$menuitems = $hookObj->accountNavigationBar($this, $menuitems);
}
}
self::showNavigationBar($menuitems);
@ -829,9 +843,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
if ($accessobject->check_view_access('RevisionSummary'))
$menuitems['revision_summary'] = array('link'=>"../out/out.RevisionSummary.php", 'label'=>getMLText('revision_summary'));
/* Check if hook exists because otherwise callHook() will override $menuitems */
if($this->hasHook('mydocumentsNavigationBar'))
$menuitems = $this->callHook('mydocumentsNavigationBar', $menuitems);
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'mydocumentsNavigationBar')) {
$menuitems = $hookObj->mydocumentsNavigationBar($this, $menuitems);
}
}
self::showNavigationBar($menuitems);
@ -931,9 +952,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
}
}
/* Check if hook exists because otherwise callHook() will override $menuitems */
if($this->hasHook('admintoolsNavigationBar'))
$menuitems = $this->callHook('admintoolsNavigationBar', $menuitems);
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'admintoolsNavigationBar')) {
$menuitems = $hookObj->admintoolsNavigationBar($this, $menuitems);
}
}
self::showNavigationBar($menuitems);
@ -964,9 +992,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
if($accessobject->check_view_access(array('AddEvent')))
$menuitems['addevent'] = array('link'=>$this->params['settings']->_httpRoot."out/out.AddEvent.php", 'label'=>getMLText('add_event'));
/* Check if hook exists because otherwise callHook() will override $menuitems */
if($this->hasHook('calendarNavigationBar'))
$menuitems = $this->callHook('calendarNavigationBar', $menuitems);
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'calendarNavigationBar')) {
$menuitems = $hookObj->calendarNavigationBar($this, $menuitems);
}
}
self::showNavigationBar($menuitems);
@ -3131,6 +3166,18 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
}
if($onepage)
$actions['view_document'] = '<a href="'.$this->params['settings']->_httpRoot.'out/out.ViewDocument.php?documentid='.$docID.'" title="'.getMLText("view_document").'"><i class="fa fa-eye"></i></a>';
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'documentRowAction')) {
$actions = $hookObj->documentRowAction($this, $document, $actions);
}
}
foreach($actions as $action) {
if(is_string($action))
$content .= $action;
@ -3370,31 +3417,49 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
$content = '';
$content .= "<div class=\"list-action\">";
$actions = array();
if(!empty($extracontent['begin_action_list']))
$content .= $extracontent['begin_action_list'];
$subFolderAccessMode = $subFolder->getAccessMode($user);
if ($accessop->check_view_access('RemoveFolder')) {
if($subFolderAccessMode >= M_ALL) {
$content .= $this->printDeleteFolderButton($subFolder, 'splash_rm_folder', true);
$actions['remove_folder'] = $this->printDeleteFolderButton($subFolder, 'splash_rm_folder', true);
} else {
$content .= '<span style="padding: 2px; color: #CCC;"><i class="fa fa-remove"></i></span>';
$actions['remove_folder'] = '<span style="padding: 2px; color: #CCC;"><i class="fa fa-remove"></i></span>';
}
}
if ($accessop->check_view_access('EditFolder')) {
if($subFolderAccessMode >= M_READWRITE) {
$content .= '<a class_="btn btn-mini" href="'.$this->params['settings']->_httpRoot.'out/out.EditFolder.php?folderid='.$subFolder->getID().'" title="'.getMLText("edit_folder_props").'"><i class="fa fa-edit"></i></a>';
$actions['edit_folder'] = '<a class_="btn btn-mini" href="'.$this->params['settings']->_httpRoot.'out/out.EditFolder.php?folderid='.$subFolder->getID().'" title="'.getMLText("edit_folder_props").'"><i class="fa fa-edit"></i></a>';
} else {
$content .= '<span style="padding: 2px; color: #CCC;"><i class="fa fa-edit"></i></span>';
$content['edit_folder'] = '<span style="padding: 2px; color: #CCC;"><i class="fa fa-edit"></i></span>';
}
}
if($subFolderAccessMode >= M_READWRITE) {
$content .= $this->printAccessButton($subFolder, true);
$actions['folder_access'] = $this->printAccessButton($subFolder, true);
}
if($enableClipboard) {
$content .= '<a class="addtoclipboard" rel="F'.$subFolder->getID().'" msg="'.getMLText('splash_added_to_clipboard').'" title="'.getMLText("add_to_clipboard").'"><i class="fa fa-copy"></i></a>';
$actions['add_to_clipboard'] = '<a class="addtoclipboard" rel="F'.$subFolder->getID().'" msg="'.getMLText('splash_added_to_clipboard').'" title="'.getMLText("add_to_clipboard").'"><i class="fa fa-copy"></i></a>';
}
if($onepage)
$content .= '<a href="'.$this->params['settings']->_httpRoot.'out/out.ViewFolder.php?folderid='.$subFolder->getID().'" title="'.getMLText("view_folder").'"><i class="fa fa-eye"></i></a>';
$actions['view_folder'] = '<a href="'.$this->params['settings']->_httpRoot.'out/out.ViewFolder.php?folderid='.$subFolder->getID().'" title="'.getMLText("view_folder").'"><i class="fa fa-eye"></i></a>';
/* Do not use $this->callHook() because $menuitems must be returned by the the
* first hook and passed to next hook. $this->callHook() will just pass
* the menuitems to each single hook. Hence, the last hook will win.
*/
$hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'folderRowAction')) {
$actions = $hookObj->folderRowAction($this, $folder, $actions);
}
}
foreach($actions as $action) {
if(is_string($action))
$content .= $action;
}
if(!empty($extracontent['end_action_list']))
$content .= $extracontent['end_action_list'];
$content .= "</div>";