From 4d0362ba64e9875a1fc3220fd0c91bfb40fab9d2 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 13 Apr 2010 04:24:48 +0000 Subject: [PATCH] API CHANGE: Added canView() to CMSBatchAction so that you could hide certain batch actions from some users. (from r94846) (from r96823) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102687 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSBatchAction.php | 9 ++++++++- code/CMSBatchActionHandler.php | 12 +++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/code/CMSBatchAction.php b/code/CMSBatchAction.php index 16da258d..56f2a0d1 100644 --- a/code/CMSBatchAction.php +++ b/code/CMSBatchAction.php @@ -108,7 +108,7 @@ abstract class CMSBatchAction extends Object { if($page->$methodName()) $applicableIDs[] = $page->ID; } } - + return $applicableIDs; } @@ -116,6 +116,13 @@ abstract class CMSBatchAction extends Object { function getParameterFields() { return false; } + + /** + * If you wish to restrict the batch action to some users, overload this function. + */ + function canView() { + return true; + } } /** diff --git a/code/CMSBatchActionHandler.php b/code/CMSBatchActionHandler.php index c4553877..63338b09 100644 --- a/code/CMSBatchActionHandler.php +++ b/code/CMSBatchActionHandler.php @@ -126,11 +126,13 @@ class CMSBatchActionHandler extends RequestHandler { foreach($actions as $urlSegment => $action) { $actionClass = $action['class']; $actionObj = new $actionClass(); - $actionDef = new ArrayData(array( - "Link" => Controller::join_links($this->Link(), $urlSegment), - "Title" => $actionObj->getActionTitle() - )); - $actionList->push($actionDef); + if($actionObj->canView()) { + $actionDef = new ArrayData(array( + "Link" => Controller::join_links($this->Link(), $urlSegment), + "Title" => $actionObj->getActionTitle() + )); + $actionList->push($actionDef); + } } return $actionList;