diff --git a/security/Permission.php b/security/Permission.php index ce9f1e7af..d53c87fbb 100755 --- a/security/Permission.php +++ b/security/Permission.php @@ -82,7 +82,13 @@ class Permission extends DataObject { * @var bool */ static $admin_implies_all = true; - + + /** + * a list of permission codes which doesn't appear in the Permission list + * when make the {@link PermissionCheckboxSetField} + * @var array; + */ + static $hidden_permissions = array(); /** * Check that the current member has the given permission. @@ -559,6 +565,26 @@ class Permission extends DataObject { return $a['sort'] < $b['sort'] ? -1 : 1; } } + + /** + * add a permission represented by the $code to the {@link slef::$hidden_permissions} list + * + * @param $code string - the permissions code + * @return void + */ + static function add_to_hidden_permissions($code){ + self::$hidden_permissions[] = $code; + } + + /** + * remove a permission represented by the $code from the {@link slef::$hidden_permissions} list + * + * @param $code string - the permissions code + * @return void + */ + static function remove_from_hidden_permissions($code){ + self::$hidden_permissions = array_diff(self::$hidden_permissions, array($code)); + } /** * Declare an array of permissions for the system. diff --git a/security/PermissionCheckboxSetField.php b/security/PermissionCheckboxSetField.php index a71f54fa5..d3eafeed4 100644 --- a/security/PermissionCheckboxSetField.php +++ b/security/PermissionCheckboxSetField.php @@ -69,7 +69,9 @@ class PermissionCheckboxSetField extends CheckboxSetField { if($source) { foreach($source as $categoryName => $permissions) { $options .= "