BUGFIX: adding onAfterDelete hooks to remove the no longer necessary permissions

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@94859 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Mateusz Uzdowski 2009-12-10 03:44:35 +00:00 committed by Sam Minnee
parent 7cdf62fd1c
commit d6b4ad39d8
2 changed files with 20 additions and 0 deletions

View File

@ -334,6 +334,16 @@ class Group extends DataObject {
}
}
function onAfterDelete() {
parent::onAfterDelete();
// Delete associated permissions
$permissions = $this->Permissions();
foreach ( $permissions as $permission ) {
$permission->delete();
}
}
/**
* Checks for permission-code CMS_ACCESS_SecurityAdmin.
* If the group has ADMIN permissions, it requires the user to have ADMIN permissions as well.

View File

@ -36,4 +36,14 @@ class PermissionRole extends DataObject {
return $fields;
}
function onAfterDelete() {
parent::onAfterDelete();
// Delete associated permission codes
$codes = $this->Codes();
foreach ( $codes as $code ) {
$code->delete();
}
}
}