From 9c5dae4dff8d33c258152b1b98e3e3223f8a9cf9 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Thu, 29 Oct 2009 00:55:20 +0000 Subject: [PATCH] MINOR shuffled permissions around, gave them help text and categorized them. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@90371 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteConfig.php | 7 +++++- core/model/SiteTree.php | 32 +++++++++++++++---------- security/Permission.php | 18 +++++++++----- security/PermissionCheckboxSetField.php | 4 +++- 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/core/model/SiteConfig.php b/core/model/SiteConfig.php index 48b043c44..3553d58ee 100644 --- a/core/model/SiteConfig.php +++ b/core/model/SiteConfig.php @@ -154,7 +154,12 @@ class SiteConfig extends DataObject implements PermissionProvider { function providePermissions() { return array( - 'EDIT_SITECONFIG' => 'Manage site configuration' + 'EDIT_SITECONFIG' => array( + 'name' => 'Manage site configuration', + 'category' => 'Roles and access permissions', + 'help' => 'Ability to edit global access settings/top-level page permissions.', + 'sort' => 400 + ) ); } } \ No newline at end of file diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index 3c4f43dda..41b6f4716 100755 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -2331,22 +2331,28 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid function providePermissions() { return array( - 'SITETREE_GRANT_ACCESS' => _t( - 'SiteTree.PERMISSION_GRANTACCESS_DESCRIPTION', - 'Manage access rights for content' + 'SITETREE_GRANT_ACCESS' => array( + 'name' => _t('SiteTree.PERMISSION_GRANTACCESS_DESCRIPTION', 'Manage access rights for content'), + 'category' => 'Roles and access permissions', + 'sort' => 100 ), - 'SITETREE_VIEW_ALL' => _t( - 'SiteTree.VIEW_ALL_DESCRIPTION', - 'View any page' + 'SITETREE_VIEW_ALL' => array( + 'name' => _t('SiteTree.VIEW_ALL_DESCRIPTION', 'View any page'), + 'category' => 'Content permissions', + 'sort' => -100, + 'help' => 'Ability to view any page on the site, regardless of the settings on the Access tab. Requires "Access to Site Content."' ), - 'SITETREE_EDIT_ALL' => _t( - 'SiteTree.EDIT_ALL_DESCRIPTION', - 'Edit any page' - ), - 'SITETREE_REORGANISE' => _t( - 'SiteTree.REORGANISE_DESCRIPTION', - 'Change site structure' + 'SITETREE_EDIT_ALL' => array( + 'name' => _t('SiteTree.EDIT_ALL_DESCRIPTION', 'Edit any page'), + 'category' => 'Content permissions', + 'sort' => -50, + 'help' => 'Ability to edit any page on the site, regardless of the settings on the Access tab. Requires "Access to Site Content."' ), + 'SITETREE_REORGANISE' => array( + 'name' => _t('SiteTree.REORGANISE_DESCRIPTION', 'Change site structure'), + 'category' => 'Content permissions', + 'sort' => 100 + ) ); } diff --git a/security/Permission.php b/security/Permission.php index e129223d6..ce9f1e7af 100755 --- a/security/Permission.php +++ b/security/Permission.php @@ -486,10 +486,10 @@ class Permission extends DataObject { // : $blankItemText; // } - $allCodes['Other']['ADMIN'] = array( + $allCodes['Roles and access permissions']['ADMIN'] = array( 'name' => _t('Permission.FULLADMINRIGHTS', 'Full administrative rights'), 'help' => null, - 'sort' => 0 + 'sort' => 100000 ); if($classes) foreach($classes as $class) { @@ -523,11 +523,17 @@ class Permission extends DataObject { } } - $otherPerms = DB::query("SELECT DISTINCT \"Code\" From \"Permission\"") - ->column(); + $flatCodeArray = array(); + foreach($allCodes as $category) foreach($category as $code => $permission) $flatCodeArray[] = $code; + $otherPerms = DB::query("SELECT DISTINCT \"Code\" From \"Permission\"")->column(); + if($otherPerms) foreach($otherPerms as $otherPerm) { - if(!array_key_exists($otherPerm, $allCodes['Other'])) - $allCodes['Other'][$otherPerm] = $otherPerm; + if(!in_array($otherPerm, $flatCodeArray)) + $allCodes['Other'][$otherPerm] = array( + 'name' => $otherPerm, + 'help' => null, + 'sort' => 0 + ); } ksort($allCodes); diff --git a/security/PermissionCheckboxSetField.php b/security/PermissionCheckboxSetField.php index d009d6814..e38397f75 100644 --- a/security/PermissionCheckboxSetField.php +++ b/security/PermissionCheckboxSetField.php @@ -46,8 +46,10 @@ class PermissionCheckboxSetField extends CheckboxSetField { $checked = in_array($key, $values) ? ' checked="checked"' : ''; + + $title = $permission['help'] ? 'title="'.htmlentities($permission['help']).'" ' : ''; - $options .= "
  • name[$key]\" type=\"checkbox\" value=\"$key\"$checked class=\"checkbox\" />
  • \n"; + $options .= "
  • name[$key]\" type=\"checkbox\" value=\"$key\"$checked class=\"checkbox\" />
  • \n"; } } }