mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
APICHANGE: add the ability to remove some permissions specified by their code in the rendered field html of PermissionChecksetBoxField and full-covered unit tests of this ability.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@92428 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
9433580f95
commit
73681b0afa
@ -276,6 +276,18 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* the permissions represented in the $codes will not appearing in the form
|
||||
* containning {@link PermissionCheckboxSetField} so as not to be checked / unchecked.
|
||||
* @param $codes array of permission code
|
||||
* @return void
|
||||
*/
|
||||
static function hide_permissions($codes){
|
||||
foreach($codes as $code){
|
||||
Permission::add_to_hidden_permissions($code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -36,6 +36,16 @@ class SecurityAdminTest extends FunctionalTest {
|
||||
$this->assertEquals($lines[1], '', "Empty export only has no content row");
|
||||
}
|
||||
|
||||
function testHidePermissions() {
|
||||
$permissionCheckboxSet = new PermissionCheckboxSetField('Permissions','Permissions','Permission','GroupID');
|
||||
$this->assertContains('CMS_ACCESS_CMSMain', $permissionCheckboxSet->Field());
|
||||
$this->assertContains('CMS_ACCESS_AssetAdmin', $permissionCheckboxSet->Field());
|
||||
|
||||
SecurityAdmin::hide_permissions(array('CMS_ACCESS_CMSMain','CMS_ACCESS_AssetAdmin'));
|
||||
$this->assertNotContains('CMS_ACCESS_CMSMain', $permissionCheckboxSet->Field());
|
||||
$this->assertNotContains('CMS_ACCESS_AssetAdmin', $permissionCheckboxSet->Field());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user