mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Using ListboxField/chosen.js to assign roles in Group->getCMSFields(). Improved explanation of groups in the user interface.
This commit is contained in:
parent
5d565dcfa3
commit
ad5cf1ebf1
@ -63,21 +63,6 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if(Permission::check('APPLY_ROLES')) {
|
|
||||||
$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')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter permissions
|
// Filter permissions
|
||||||
$permissionField = $form->Fields()->dataFieldByName('Permissions');
|
$permissionField = $form->Fields()->dataFieldByName('Permissions');
|
||||||
|
@ -281,7 +281,7 @@ $lang['en_US']['Group']['Parent'] = array(
|
|||||||
PR_MEDIUM,
|
PR_MEDIUM,
|
||||||
'One group has one parent group'
|
'One group has one parent group'
|
||||||
);
|
);
|
||||||
$lang['en_US']['Group']['RolesAddEditLink'] = 'Add/edit roles';
|
$lang['en_US']['Group']['RolesAddEditLink'] = 'Manage roles';
|
||||||
$lang['en_US']['Group']['SINGULARNAME'] = array(
|
$lang['en_US']['Group']['SINGULARNAME'] = array(
|
||||||
'Group',
|
'Group',
|
||||||
50,
|
50,
|
||||||
@ -730,7 +730,7 @@ $lang['en_US']['SecurityAdmin']['MemberListCaution'] = 'Caution: Removing member
|
|||||||
$lang['en_US']['SecurityAdmin']['NEWGROUP'] = 'New Group';
|
$lang['en_US']['SecurityAdmin']['NEWGROUP'] = 'New Group';
|
||||||
$lang['en_US']['SecurityAdmin']['PERMISSIONS'] = 'Permissions';
|
$lang['en_US']['SecurityAdmin']['PERMISSIONS'] = 'Permissions';
|
||||||
$lang['en_US']['SecurityAdmin']['ROLES'] = 'Roles';
|
$lang['en_US']['SecurityAdmin']['ROLES'] = 'Roles';
|
||||||
$lang['en_US']['SecurityAdmin']['ROLESDESCRIPTION'] = 'This section allows you to add roles to this group. Roles are logical groupings of permissions, which can be editied in the Roles tab';
|
$lang['en_US']['SecurityAdmin']['ROLESDESCRIPTION'] = 'Roles are predefined sets of permissions, and can be assigned to groups.<br />They are inherited from parent groups if required.';
|
||||||
$lang['en_US']['SecurityAdmin']['SGROUPS'] = 'Security Groups';
|
$lang['en_US']['SecurityAdmin']['SGROUPS'] = 'Security Groups';
|
||||||
$lang['en_US']['SecurityAdmin']['TABIMPORT'] = 'Import';
|
$lang['en_US']['SecurityAdmin']['TABIMPORT'] = 'Import';
|
||||||
$lang['en_US']['SecurityAdmin']['TABROLES'] = 'Roles';
|
$lang['en_US']['SecurityAdmin']['TABROLES'] = 'Roles';
|
||||||
|
@ -123,8 +123,16 @@ class Group extends DataObject {
|
|||||||
new LiteralField(
|
new LiteralField(
|
||||||
"",
|
"",
|
||||||
"<p>" .
|
"<p>" .
|
||||||
_t('SecurityAdmin.ROLESDESCRIPTION',
|
_t(
|
||||||
"This section allows you to add roles to this group. Roles are logical groupings of permissions, which can be editied in the Roles tab"
|
'SecurityAdmin.ROLESDESCRIPTION',
|
||||||
|
"Roles are predefined sets of permissions, and can be assigned to groups.<br />They are inherited from parent groups if required."
|
||||||
|
) . '<br />' .
|
||||||
|
sprintf(
|
||||||
|
'<a href="%s" class="add-role">%s</a>',
|
||||||
|
singleton('SecurityAdmin')->Link('show/root#Root_Roles'),
|
||||||
|
// 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', 'Manage roles')
|
||||||
) .
|
) .
|
||||||
"</p>"
|
"</p>"
|
||||||
)
|
)
|
||||||
@ -139,13 +147,14 @@ class Group extends DataObject {
|
|||||||
$ancestorRoles = $ancestor->Roles();
|
$ancestorRoles = $ancestor->Roles();
|
||||||
if($ancestorRoles) $inheritedRoles->merge($ancestorRoles);
|
if($ancestorRoles) $inheritedRoles->merge($ancestorRoles);
|
||||||
}
|
}
|
||||||
$fields->findOrMakeTab('Root.Roles', 'Root.' . _t('SecurityAdmin.ROLES', 'Roles'));
|
$groupRoleIDs = $groupRoles->column('ID') + $inheritedRoles->column('ID');
|
||||||
$fields->addFieldToTab(
|
$rolesField = Object::create('ListboxField', 'Roles', false, $allRoles->map()->toArray())
|
||||||
'Root.Roles',
|
->setMultiple(true)
|
||||||
$rolesField = new CheckboxSetField('Roles', 'Roles', $allRoles)
|
->setDefaultItems($groupRoleIDs)
|
||||||
);
|
->setAttribute('data-placeholder', _t('Group.AddRole', 'Add a role for this group'))
|
||||||
$rolesField->setDefaultItems($inheritedRoles->column('ID'));
|
->setDisabledItems($inheritedRoles->column('ID'));
|
||||||
$rolesField->setDisabledItems($inheritedRoles->column('ID'));
|
if(!$allRoles->Count()) $rolesField->setAttribute('data-placeholder', _t('Group.NoRoles', 'No roles found'));
|
||||||
|
$fields->addFieldToTab('Root.Roles', $rolesField);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields->push($idField = new HiddenField("ID"));
|
$fields->push($idField = new HiddenField("ID"));
|
||||||
|
Loading…
Reference in New Issue
Block a user