mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
ENHANCEMENT Better editing of roles through SecurityAdmin instead of a new "Roles" tab. Removed (previously unreleased) PermissionRoleAdmin. (see #4757)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@100776 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
131c271f9c
commit
13ee9391bf
@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Admin interface for Permission Roles.
|
|
||||||
*/
|
|
||||||
class PermissionRoleAdmin extends ModelAdmin {
|
|
||||||
static $managed_models = array(
|
|
||||||
'PermissionRole'
|
|
||||||
);
|
|
||||||
|
|
||||||
public static $collection_controller_class = "PermissionRoleAdmin_CollectionController";
|
|
||||||
public static $record_controller_class = "PermissionRoleAdmin_RecordController";
|
|
||||||
|
|
||||||
static $url_segment = 'roles';
|
|
||||||
static $menu_title = 'Roles';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Customized controller for hiding permissions on AddForm
|
|
||||||
*/
|
|
||||||
class PermissionRoleAdmin_CollectionController extends ModelAdmin_CollectionController {
|
|
||||||
public function AddForm() {
|
|
||||||
$form = parent::AddForm();
|
|
||||||
if ( $this->modelClass=='PermissionRole' ) {
|
|
||||||
$permissionField = $form->Fields()->dataFieldByName('Codes');
|
|
||||||
if($permissionField) $permissionField->setHiddenPermissions(SecurityAdmin::$hidden_permissions);
|
|
||||||
}
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Customized controller for hiding permissions on EditForm
|
|
||||||
*/
|
|
||||||
class PermissionRoleAdmin_RecordController extends ModelAdmin_RecordController {
|
|
||||||
public function EditForm() {
|
|
||||||
$form = parent::EditForm();
|
|
||||||
if ( $this->parentController->modelClass=='PermissionRole' ) {
|
|
||||||
$permissionField = $form->Fields()->dataFieldByName('Codes');
|
|
||||||
if($permissionField) $permissionField->setHiddenPermissions(SecurityAdmin::$hidden_permissions);
|
|
||||||
}
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -81,6 +81,20 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$fields->addFieldToTab(
|
||||||
|
'Root.Roles',
|
||||||
|
new LiteralField(
|
||||||
|
'RolesAddEditLink',
|
||||||
|
sprintf(
|
||||||
|
'<p class="add-role"><a href="%s">%s</a></p>',
|
||||||
|
$this->Link('show/root'),
|
||||||
|
// TODO This should include #Root_Roles to switch directly to the tab,
|
||||||
|
// but tabstrip.js doesn't display tabs when directly adressed through a URL pragma
|
||||||
|
_t('Group.RolesAddEditLink', 'Add/edit roles')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$actions = new FieldSet(
|
$actions = new FieldSet(
|
||||||
@ -147,6 +161,28 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
// necessary for tree node selection in LeftAndMain.EditForm.js
|
// necessary for tree node selection in LeftAndMain.EditForm.js
|
||||||
new HiddenField('ID', false, 0)
|
new HiddenField('ID', false, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Add roles editing interface
|
||||||
|
if(Permission::check('APPLY_ROLES')) {
|
||||||
|
$rolesCTF = new ComplexTableField(
|
||||||
|
$this,
|
||||||
|
'Roles',
|
||||||
|
'PermissionRole'
|
||||||
|
);
|
||||||
|
// Necessary to make Permission code checkboxes behave consistently
|
||||||
|
$rolesCTF->requirementsForPopupCallback = create_function(
|
||||||
|
'$popup',
|
||||||
|
'Requirements::javascript(CMS_DIR . "/javascript/MemberTableField.js");'
|
||||||
|
);
|
||||||
|
|
||||||
|
$rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles'));
|
||||||
|
$rolesTab->push(new LiteralField(
|
||||||
|
'RolesDescription',
|
||||||
|
''
|
||||||
|
));
|
||||||
|
$rolesTab->push($rolesCTF);
|
||||||
|
}
|
||||||
|
|
||||||
$actions = new FieldSet(
|
$actions = new FieldSet(
|
||||||
new FormAction('addmember',_t('SecurityAdmin.ADDMEMBER','Add Member'))
|
new FormAction('addmember',_t('SecurityAdmin.ADDMEMBER','Add Member'))
|
||||||
);
|
);
|
||||||
|
@ -281,13 +281,7 @@ Behaviour.register({
|
|||||||
});
|
});
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
Behaviour.register({
|
var checkboxBehaviour = {
|
||||||
/**
|
|
||||||
* Automatically check and disable all checkboxes if ADMIN permissions are selected.
|
|
||||||
* As they're disabled, any changes won't be submitted (which is intended behaviour),
|
|
||||||
* checking all boxes is purely presentational.
|
|
||||||
*/
|
|
||||||
'#Permissions .valADMIN input': {
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.toggleCheckboxes();
|
this.toggleCheckboxes();
|
||||||
},
|
},
|
||||||
@ -311,6 +305,15 @@ Behaviour.register({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Behaviour.register({
|
||||||
|
/**
|
||||||
|
* Automatically check and disable all checkboxes if ADMIN permissions are selected.
|
||||||
|
* As they're disabled, any changes won't be submitted (which is intended behaviour),
|
||||||
|
* checking all boxes is purely presentational.
|
||||||
|
*/
|
||||||
|
'#Permissions .valADMIN input': checkboxBehaviour,
|
||||||
|
'#Codes .valADMIN input': checkboxBehaviour
|
||||||
});
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
Loading…
Reference in New Issue
Block a user