API CHANGE: Added canView() to CMSBatchAction so that you could hide certain batch actions from some users. (from r94846)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@96823 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-01-13 00:09:30 +00:00
parent c124dd23fa
commit 27907e4ced
3 changed files with 18 additions and 8 deletions

View File

@ -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;
}
}
/**

View File

@ -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;

View File

@ -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();