/**
  * This function sends an email out to the user referenced by the notification_user record,
  * and returns whether sending the email was successful or not.
  * @return bool
  */
 public function send()
 {
     global $db, $AGENT_CONTACTS;
     require_once "Models/utility/TemplateMailer.class.php";
     $query = "SELECT a.`proxy_id`, b.`firstname`, b.`lastname`, b.`email`, a.`content_type`, a.`record_id`, a.`record_proxy_id` FROM `notification_users` AS a\n\t\t\t\t\tJOIN `" . AUTH_DATABASE . "`.`user_data` AS b\n\t\t\t\t\tON a.`proxy_id` = b.`id`\n\t\t\t\t\tWHERE a.`nuser_id` = " . $db->qstr($this->nuser_id);
     $user = $db->GetRow($query);
     if ($user) {
         $template = new Template();
         $template->loadString($this->notification_body);
         $mail = new TemplateMailer(new Zend_Mail());
         $mail->addHeader("X-Section", APPLICATION_NAME . " Notifications System", true);
         $from = array("email" => $AGENT_CONTACTS["agent-notifications"]["email"], "firstname" => APPLICATION_NAME . " Notification System", "lastname" => "");
         $to = array("email" => $user["email"], "firstname" => $user["firstname"], "lastname" => $user["lastname"]);
         try {
             $mail->send($template, $to, $from, DEFAULT_LANGUAGE);
             if ($this->setSentStatus(true)) {
                 application_log("success", "A [" . $user["content_type"] . "] notification has been sent to a user [" . $user["proxy_id"] . "] successfully.");
                 return true;
             }
         } catch (Zend_Mail_Transport_Exception $e) {
             system_log_data("error", "Unable to send [" . $user["content_type"] . "] notification to user [" . $user["proxy_id"] . "]. Template Mailer said: " . $e->getMessage());
         }
     }
     return false;
 }
             $timestamp = $history_timestamp["history_timestamp"];
         }
     }
 }
 $query = "  SELECT a.`community_id`, a.`proxy_id`, a.`member_acl`, b.`id`, b.`firstname`, b.`lastname`, b.`email`\n\t\t\t\t\t\t\tFROM `community_members` AS a\n\t\t\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_data` AS b\n\t\t\t\t\t\t\tON a.`proxy_id` = b.`id`\n\t\t\t\t\t\t\tWHERE a.`community_id` = " . $db->qstr($history_timestamp["community_id"]) . "\n\t\t\t\t\t\t\tAND a.member_acl = '1'";
 if ($timestamp >= strtotime("-6 months 00:00:00") && $timestamp <= strtotime("-6 months 23:59:59")) {
     $admin_info_results = $db->GetAll($query);
     if ($admin_info_results) {
         $xml_file = $ENTRADA_TEMPLATE->absolute() . "/email/community-cleanup.xml";
         $template = new Template($xml_file);
         foreach ($admin_info_results as $admin_info) {
             $keywords = array("application_name" => APPLICATION_NAME, "to_fullname" => $admin_info["firstname"] . " " . $admin_info["lastname"], "time_inactive" => "6 months,", "community_title" => $result["community_title"], "message" => "if you wish to deactivate the community you can do so by clicking the following link", "community_url" => ENTRADA_URL . "/communities?section=modify&community=" . $result["community_id"] . "&deactivate");
             $from = array("email" => $AGENT_CONTACTS["administrator"]["email"], "firstname" => $AGENT_CONTACTS["administrator"]["firstname"], "lastname" => $AGENT_CONTACTS["administrator"]["lastname"]);
             $to = array("email" => $admin_info["email"], "firstname" => $admin_info["firstname"], "lastname" => $admin_info["lastname"]);
             if ($SEND_EMAIL_NOTIFICATIONS) {
                 if ($mail->send($template, $to, $from, DEFAULT_LANGUAGE, $keywords)) {
                     application_log("cron", "Sent 6 month community inactivity e-mail to admin: [" . $admin_info["email"] . "]" . " community " . $admin_info["community_id"]);
                 } else {
                     application_log("error", "Unable to send e-mail notification to admin [" . $admin_info["email"] . "]" . " community " . $admin_info["community_id"]);
                 }
             } else {
                 application_log("cron", "Action: Send 6 month community inactivity e-mail to admin [" . $admin_info["email"] . "]" . " community " . $admin_info["community_id"]);
             }
         }
     }
 } elseif ($timestamp >= strtotime("-12 months 00:00:00") && $timestamp <= strtotime("-12 months 23:59:59")) {
     $admin_info_results = $db->GetAll($query);
     if ($admin_info_results) {
         $xml_file = $ENTRADA_TEMPLATE->absolute() . "/email/community-cleanup.xml";
         $template = new Template($xml_file);
         foreach ($admin_info_results as $admin_info) {
예제 #3
0
/**
 * Sends email based on the specified type using templates from $ENTRADA_TEMPLATE->absolute()/email directory
 * @param string $type One of "reason", "noreason"
 * @param array $to associative array consisting of firstname, lastname, and email
 * @param array $keywords Associative array of keywords mapped to the replacement contents
 */
function submission_rejection_notification($type, $to = array(), $keywords = array())
{
    global $AGENT_CONTACTS, $ENTRADA_TEMPLATE;
    if (!is_array($to) || !isset($to["email"]) || !valid_address($to["email"]) || !isset($to["firstname"]) || !isset($to["lastname"])) {
        application_log("error", "Attempting to send a submission_rejection_notification() however the recipient information was not complete.");
        return false;
    }
    if (!in_array($type, array("reason", "noreason"))) {
        application_log("error", "Encountered an unrecognized notification type [" . $type . "] when attempting to send a submission_rejection_notification().");
        return false;
    }
    $xml_file = $ENTRADA_TEMPLATE->absolute() . "/email/mspr-rejection-" . $type . ".xml";
    try {
        require_once "Models/utility/Template.class.php";
        require_once "Models/utility/TemplateMailer.class.php";
        $template = new Template($xml_file);
        $mail = new TemplateMailer(new Zend_Mail());
        $mail->addHeader("X-Section", "MSPR Module", true);
        $from = array("email" => $AGENT_CONTACTS["agent-notifications"]["email"], "firstname" => "MSPR System", "lastname" => "");
        if ($mail->send($template, $to, $from, DEFAULT_LANGUAGE, $keywords)) {
            return true;
        } else {
            add_notice("We were unable to e-mail a task notification <strong>" . $to["email"] . "</strong>.<br /><br />A system administrator was notified of this issue, but you may wish to contact this individual manually and let them know their task verification status.");
            application_log("error", "Unable to send task verification notification to [" . $to["email"] . "] / type [" . $type . "]. Zend_Mail said: " . $mail->ErrorInfo);
        }
    } catch (Exception $e) {
        application_log("error", "Unable to load the XML file [" . $xml_file . "] or the XML file did not contain the language requested [" . DEFAULT_LANGUAGE . "], when attempting to send a regional education notification.");
    }
    return false;
}