diff --git a/code/CMSBatchAction.php b/code/CMSBatchAction.php index 24cbaee5..d8b33cf7 100644 --- a/code/CMSBatchAction.php +++ b/code/CMSBatchAction.php @@ -101,7 +101,7 @@ abstract class CMSBatchAction extends Object { if($page->$methodName()) $applicableIDs[] = $page->ID; } } - + return $applicableIDs; } @@ -109,6 +109,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 bed33ba3..89de7109 100644 --- a/code/CMSBatchActionHandler.php +++ b/code/CMSBatchActionHandler.php @@ -117,12 +117,14 @@ class CMSBatchActionHandler extends RequestHandler { foreach($actions as $urlSegment => $actionClass) { $actionObj = new $actionClass(); - $actionDef = new ArrayData(array( - "Link" => Controller::join_links($this->Link(), $urlSegment), - "Title" => $actionObj->getActionTitle(), - "DoingText" => $actionObj->getDoingText(), - )); - $actionList->push($actionDef); + if($actionObj->canView()) { + $actionDef = new ArrayData(array( + "Link" => Controller::join_links($this->Link(), $urlSegment), + "Title" => $actionObj->getActionTitle(), + "DoingText" => $actionObj->getDoingText(), + )); + $actionList->push($actionDef); + } } return $actionList; diff --git a/code/CMSMain.php b/code/CMSMain.php index a3c61cb8..da4035d3 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -1027,7 +1027,8 @@ JS; $forms = array(); foreach($batchActions as $urlSegment => $batchAction) { - if ($fieldset = singleton($batchAction)->getParameterFields()) { + $SNG_action = singleton($batchAction); + if ($SNG_action->canView() && $fieldset = $SNG_action->getParameterFields()) { $formHtml = ''; foreach($fieldset as $field) { $formHtml .= $field->Field();