From 48171d1f585cfbafc802ca97f2d6ea8df16741e0 Mon Sep 17 00:00:00 2001 From: Mateusz Uzdowski Date: Tue, 19 Jan 2010 01:01:46 +0000 Subject: [PATCH] BUGFIX: now hiding the permissions via SecurityAdmin::add_hidden_permission works also for PermissionRoleAdmin git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@97168 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/PermissionRoleAdmin.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/code/PermissionRoleAdmin.php b/code/PermissionRoleAdmin.php index cb828a9f..1f4aed6c 100644 --- a/code/PermissionRoleAdmin.php +++ b/code/PermissionRoleAdmin.php @@ -8,8 +8,39 @@ class PermissionRoleAdmin extends ModelAdmin { 'PermissionRole' ); + public static $collection_controller_class = "PermissionRoleAdmin_CollectionController"; + public static $record_controller_class = "PermissionRoleAdmin_RecordController"; + static $url_segment = 'roles'; static $menu_title = 'Roles'; } +/** + * Customized controller for hiding permissions on AddForm + */ +class PermissionRoleAdmin_CollectionController extends ModelAdmin_CollectionController { + public function AddForm() { + $form = parent::AddForm(); + if ( $this->modelClass=='PermissionRole' ) { + $permissionField = $form->Fields()->dataFieldByName('Codes'); + if($permissionField) $permissionField->setHiddenPermissions(SecurityAdmin::$hidden_permissions); + } + return $form; + } +} + +/** + * Customized controller for hiding permissions on EditForm + */ +class PermissionRoleAdmin_RecordController extends ModelAdmin_RecordController { + public function EditForm() { + $form = parent::EditForm(); + if ( $this->parentController->modelClass=='PermissionRole' ) { + $permissionField = $form->Fields()->dataFieldByName('Codes'); + if($permissionField) $permissionField->setHiddenPermissions(SecurityAdmin::$hidden_permissions); + } + return $form; + } +} + ?>