added removeFromGroupByCode() function to Member.php

I was using the addToGroupByCode() function today and it would have been handy to have a removeFromGroupByCode() so I decided to add one.
This commit is contained in:
andrewvt 2013-10-24 16:57:00 -04:00
parent 7cf8e65309
commit 9a11c643da

View File

@ -876,6 +876,19 @@ class Member extends DataObject implements TemplateGlobalProvider {
}
}
/**
* Removes a member from a group.
*
* @param string $groupcode
*/
public function removeFromGroupByCode($groupcode) {
$group = DataObject::get_one('Group', "\"Code\" = '" . Convert::raw2sql($groupcode). "'");
if($group) {
$this->Groups()->remove($group);
}
}
/**
* @param Array $columns Column names on the Member record to show in {@link getTitle()}.
* @param String $sep Separator