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;