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:
Normann Lou 2009-11-20 03:49:57 +00:00 committed by Sam Minnee
parent 9433580f95
commit 73681b0afa
2 changed files with 22 additions and 0 deletions

View File

@ -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);
}
}
}
?>

View File

@ -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());
}
}
?>