From c0db4520691b414549b3bffddc407ee6ce36f687 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 16 Dec 2009 05:41:08 +0000 Subject: [PATCH] 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 --- security/Group.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/security/Group.php b/security/Group.php index a82421b50..d9510c5e1 100644 --- a/security/Group.php +++ b/security/Group.php @@ -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(); + } } /**