mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
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:
parent
c124dd23fa
commit
27907e4ced
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user