mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FEATURE Showing (readonly) permissions for a Member record in admin/security popup (from r99586)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@99662 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5a6683e775
commit
ebaf33c720
@ -1030,6 +1030,22 @@ class Member extends DataObject {
|
||||
$groupsField = new TreeMultiselectField('Groups', false, 'Group');
|
||||
$fields->findOrMakeTab('Root.Groups', singleton('Group')->i18n_plural_name());
|
||||
$fields->addFieldToTab('Root.Groups', $groupsField);
|
||||
|
||||
// Add permission field (readonly to avoid complicated group assignment logic).
|
||||
// This should only be available for existing records, as new records start
|
||||
// with no permissions until they have a group assignment anyway.
|
||||
if($this->ID) {
|
||||
$permissionsField = new PermissionCheckboxSetField_Readonly(
|
||||
'Permissions',
|
||||
singleton('Permission')->i18n_plural_name(),
|
||||
'Permission',
|
||||
'GroupID',
|
||||
// we don't want parent relationships, they're automatically resolved in the field
|
||||
$this->getManyManyComponents('Groups')
|
||||
);
|
||||
$fields->findOrMakeTab('Root.Permissions', singleton('Permission')->i18n_plural_name());
|
||||
$fields->addFieldToTab('Root.Permissions', $permissionsField);
|
||||
}
|
||||
}
|
||||
|
||||
$this->extend('updateCMSFields', $fields);
|
||||
|
@ -80,7 +80,11 @@ class PermissionCheckboxSetField extends FormField {
|
||||
// Get existing values from the form record (assuming the formfield name is a join field on the record)
|
||||
if(is_object($this->form)) {
|
||||
$record = $this->form->getRecord();
|
||||
if($record && !$records->find('ID', $record->ID)) {
|
||||
if(
|
||||
$record
|
||||
&& (is_a($record, 'Group') || is_a($record, 'PermissionRole'))
|
||||
&& !$records->find('ID', $record->ID)
|
||||
) {
|
||||
$records->push($record);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ class PermissionRole extends DataObject {
|
||||
'Codes',
|
||||
singleton('Permission')->i18n_plural_name(),
|
||||
'PermissionRoleCode',
|
||||
'RoleID'));
|
||||
'RoleID'
|
||||
));
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user