mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
List "view/edit all" groups in group permission field
See https://github.com/silverstripe/silverstripe-cms/issues/794
This commit is contained in:
parent
e31b09fef3
commit
4bacd35fc4
@ -1926,12 +1926,18 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
||||
*/
|
||||
public function getSettingsFields()
|
||||
{
|
||||
$groupsMap = array();
|
||||
foreach (Group::get() as $group) {
|
||||
$mapFn = function ($groups = []) {
|
||||
$map = [];
|
||||
foreach ($groups as $group) {
|
||||
// Listboxfield values are escaped, use ASCII char instead of »
|
||||
$groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
|
||||
$map[$group->ID] = $group->getBreadcrumbs(' > ');
|
||||
}
|
||||
asort($groupsMap);
|
||||
asort($map);
|
||||
return $map;
|
||||
};
|
||||
$groupsMap = $mapFn(Group::get());
|
||||
$viewAllGroupsMap = $mapFn(Permission::get_groups_by_permission(['SITETREE_VIEW_ALL', 'ADMIN']));
|
||||
$editAllGroupsMap = $mapFn(Permission::get_groups_by_permission(['SITETREE_EDIT_ALL', 'ADMIN']));
|
||||
|
||||
$fields = new FieldList(
|
||||
$rootTab = new TabSet(
|
||||
@ -2017,6 +2023,22 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
||||
unset($editorsOptionsSource[InheritedPermissions::ANYONE]);
|
||||
$editorsOptionsField->setSource($editorsOptionsSource);
|
||||
|
||||
if ($viewAllGroupsMap) {
|
||||
$viewerGroupsField->setDescription(_t(
|
||||
'SilverStripe\\CMS\\Model\\SiteTree.VIEWER_GROUPS_FIELD_DESC',
|
||||
'Groups with global view permissions: {groupList}',
|
||||
['groupList' => implode(', ', array_values($viewAllGroupsMap))]
|
||||
));
|
||||
}
|
||||
|
||||
if ($editAllGroupsMap) {
|
||||
$editorGroupsField->setDescription(_t(
|
||||
'SilverStripe\\CMS\\Model\\SiteTree.EDITOR_GROUPS_FIELD_DESC',
|
||||
'Groups with global edit permissions: {groupList}',
|
||||
['groupList' => implode(', ', array_values($editAllGroupsMap))]
|
||||
));
|
||||
}
|
||||
|
||||
if (!Permission::check('SITETREE_GRANT_ACCESS')) {
|
||||
$fields->makeFieldReadonly($viewersOptionsField);
|
||||
if ($this->CanEditType === InheritedPermissions::ONLY_THESE_USERS) {
|
||||
|
Loading…
Reference in New Issue
Block a user