mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
APICHANGE: Group::addByGroupName() now creates the group if one does not already exist (from r83010) (from r94430)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95611 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
96fdef27bd
commit
c0db452069
@ -190,7 +190,8 @@ class Group extends DataObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a member to a group.
|
||||
* Add a member to a group. This will create the group if the given
|
||||
* group code doesn't work.
|
||||
*
|
||||
* @param DataObject $member
|
||||
* @param string $groupcode
|
||||
@ -201,6 +202,15 @@ class Group extends DataObject {
|
||||
$member->Groups()->add($group);
|
||||
$member->write();
|
||||
}
|
||||
else {
|
||||
$group = new Group();
|
||||
$group->Code = $groupcode;
|
||||
$group->Title = $groupcode;
|
||||
$group->write();
|
||||
|
||||
$member->Groups()->add($group);
|
||||
$member->write();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user