Browse files

FEATURE Showing (readonly) permissions for a Member record in admin/s…

…ecurity popup

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@99586 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 705eaae commit 11ad275522f2564df1f44140c3465ea2337c3acf @chillu chillu committed Feb 22, 2010
Showing with 23 additions and 2 deletions.
  1. +16 −0 security/Member.php
  2. +5 −1 security/PermissionCheckboxSetField.php
  3. +2 −1 security/PermissionRole.php
View
16 security/Member.php
@@ -982,6 +982,22 @@ public function getCMSFields() {
$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);
View
6 security/PermissionCheckboxSetField.php
@@ -80,7 +80,11 @@ function Field() {
// 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);
}
}
View
3 security/PermissionRole.php
@@ -32,7 +32,8 @@ function getCMSFields() {
'Codes',
singleton('Permission')->i18n_plural_name(),
'PermissionRoleCode',
- 'RoleID'));
+ 'RoleID'
+ ));
return $fields;
}

0 comments on commit 11ad275

Please sign in to comment.