inform-merge r33051: WIP3610: Fact finder finishes

WIP3613: Newsletter integration 

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@45524 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2007-11-23 05:15:22 +00:00
parent a584cff4bb
commit df30647a88

View File

@ -252,6 +252,48 @@ class Member extends DataObject {
* @return Member_Validator Returns an instance of a * @return Member_Validator Returns an instance of a
* {@link Member_Validator} object. * {@link Member_Validator} object.
*/ */
function getNewsletterSubscriptions(){
$groups = $this->Groups()->toDropDownMap("ID","ID");
return $groups;
}
/**
* This does some cunning and automatically save the newsletter subscriptions
* by adding and removing the member from the appropriate
* groups based on a checkboxset field.
* This function is called by the form handler
* whenever form->saveInto($member); is called with an
* checkboxsetfield in the data with the name
* "newsletterSubscriptions"
*/
function saveNewsletterSubscriptions($groups){
$checkboxsetfield = new CheckboxSetField(
"NewsletterSubscriptions",
"",
$sourceitems = DataObject::get("NewsletterType")->toDropDownMap("GroupID","Title"),
$selectedgroups = $groups
);
return $this->Groups()->setByCheckboxSetField($checkboxsetfield);
}
function removeAllNewsletterSubscriptions(){
$groups = $this->Groups();
$groupIDs = $groups->getIDList();
$newsletterTypes = DataObject::get("NewsletterType");
if($newsletterTypes&&$newsletterTypes->count()){
foreach($newsletterTypes as $type){
$newsletterGroupIDs[] = $type->GroupID;
}
}
if($newsletterGroupIDs) {
foreach($newsletterGroupIDs as $newsletterGroupID){
if($groupIDs&&in_array($newsletterGroupID, $groupIDs)){
$groups->remove($newsletterGroupID);
}
}
}
}
function getValidator() { function getValidator() {
return new Member_Validator(); return new Member_Validator();
} }