a7dd9328 by Chris Boden

Parsed subject line, removed HTML from subject line

1 parent 9827b8e2
...@@ -188,34 +188,27 @@ function remove_notice($notification_id = -1) { ...@@ -188,34 +188,27 @@ function remove_notice($notification_id = -1) {
188 @trigger = notification unique slug name 188 @trigger = notification unique slug name
189 */ 189 */
190 function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(),$send_override = false) { 190 function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(),$send_override = false) {
191
192
193 $notification = get_notification_by_trigger($trigger); 191 $notification = get_notification_by_trigger($trigger);
194 192
195
196 if($notification) { 193 if($notification) {
197
198
199 // get the notification and notificatio details.... 194 // get the notification and notificatio details....
200 $nid = $notification->ID; 195 $nid = $notification->ID;
201 $details = get_post_meta($nid,'details',true); 196 $details = get_post_meta($nid,'details',true);
202 $email = get_post_meta($nid,'email',true); 197 $email = get_post_meta($nid,'email',true);
203 $system = get_post_meta($nid,'system',true); 198 $system = get_post_meta($nid,'system',true);
204 199
205
206 $notification->trigger = $details['trigger']; 200 $notification->trigger = $details['trigger'];
207 $notification->status = isset($details['status']) ? $details['status'] : "active"; 201 $notification->status = isset($details['status']) ? $details['status'] : "active";
208 $notification->type = $details['type']; 202 $notification->type = $details['type'];
209 $notification->sendto = $details['sendto']; 203 $notification->sendto = $details['sendto'];
210 $notification->is_email = (($email['text'] != "" || $email['html'] != "") && $email['subject'] != "") ? true : false; 204 $notification->is_email = (($email['text'] != "" || $email['html'] != "") && $email['subject'] != "") ? true : false;
211 $notification->is_system = (isset($system['message']) && $system['message'] != "") ? true : false; 205 $notification->is_system = (isset($system['message']) && $system['message'] != "") ? true : false;
212 206
213
214 // if is_system ========================================== 207 // if is_system ==========================================
215 if ($notification->is_system && $uid != 0) { 208 if ($notification->is_system && $uid != 0) {
216 get_user_notices($uid); 209 get_user_notices($uid);
217 $notices = Vars::$notices; 210 $notices = Vars::$notices;
218 211
219 $insert = array( 212 $insert = array(
220 'notification_id' => $nid 213 'notification_id' => $nid
221 , 'status' => 'unread' 214 , 'status' => 'unread'
...@@ -234,22 +227,17 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(), ...@@ -234,22 +227,17 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(),
234 update_user_meta($uid,'notices',$notices); 227 update_user_meta($uid,'notices',$notices);
235 } 228 }
236 229
237
238 // if is_email =========================================== 230 // if is_email ===========================================
239 if ($notification->is_email) { 231 if ($notification->is_email) {
240 send_email($uid,$email,$args, true); 232 send_email($uid,$email,$args, true);
241 } 233 }
242
243
244 } 234 }
245 // if the system notification has set current user than get current user otherwise loop through the users needed. 235 // if the system notification has set current user than get current user otherwise loop through the users needed.
246 } 236 }
247 237
248 function send_email($uid = 0, $contents,$args, $override = false) { 238 function send_email($uid = 0, $contents,$args, $override = false) {
249
250 if ( $uid == 0 && !isset($args['email'])) { return; } 239 if ( $uid == 0 && !isset($args['email'])) { return; }
251 240
252
253 if ( isset($args['email'])) { 241 if ( isset($args['email'])) {
254 $to_email = $args['email']; 242 $to_email = $args['email'];
255 } else { 243 } else {
...@@ -272,10 +260,9 @@ function send_email($uid = 0, $contents,$args, $override = false) { ...@@ -272,10 +260,9 @@ function send_email($uid = 0, $contents,$args, $override = false) {
272 260
273 $from_address = get_bloginfo('admin_email'); 261 $from_address = get_bloginfo('admin_email');
274 262
275 263 $subject = strip_tags($contents['subject']);
276 $subject = $contents['subject']; 264 $html = $contents['html'];
277 $html = $contents['html']; 265 $alttext = $contents['text'];
278 $alttext = $contents['text'];
279 266
280 $headers = ""; 267 $headers = "";
281 268
...@@ -296,11 +283,11 @@ function send_email($uid = 0, $contents,$args, $override = false) { ...@@ -296,11 +283,11 @@ function send_email($uid = 0, $contents,$args, $override = false) {
296 if ( (filter_var($val, FILTER_VALIDATE_URL) !== false) && !empty($html)) { 283 if ( (filter_var($val, FILTER_VALIDATE_URL) !== false) && !empty($html)) {
297 $message = str_replace("{".$key."}","<a href='".$val."'>".$val."</a>",$message); 284 $message = str_replace("{".$key."}","<a href='".$val."'>".$val."</a>",$message);
298 } else { 285 } else {
299 $message = str_replace("{".$key."}",$val,$message); 286 $message = str_replace("{".$key."}", $val, $message);
287 $subject = str_replace("{".$key."}", $val, $subject);
300 } 288 }
301
302 } 289 }
303 290
304 // Additional headers 291 // Additional headers
305 //$headers .= 'To: '.$to_email.' <'.$to_email.'>' . "\r\n"; 292 //$headers .= 'To: '.$to_email.' <'.$to_email.'>' . "\r\n";
306 $headers .= 'From: CICBV <'.$from_address.'>' . "\r\n"; 293 $headers .= 'From: CICBV <'.$from_address.'>' . "\r\n";
......