9ea0a7cb by Kevin Burton

updates to the notification system

1 parent 3c508f67
......@@ -181,16 +181,10 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(),
$notification = get_notification_by_trigger($trigger);
if($notification) {
// get the user and user details....
if ($uid > 0) {
$user = new WP_User($uid);//Tools\getCurrentUser();
$notify_me = get_user_meta($user->ID,'notify_me',true);
$notify_format = get_user_meta($user->ID,'notify_format',true);
$email_preference = get_user_meta($user->ID,'email_address_preference',true);
$cell = get_user_meta($user->ID,'mobile',true);
}
// get the notification and notificatio details....
$nid = $notification->ID;
......@@ -205,6 +199,8 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(),
$notification->type = $details['type'];
$notification->sendto = $details['sendto'];
$notification->is_email = (($email['text'] != "" || $email['html'] != "") && $email['subject'] != "") ? true : false;
$notification->is_system = (isset($system['message']) && $system['message'] != "") ? true : false;
$notification->is_sms = (isset($sms['message']) && $sms['message'] != "") ? true : false;
......@@ -241,7 +237,7 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(),
// if is_email ===========================================
if ($notification->is_email) {
send_email($uid,$email,$args);
send_email($uid,$email,$args, true);
}
......@@ -249,18 +245,20 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(),
// if the system notification has set current user than get current user otherwise loop through the users needed.
}
function send_email($uid, $contents,$args) {
$from_address = get_bloginfo('admin_email');
function send_email($uid = 0, $contents,$args, $override = false) {
if ($uid > 0) {
$user = new WP_User($uid);
$to_email = $user->user_email;//get_user_meta($uid,'home_email',true);
} elseif (isset($args['email'])) {
if ( $uid == 0 && !isset($args['email'])) { return; }
if ( isset($args['email'])) {
$to_email = $args['email'];
} else {
return;
$user = new WP_User($uid);
$to_email = $user->user_email;
}
$from_address = get_bloginfo('admin_email');
$subject = $contents['subject'];
$html = $contents['html'];
......@@ -294,6 +292,8 @@ function send_email($uid, $contents,$args) {
//$headers .= 'To: '.$to_email.' <'.$to_email.'>' . "\r\n";
$headers .= 'From: CICBV <'.$from_address.'>' . "\r\n";
//die("To: $to_email, Subject: $subject, Message: $message, Header: $headers");
mail($to_email, $subject, $message, $headers);
......