notify.module
Search API
File
modules/notify/notify.moduleView source
- <?php
-
-
-
-
-
-
- /**
- * $cid is the related content's cid, if applicable.
- *
- * If there is supposed to be an attachment, it's contents should be in $attachments. At the moment, this is only used by email.
- *
- */
- function notify_send_notification_to_user($user_id, $msg, $cid = 0, $content_type = "", $notification_type='default', $attachments = array()) {
-
- // TODO: As a safety measure, if the user is getting TOO MANY notifications, we should throttle it. Could be a hacking
- // attempt or something similar.
-
-
- $account = fp_load_user($user_id);
- $user_cwid = $account->cwid;
- // Let's find out what the user's default notification setting is. Unless it's set to NONE, we will
- // use their email address.
-
- $method = "";
-
- $default_notification_method = @$account->settings['default_notification_method'];
- if ($default_notification_method == "") {
- $default_notification_method = "email";
- }
-
- if ($default_notification_method == "NONE") {
- // The user does not have a default method. Therefor, we will not be notifying them about nothing.
- return;
- }
-
- $method = $default_notification_method;
-
- $user_email = $account->email;
- $mobile_phone = @$account->attributes['mobile_phone'];
-
- $subject = t("FlightPath - Notification");
-
-
- $msg .= "<br><br>\n\n " . t("To change your notification options, visit your settings page in @name.", array("@name" => variable_get("system_name", "FlightPath")));
-
-
-
- if ($method == 'email') {
- notify_by_mail($user_email, $subject, $msg, $attachments);
- notify_save_notification($user_id, $cid, $content_type, 'email', $user_email, $subject, $msg, $notification_type);
- }
- if ($method == 'txt') {
- notify_by_sms($mobile_phone, $subject, $msg);
- notify_save_notification($user_id, $cid, $content_type, 'txt', $mobile_phone, $subject, $msg, $notification_type);
- }
-
- if ($method == 'email_txt') {
- // Sending to both.
- notify_by_mail($user_email, $subject, $msg, $attachments);
- notify_save_notification($user_id, $cid, $content_type, 'email', $user_email, $subject, $msg, $notification_type);
-
- notify_by_sms($mobile_phone, $subject, $msg);
- notify_save_notification($user_id, $cid, $content_type, 'txt', $mobile_phone, $subject, $msg, $notification_type);
- }
-
-
-
- } // notify_send_notification_to_user
-
-
-
- /**
- * Actually writes our notification to our notification_history table.
- */
- function notify_save_notification($user_id, $cid = 0, $content_type = "", $method, $address_or_num, $subject, $msg, $type = 'default') {
- db_query("INSERT INTO notification_history (cid, content_type, to_user_id, notification_method, to_address, subject, msg, notification_type, submitted)
- VALUES (?,?,?,?,?,?,?,?,?) ", array($cid, $content_type, intval($user_id), $method, $address_or_num, $subject, $msg, $type, time()));
-
- return db_insert_id();
- }
-
-
-
-
-
- function notify_by_mail($email, $subject, $msg, $attachments = array()) {
-
-
- // We will assume the attachments is in "string" format, if present.
- $bool_attachment_string = FALSE;
- if (count($attachments) > 0) $bool_attachment_string = TRUE;
-
- fp_mail($email, $subject, $msg, TRUE, $attachments, $bool_attachment_string);
- }
-
-
-
- function notify_by_sms($mobile_phone, $subject, $msg) {
-
- // The msg cannot have any HTML, since it's just a text message.
- $msg = filter_markup($msg, 'plain');
- $msg = str_replace("&", "&", $msg); // trouble HTML chars back into normal chars for SMS.
-
- engagements_send_sms_to_number($mobile_phone, $subject . "\n--\n" . $msg);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Functions
Name | Description |
---|---|
notify_by_mail | |
notify_by_sms | |
notify_save_notification | Actually writes our notification to our notification_history table. |
notify_send_notification_to_user | $cid is the related content's cid, if applicable. |