From ca2739b96ee49340313e96af4606784bc236a47b Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 7 Jul 2022 16:47:42 +0200 Subject: [PATCH] add hooks folderRowAction and documentRowAction --- views/bootstrap/class.Bootstrap.php | 45 ++++++++++++++++++++++----- views/bootstrap4/class.Bootstrap4.php | 42 +++++++++++++++++++++---- 2 files changed, 74 insertions(+), 13 deletions(-) diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index 399af883a..4a1f5b549 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -3038,10 +3038,23 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev) } if($onepage) $actions['view_document'] = ''; + + /* 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 .= ""; @@ -3206,29 +3219,47 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev) $content = ''; $content .= "
"; + $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 .= ''; + $actions['remove_folder'] = ''; } } if($subFolderAccessMode >= M_READWRITE) { - $content .= ''; + $actions['edit_folder'] = ''; } else { - $content .= ''; + $actions['edit_folder'] = ''; } if($subFolderAccessMode >= M_READWRITE) { - $content .= $this->printAccessButton($subFolder, true); + $actions['folder_access'] = $this->printAccessButton($subFolder, true); } if($enableClipboard) { - $content .= ''; + $actions['add_to_clipboard'] = ''; } if($onepage) - $content .= ''; + $actions['view_folder'] = ''; + + /* 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 .= "
"; diff --git a/views/bootstrap4/class.Bootstrap4.php b/views/bootstrap4/class.Bootstrap4.php index 689494a29..7e84e82e4 100644 --- a/views/bootstrap4/class.Bootstrap4.php +++ b/views/bootstrap4/class.Bootstrap4.php @@ -3113,6 +3113,18 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev) } if($onepage) $actions['view_document'] = ''; + + /* 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; @@ -3328,29 +3340,47 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev) $content = ''; $content .= "
"; + $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 .= ''; + $actions['remove_folder'] = ''; } } if($subFolderAccessMode >= M_READWRITE) { - $content .= ''; + $actions['edit_folder'] = ''; } else { $content .= ''; } if($subFolderAccessMode >= M_READWRITE) { - $content .= $this->printAccessButton($subFolder, true); + $actions['folder_access'] = $this->printAccessButton($subFolder, true); } if($enableClipboard) { - $content .= ''; + $actions['add_to_clipboard'] = ''; } if($onepage) - $content .= ''; + $actions['view_folder'] = ''; + + /* 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 .= "
";