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
This commit is contained in:
Ingo Schommer 2010-04-13 04:24:48 +00:00
parent 186e43e60b
commit 4d0362ba64
2 changed files with 15 additions and 6 deletions

View File

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

View File

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