BUGFIX: adding onAfterDelete hooks to remove the no longer necessary permissions (from r94859)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95627 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-12-16 05:43:47 +00:00
parent d8017fe459
commit d459e17288
2 changed files with 20 additions and 0 deletions

View File

@ -336,6 +336,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();
}
}
}