public static function save_current_msg() { $emailmsg = new EventEmail(); $emailmsg->write(); // Set the Member relation to this order $emailmsg->Member = Member::currentUserID(); // Write the order $emailmsg->write(); return $emailmsg; }
protected function processMessage($data, $form, $request) { //Decide who to send this message to $cleanupid = $_REQUEST['CleanupID']; if (!$cleanupid) { Director::redirect('my-events/Error/'); } $cleanup = DataObject::get_one('CleanUpGroup', "CleanUpGroup.ID = '{$cleanupid}'"); $creatorid = $cleanup->CreatorID; $curr_member = Member::currentUser(); $memberid = Member::currentUserID(); if ($creatorid == $memberid) { //CASE1: CLEANUP ADMIN EMAIL! sends to group $members = $cleanup->getManyManyComponents("Members"); if (!$members) { //this better work Director::redirect('Nomembers'); } foreach ($members as $member) { $emailmsg = EventEmail::save_current_msg(); $form->saveInto($emailmsg); $emailmsg->MemberID = $memberid; $emailmsg->SenderEmail = $_REQUEST['Email']; $emailmsg->Recipient = $member->Email; $emailmsg->CleanUpGroupID = $cleanupid; $emailmsg->write(); $emailmsg->goMessage(); } Director::redirectBack(); } else { //CASE2: SEND CLEANUP ADMIN AN EMAIL! $creator = DataObject::get_by_id('Member', $creatorid); $emailmsg = EventEmail::save_current_msg(); $form->saveInto($emailmsg); $emailmsg->MemberID = $memberid; $emailmsg->FirstName = $_REQUEST['FirstName']; $emailmsg->Phone = $_REQUEST['Phone']; $emailmsg->SenderEmail = $_REQUEST['Email']; $emailmsg->Message = $_REQUEST['Message']; $emailmsg->Recipient = $creator->Email; $emailmsg->CleanUpGroupID = $cleanupid; $emailmsg->write(); $emailmsg->goMessage(); Director::redirectBack(); } //PROCESS ENDS }
protected function processInvites($data, $form, $request) { //Decide who to send this message to $cleanupid = $_REQUEST['CleanupID']; if (!$cleanupid) { Director::redirect('my-events/Error/'); } $cleanup = DataObject::get_one('CleanUpGroup', "CleanUpGroup.ID = '{$cleanupid}'"); $creator = Member::currentUser(); $creatorid = Member::currentUserID(); //CASE: Send Email to Recipients list! $emailmsg = EventEmail::save_current_msg(); $form->saveInto($emailmsg); $emailmsg->MemberID = $creatorid; $emailmsg->SenderEmail = $_REQUEST['Email']; $emailmsg->Recipients = $_REQUEST['Recipients']; $emailmsg->CleanUpGroupID = $cleanupid; $emailmsg->write(); $emailmsg->invitePeeps(); Director::redirectBack(); //PROCESS ENDS }
function joinevent($request) { $member = Member::currentUser(); if ($cleanupID = $request->param('ID')) { if ($cleangroup = DataObject::get_by_id('CleanUpGroup', $cleanupID)) { $memberid = Member::currentUserID(); //$curr_mems = $cleangroup->JoinedCount; //Send an email $emailmsg = new EventEmail(); $emailmsg->MemberID = $memberid; $emailmsg->FirstName = $member->FirstName; $emailmsg->Subject = 'Thanks for Joining in on Love Your Coast'; $emailmsg->Recipient = $member->Email; $emailmsg->CleanUpGroupID = $cleanupID; $emailmsg->write(); $emailmsg->joinEmail(); //Add the member as a Joined record $cleanup = DataObject::get_by_id('CleanUpGroup', $cleanupID); //$cleanup->JoinedCount = ++$curr_mems; $cleanup->write(); //Add the member to the group $member->CleanUpGroups()->add($cleangroup); // Redirect to my cleanup week Director::redirect($cleangroup->Link()); } else { Director::redirectBack(); } } }