public function SendMessage()
 {
     $facilitatorList = array();
     $groupInfo = array();
     // Get information for each selected group
     foreach ($this->rbtnSelectArray as $rbtnSelect) {
         if ($rbtnSelect->Checked) {
             $objGroup = Group::Load($rbtnSelect->ActionParameter);
             $objGroupParticipants = GroupParticipation::LoadArrayByGroupId($objGroup->Id);
             $bFoundContact = false;
             // Check for Contact person first
             foreach ($objGroupParticipants as $objParticipant) {
                 if ($objParticipant->GroupRoleId == $this->intGroupContactRoleId && $objParticipant->DateEnd == null) {
                     $objContact = Person::Load($objParticipant->PersonId);
                     $facilitatorList[] = $objContact;
                     $bFoundContact = true;
                     break;
                 }
             }
             // If contact person not found, grab facilitator
             if (!$bFoundContact) {
                 foreach ($objGroupParticipants as $objParticipant) {
                     if ($objParticipant->GroupRoleId == $this->intFacilitatorRoleId && $objParticipant->DateEnd == null) {
                         $objFacilitator = Person::Load($objParticipant->PersonId);
                         $facilitatorList[] = $objFacilitator;
                         break;
                     }
                 }
             }
             $ggGroup = GrowthGroup::Load($rbtnSelect->ActionParameter);
             $groupInfo[] = array(trim(str_replace(range(0, 9), '', $objGroup->Name)), $ggGroup->MeetingInfo);
         }
     }
     // Set debug mode
     //QEmailServer::$TestMode = true;
     //QEmailServer::$TestModeDirectory = __DOCROOT__ . '/../file_assets/emails';
     QEmailServer::$SmtpServer = SMTP_SERVER;
     // Create a new message
     // Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
     $objMessage = new QEmailMessage();
     $objMessage->From = 'Carisa Hamilton <*****@*****.**>';
     $objMessage->To = $this->objRegistrant->Email;
     $objMessage->Bcc = '*****@*****.**';
     $objMessage->Subject = 'Invitation to Growth Groups';
     // Setup Plaintext Message
     $strBody = "Dear " . $this->objRegistrant->FirstName . ",\r\n\r\n";
     $strBody .= "Thank you for your interest in Growth Groups! Below is the information for one or more Growth Groups in your area. Please contact the facilitators below for more information about visiting. I've copied them on this e-mail so that they will know of your interest.\r\n\r\n";
     $strBody .= sprintf("%s %s\r\n%s\r\n%s\r\n\r\n", $this->objRegistrant->FirstName, $this->objRegistrant->LastName, $this->objRegistrant->Phone, $this->objRegistrant->Email);
     if (count($groupInfo) >= 1) {
         if ($facilitatorList[0]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[0]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[0]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("%s, %s \r\\Contact: %s %s\r\n%s\r\n\r\n", $groupInfo[0][0], $groupInfo[0][1], $facilitatorList[0]->FirstName, $facilitatorList[0]->LastName, $email);
         $objMessage->Cc = $email;
     }
     if (count($groupInfo) >= 2) {
         if ($facilitatorList[1]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[1]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[1]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("%s, %s \r\\Contact: %s %s\r\n%s\r\n\r\n", $groupInfo[1][0], $groupInfo[1][1], $facilitatorList[1]->FirstName, $facilitatorList[1]->LastName, $email);
         $objMessage->Cc .= ', ' . $email;
     }
     if (count($groupInfo) >= 3) {
         if ($facilitatorList[1]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[2]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[2]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("%s, %s \r\\Contact: %s %s\r\n%s\r\n", $groupInfo[2][0], $groupInfo[2][1], $facilitatorList[2]->FirstName, $facilitatorList[2]->LastName, $email);
         $objMessage->Cc .= ', ' . $email;
     }
     $strBody .= '\\r\\n* Please don\'t hesitate to visit a group for 2 to 3 times before prayerfully deciding if the ' . 'group is a good fit for you.\\r\\n\\r\\n';
     $strBody .= 'Regards, \\r\\nCarisa Hamilton';
     $objMessage->Body = $strBody;
     // Also setup HTML message (optional)
     $strBody = "Dear " . $this->objRegistrant->FirstName . ',<br/><br/>';
     $strBody .= 'Thank you for your interest in Growth Groups! Below is the information for one or more Growth Groups ' . 'in your area. <br>Please contact the facilitators below for more information about visiting. ' . 'I have copied them on this e-mail so that they will know of your interest.<br><br>';
     $strBody .= sprintf("%s %s<br>%s<br>%s<br><br>", $this->objRegistrant->FirstName, $this->objRegistrant->LastName, $this->objRegistrant->Phone, $this->objRegistrant->Email);
     if (count($groupInfo) >= 1) {
         if ($facilitatorList[0]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[0]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[0]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("<b>Option 1</b><br>%s, %s<br>Contact: %s %s<br>%s<br><br>", $groupInfo[0][0], $groupInfo[0][1], $facilitatorList[0]->FirstName, $facilitatorList[0]->LastName, $email);
         $objMessage->Cc .= ', ' . $email;
     }
     if (count($groupInfo) >= 2) {
         if ($facilitatorList[1]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[1]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[1]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("<b>Option 2</b><br>%s, %s <br><b>Contact:</b> %s %s<br>%s<br><br>", $groupInfo[1][0], $groupInfo[1][1], $facilitatorList[1]->FirstName, $facilitatorList[1]->LastName, $email);
         $objMessage->Cc .= ', ' . $email;
     }
     if (count($groupInfo) >= 3) {
         if ($facilitatorList[1]->PrimaryEmailId == null) {
             $emailArray = Email::LoadArrayByPersonId($facilitatorList[2]->Id);
             $email = $emailArray[0]->Address;
             // just grab the first one we find
         } else {
             $email = Email::Load($facilitatorList[2]->PrimaryEmailId)->Address;
         }
         $strBody .= sprintf("<b>Option 3</b><br>%s, %s <br><b>Contact:</b> %s %s<br>%s<br>", $groupInfo[2][0], $groupInfo[2][1], $facilitatorList[2]->FirstName, $facilitatorList[2]->LastName, $email);
         $objMessage->Cc .= ', ' . $email;
     }
     $strBody .= '<br>* Please don\'t hesitate to visit a group for 2 to 3 times before prayerfully deciding if the ' . 'group is a good fit for you.<br><br>';
     $strBody .= 'Regards,<br/><b>Carisa Hamilton</b>';
     $objMessage->HtmlBody = $strBody;
     // Add random/custom email headers
     $objMessage->SetHeader('x-application', 'Growth Groups Ministry');
     QEmailServer::Send($objMessage);
 }
Example #2
0
    /**
     * Deletes all associated GroupParticipations
     * @return void
     */
    public function DeleteAllGroupParticipations()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateGroupParticipation on this unsaved Group.');
        }
        // Get the Database Object for this Class
        $objDatabase = Group::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (GroupParticipation::LoadArrayByGroupId($this->intId) as $objGroupParticipation) {
                $objGroupParticipation->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`group_participation`
				WHERE
					`group_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }