Exemple #1
0
 /**
  * This is the base function for sending mail;
  * it looks up the form, and fills in the params,
  * then calls mail.
  */
 public function sendForm($to, array $params = NULL)
 {
     try {
         $sendBody = $this->body;
         if (!is_null($params)) {
             if (count($this->paramNames) != count($params)) {
                 logMessage('FormMail.sendForm(' . $to . ')', 'params do not match');
             }
             $sendBody = $this->body;
             foreach ($this->paramNames as $param) {
                 $sendBody = str_replace($param, $params[$param], $sendBody);
             }
         }
         FormMail::send($to, $this->subject, $sendBody);
     } catch (Exception $ex) {
         logMessage('FormMail.sendForm(' . $to . ')', $ex->getMessage());
     }
 }
$message = swwat_parse_string(html_entity_decode($_POST[PARAM_MESSAGE]));
$list = $_POST[PARAM_LIST_INDEX];
if (!is_null($list) && ($typeFlag && (!is_null($subject) || !is_null($message)) || !$typeFlag && !is_null($message))) {
    if (!$typeFlag) {
        $subject = "";
        // ensure blank
        $message = substr($message, 0, 160);
    }
    $workerList = $_SESSION[PARAM_LIST];
    for ($k = 0; $k < count($list); $k++) {
        try {
            $listIndex = swwat_parse_number(html_entity_decode($list[$k]), FALSE);
            $worker = $workerList[$listIndex];
            $to = $typeFlag ? $worker->email : $worker->smsemail;
            if (!is_null($to) && strlen($to) > 0) {
                FormMail::send($to, $subject, $message);
            } else {
                /* continue to process list */
                logMessage("SendMessageAction", "failure with to field:" . $to . " index:" . $k . " value:" . $list[$k]);
            }
        } catch (ParseSWWATException $pe) {
            /* continue to process list */
            logMessage("SendMessageAction", "failure with index:" . $k . " value:" . $list[$k]);
        }
    }
    // $k
}
// all null
// return to whence we came
if (is_null(getStationCurrent())) {
    if (is_null(getExpoCurrent())) {
// create data array
// loop over array of emails
foreach ($email_array as $email) {
    $messages = $messagedata[$email];
    $subject = $messages[0]->expo . " Reminder";
    $message = "Dear " . $messages[0]->workerName . ",\n\n";
    if (PARAM_ANTEREMINDER_TIME == 1) {
        $message .= "This message is to remind you that your upcoming shift assignment for " . PARAM_ANTEREMINDER_TIME . " day from now is:\n\n";
    } else {
        $message .= "This message is to remind you that your upcoming shift assignment for " . PARAM_ANTEREMINDER_TIME . " days from now is:\n\n";
    }
    $message .= "Expo: " . $messages[0]->expo . "\n\n";
    $body = $message;
    foreach ($messages as $message) {
        $body .= "Station: " . $message->station . "\n";
        $shift = explode(';', swwat_format_shift($message->startTime, $message->stopTime));
        $body .= "Time: " . $shift[0] . " (" . $shift[1] . ")\n";
    }
    // $message
    //START SIGNATURE BLOCK
    $message .= "\n\n Your participation in the conference is appreciated.";
    //    $message .= "\n\n Please notify us at zzz-xxx-yyyy if unable to make your shift.";
    $message .= "\n\n Thank you,";
    $message .= "\n\n Your " . SITE_NAME . " Team";
    // ENDIT SIGNATURE BLOCK
    FormMail::send($email, $subject, $body);
    logMessage("SendMessagesCron", "email sent to " . $email);
}
// $email
ReminderSent::insert(swwat_format_isodate($targtag));
logMessage("SendMessagesCron", "Date: " . swwat_format_isodate($targtag) . " written to database.");