BUGFIX: removing permissions before re-applying them (previously it just removed the components on the relation which resulted in permissions having GroupID set to 0)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@94810 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Mateusz Uzdowski 2009-12-09 22:53:59 +00:00 committed by Sam Minnee
parent cdada2784d
commit fa3fe47284

View File

@ -122,7 +122,13 @@ class PermissionCheckboxSetField extends CheckboxSetField {
function saveInto(DataObject $record) {
$fieldname = $this->name;
$managedClass = $this->managedClass;
$record->$fieldname()->removeAll();
// remove all permissions and re-add them afterwards
$permissions = $record->$fieldname();
foreach ( $permissions as $permission ) {
$permission->delete();
}
if($fieldname && $record && ($record->has_many($fieldname) || $record->many_many($fieldname))) {
$idList = array();
if($this->value) foreach($this->value as $id => $bool) {