function notify_send_notification_to_user
Search API
6.x notify.module | notify_send_notification_to_user($user_id, $msg, $cid = 0, $content_type = "", $notification_type = 'default', $attachments = array()) |
$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.
6 calls to notify_send_notification_to_user()
- calendar_appointment_content_form_validate in modules/
calendar/ calendar.module - Custom validate handler for when we save an appointment form. We want to confirm the student is valid, and also store ONLY the cwid.
- calendar_confirm_cancel_appointment_form_submit in modules/
calendar/ calendar.module - calendar_find_and_remind_notify_upcoming_appointments in modules/
calendar/ calendar.module - This function will find appointments approaching within X number of minutes, and send out notifications to all involved.
- calendar_schedule_appointment_confirm_form_submit in modules/
calendar/ calendar.module - We passed validation, it's time to actually submit now!
- engagements_handle_incoming_sms in modules/
engagements/ engagements.module - This catches incoming sms messages from POST, but can also be used by our "sms_get_all_messages" function, but it is also used by the sms_get_all_messages to save/update information.
File
- modules/
notify/ notify.module, line 14
Code
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);
}
}