static function sendMailToParents($childID, $subjectTPL, $messageTPL, $templateVars, $additionalCC = null) { require_once 'SFS/Utils/Relationship.php'; $parentInfo = array(); SFS_Utils_Relationship::getParents($childID, $parentInfo, false); // make sure we unset the older parents for ($count = 1; $count < 5; $count++) { $templateVars["parent_{$count}_Name"] = null; } $count = 1; $toDisplayName = $toEmail = $cc = null; foreach ($parentInfo as $parent) { $templateVars["parent_{$count}_Name"] = $parent['name']; if ($parent['email']) { if (!$toEmail) { $toDisplayName = $parent['name']; $toEmail = $parent['email']; } else { if (!empty($cc)) { $cc .= ", "; } $cc .= $parent['email']; } } $count++; } if ($additionalCC) { if (!empty($cc)) { $cc .= ", "; } $cc .= $additionalCC; } // return if we dont have a toEmail if (!$toEmail) { return; } require_once 'SFS/Utils/Query.php'; list($templateVars['childName'], $templateVars['childEmail']) = SFS_Utils_Query::getNameAndEmail($childID); $template = CRM_Core_Smarty::singleton(); $template->assign($templateVars); require_once 'CRM/Utils/Mail.php'; require_once 'CRM/Utils/String.php'; $params = array('from' => self::SFS_FROM_EMAIL, 'toName' => $toDisplayName, 'toEmail' => $toEmail, 'subject' => $template->fetch($subjectTPL), 'text' => $template->fetch($messageTPL), 'cc' => $cc, 'bcc' => self::SFS_BCC_EMAIL); CRM_Utils_Mail::send($params); }
function sendConferenceEmail($activityID, $advisorID, $childID, $dateTime = null) { require_once 'SFS/Utils/Query.php'; $templateVars = array(); list($templateVars['advisorName'], $templateVars['advisorEmail']) = SFS_Utils_Query::getNameAndEmail($advisorID); if ($dateTime == null) { $dateTime = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'activity_date_time'); } $templateVars['dateTime'] = CRM_Utils_Date::customFormat($dateTime, "%l:%M %P on %b %E%f"); // now send a message to the parents about what they did require_once 'SFS/Utils/Mail.php'; SFS_Utils_Mail::sendMailToParents($childID, 'SFS/Mail/Conference/Subject.tpl', 'SFS/Mail/Conference/Message.tpl', $templateVars); }