updates to the notification system
Showing
1 changed file
with
16 additions
and
16 deletions
| ... | @@ -181,16 +181,10 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), | ... | @@ -181,16 +181,10 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), |
| 181 | 181 | ||
| 182 | 182 | ||
| 183 | $notification = get_notification_by_trigger($trigger); | 183 | $notification = get_notification_by_trigger($trigger); |
| 184 | |||
| 185 | |||
| 184 | if($notification) { | 186 | if($notification) { |
| 185 | 187 | ||
| 186 | // get the user and user details.... | ||
| 187 | if ($uid > 0) { | ||
| 188 | $user = new WP_User($uid);//Tools\getCurrentUser(); | ||
| 189 | $notify_me = get_user_meta($user->ID,'notify_me',true); | ||
| 190 | $notify_format = get_user_meta($user->ID,'notify_format',true); | ||
| 191 | $email_preference = get_user_meta($user->ID,'email_address_preference',true); | ||
| 192 | $cell = get_user_meta($user->ID,'mobile',true); | ||
| 193 | } | ||
| 194 | 188 | ||
| 195 | // get the notification and notificatio details.... | 189 | // get the notification and notificatio details.... |
| 196 | $nid = $notification->ID; | 190 | $nid = $notification->ID; |
| ... | @@ -205,6 +199,8 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), | ... | @@ -205,6 +199,8 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), |
| 205 | $notification->type = $details['type']; | 199 | $notification->type = $details['type']; |
| 206 | $notification->sendto = $details['sendto']; | 200 | $notification->sendto = $details['sendto']; |
| 207 | 201 | ||
| 202 | |||
| 203 | |||
| 208 | $notification->is_email = (($email['text'] != "" || $email['html'] != "") && $email['subject'] != "") ? true : false; | 204 | $notification->is_email = (($email['text'] != "" || $email['html'] != "") && $email['subject'] != "") ? true : false; |
| 209 | $notification->is_system = (isset($system['message']) && $system['message'] != "") ? true : false; | 205 | $notification->is_system = (isset($system['message']) && $system['message'] != "") ? true : false; |
| 210 | $notification->is_sms = (isset($sms['message']) && $sms['message'] != "") ? true : false; | 206 | $notification->is_sms = (isset($sms['message']) && $sms['message'] != "") ? true : false; |
| ... | @@ -241,7 +237,7 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), | ... | @@ -241,7 +237,7 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), |
| 241 | 237 | ||
| 242 | // if is_email =========================================== | 238 | // if is_email =========================================== |
| 243 | if ($notification->is_email) { | 239 | if ($notification->is_email) { |
| 244 | send_email($uid,$email,$args); | 240 | send_email($uid,$email,$args, true); |
| 245 | } | 241 | } |
| 246 | 242 | ||
| 247 | 243 | ||
| ... | @@ -249,18 +245,20 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), | ... | @@ -249,18 +245,20 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), |
| 249 | // if the system notification has set current user than get current user otherwise loop through the users needed. | 245 | // if the system notification has set current user than get current user otherwise loop through the users needed. |
| 250 | } | 246 | } |
| 251 | 247 | ||
| 252 | function send_email($uid, $contents,$args) { | 248 | function send_email($uid = 0, $contents,$args, $override = false) { |
| 253 | $from_address = get_bloginfo('admin_email'); | ||
| 254 | 249 | ||
| 255 | if ($uid > 0) { | 250 | if ( $uid == 0 && !isset($args['email'])) { return; } |
| 256 | $user = new WP_User($uid); | 251 | |
| 257 | $to_email = $user->user_email;//get_user_meta($uid,'home_email',true); | 252 | |
| 258 | } elseif (isset($args['email'])) { | 253 | if ( isset($args['email'])) { |
| 259 | $to_email = $args['email']; | 254 | $to_email = $args['email']; |
| 260 | } else { | 255 | } else { |
| 261 | return; | 256 | $user = new WP_User($uid); |
| 257 | $to_email = $user->user_email; | ||
| 262 | } | 258 | } |
| 263 | 259 | ||
| 260 | $from_address = get_bloginfo('admin_email'); | ||
| 261 | |||
| 264 | 262 | ||
| 265 | $subject = $contents['subject']; | 263 | $subject = $contents['subject']; |
| 266 | $html = $contents['html']; | 264 | $html = $contents['html']; |
| ... | @@ -294,6 +292,8 @@ function send_email($uid, $contents,$args) { | ... | @@ -294,6 +292,8 @@ function send_email($uid, $contents,$args) { |
| 294 | //$headers .= 'To: '.$to_email.' <'.$to_email.'>' . "\r\n"; | 292 | //$headers .= 'To: '.$to_email.' <'.$to_email.'>' . "\r\n"; |
| 295 | $headers .= 'From: CICBV <'.$from_address.'>' . "\r\n"; | 293 | $headers .= 'From: CICBV <'.$from_address.'>' . "\r\n"; |
| 296 | 294 | ||
| 295 | //die("To: $to_email, Subject: $subject, Message: $message, Header: $headers"); | ||
| 296 | |||
| 297 | mail($to_email, $subject, $message, $headers); | 297 | mail($to_email, $subject, $message, $headers); |
| 298 | 298 | ||
| 299 | 299 | ... | ... |
-
Please register or sign in to post a comment