6d59626b by Marty Penner

Apply basic auto code formatting to the main Notifications file

1 parent b40ead7d
...@@ -9,47 +9,47 @@ use Tz\WordPress\CBV\User; ...@@ -9,47 +9,47 @@ use Tz\WordPress\CBV\User;
9 use WP_User; 9 use WP_User;
10 use Exception, StdClass; 10 use Exception, StdClass;
11 11
12
13 const OPTION_NAME = "notif_options"; 12 const OPTION_NAME = "notif_options";
14 13
15 call_user_func(function() { 14 call_user_func(
16 Tools\add_actions(__NAMESPACE__ . '\Actions'); 15 function()
16 {
17 Tools\add_actions(__NAMESPACE__.'\Actions');
17 Vars::$options = new Tools\WP_Option(OPTION_NAME); 18 Vars::$options = new Tools\WP_Option(OPTION_NAME);
18 Vars::$notices = Array(); 19 Vars::$notices = Array();
19 if (is_admin()) { 20 if (is_admin()) {
20 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'Validation.php'); 21 require_once(__DIR__.DIRECTORY_SEPARATOR.'Validation.php');
21 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'Admin.php'); 22 require_once(__DIR__.DIRECTORY_SEPARATOR.'Admin.php');
22 } 23 }
23 }); 24 });
24 25
25 26 function subval_sort($a, $subkey, $sort)
26 function subval_sort($a,$subkey,$sort) { 27 {
27 foreach($a as $k=>$v) { 28 foreach ($a as $k=> $v) {
28 $b[$k] = strtolower($v[$subkey]); 29 $b[$k] = strtolower($v[$subkey]);
29 } 30 }
30 $sort($b); 31 $sort($b);
31 foreach($b as $key=>$val) { 32 foreach ($b as $key=> $val) {
32 $c[] = $a[$key]; 33 $c[] = $a[$key];
33 } 34 }
34 return $c; 35 return $c;
35 } 36 }
36 37
37 function get_user_notices($uid) { 38 function get_user_notices($uid)
38 $notices = get_user_meta($uid,'notices',true); 39 {
39 if(!empty($notices)) { 40 $notices = get_user_meta($uid, 'notices', true);
40 41 if (!empty($notices)) {
41 $notices = subval_sort($notices,'sent_date','arsort'); 42 $notices = subval_sort($notices, 'sent_date', 'arsort');
42 Vars::$notices = $notices; 43 Vars::$notices = $notices;
43 } 44 }
44 } 45 }
45 46
46 function print_user_notices($show_more = true) { 47 function print_user_notices($show_more = true)
47 48 {
48 $user = new User\CurrentAccount(); 49 $user = new User\CurrentAccount();
49 50
50 get_user_notices($user->ID); 51 get_user_notices($user->ID);
51 52
52
53 if (CBV\on_page('/dashboard')) { 53 if (CBV\on_page('/dashboard')) {
54 $limit = 5; 54 $limit = 5;
55 } else { 55 } else {
...@@ -58,10 +58,9 @@ function print_user_notices($show_more = true) { ...@@ -58,10 +58,9 @@ function print_user_notices($show_more = true) {
58 58
59 $notices = Vars::$notices; 59 $notices = Vars::$notices;
60 $total_rows = count($notices); 60 $total_rows = count($notices);
61 $next_id = isset($_POST['last_id']) ? ($_POST['last_id']+1) : 0; 61 $next_id = isset($_POST['last_id']) ? ($_POST['last_id'] + 1) : 0;
62 $end = (($next_id + $limit) < $total_rows) ? ($next_id + $limit) : $total_rows; 62 $end = (($next_id + $limit) < $total_rows) ? ($next_id + $limit) : $total_rows;
63 63
64
65 if (count($notices) < 1) { 64 if (count($notices) < 1) {
66 //print '<tr><td colspan="3">You have no new notices.</td></tr>'; 65 //print '<tr><td colspan="3">You have no new notices.</td></tr>';
67 } 66 }
...@@ -69,26 +68,26 @@ function print_user_notices($show_more = true) { ...@@ -69,26 +68,26 @@ function print_user_notices($show_more = true) {
69 $rows = ""; 68 $rows = "";
70 69
71 $last_id = 0; 70 $last_id = 0;
72 for($i = 0; $i < $total_rows; $i++) { 71 for ($i = 0; $i < $total_rows; $i++) {
73 72
74 $the_notice = get_post($notices[$i]['notification_id']); 73 $the_notice = get_post($notices[$i]['notification_id']);
75 $system = get_post_meta($notices[$i]['notification_id'],'system',true); 74 $system = get_post_meta($notices[$i]['notification_id'], 'system', true);
76 $content = $system['message']; 75 $content = $system['message'];
77 $id = $the_notice->ID; 76 $id = $the_notice->ID;
78 77
79 if (isset($notices[$i]['args']) && count($notices[$i]['args']) > 0): 78 if (isset($notices[$i]['args']) && count($notices[$i]['args']) > 0):
80 foreach($notices[$i]['args'] as $key => $val) { 79 foreach ($notices[$i]['args'] as $key => $val) {
81 if (filter_var($val, FILTER_VALIDATE_URL) !== false) { 80 if (filter_var($val, FILTER_VALIDATE_URL) !== false) {
82 $content = str_replace("{".$key."}","<a href='".$val."'>Click here</a>",$content); 81 $content = str_replace("{".$key."}", "<a href='".$val."'>Click here</a>", $content);
83 } else { 82 } else {
84 $content = str_replace("{".$key."}",$val,$content); 83 $content = str_replace("{".$key."}", $val, $content);
85 } 84 }
86 } 85 }
87 endif; 86 endif;
88 87
89 $rows .= '<tr class="notice-row" id="'.$i.'">'; 88 $rows .= '<tr class="notice-row" id="'.$i.'">';
90 if ($notices[$i]['status']=="unread") { 89 if ($notices[$i]['status'] == "unread") {
91 $rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><a href="#" class="notice '.(($notices[$i]['status']=="read") ? 'read' : 'unread').'"><img src="assets/images/blank.gif" width="12" height="12" /></a></td>'; 90 $rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><a href="#" class="notice '.(($notices[$i]['status'] == "read") ? 'read' : 'unread').'"><img src="assets/images/blank.gif" width="12" height="12" /></a></td>';
92 } else { 91 } else {
93 $rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><img src="assets/images/blank.gif" width="12" height="12" /></td>'; 92 $rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><img src="assets/images/blank.gif" width="12" height="12" /></td>';
94 } 93 }
...@@ -101,55 +100,54 @@ function print_user_notices($show_more = true) { ...@@ -101,55 +100,54 @@ function print_user_notices($show_more = true) {
101 $system['system_message_type'] = "notice"; 100 $system['system_message_type'] = "notice";
102 } 101 }
103 102
104 $rows .= '<td width="80" style="vertical-align:middle;"><span>'.ucfirst(str_replace("_","&nbsp;",$system['system_message_type'])).'</span></td>'; 103 $rows .= '<td width="80" style="vertical-align:middle;"><span>'.ucfirst(
105 $rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date("M j, Y @ h:ia",$notices[$i]['sent_date']).'</span></td>'; 104 str_replace("_", "&nbsp;", $system['system_message_type'])).'</span></td>';
105 $rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date(
106 "M j, Y @ h:ia", $notices[$i]['sent_date']).'</span></td>';
106 /*endif;*/ 107 /*endif;*/
107 $rows .= '</tr>'; 108 $rows .= '</tr>';
108 $last_id = $i; 109 $last_id = $i;
109
110 } 110 }
111 111
112 if ($end < $total_rows && CBV\on_page('/notices')) { 112 if ($end < $total_rows && CBV\on_page('/notices')) {
113 //$rows .= '<tr id="TzMoreRows"><td colspan="4"><a onclick="return false;" class="load_more_notices" id="'.$last_id.'" href="#">Show more...</a></td></tr>'; 113 //$rows .= '<tr id="TzMoreRows"><td colspan="4"><a onclick="return false;" class="load_more_notices" id="'.$last_id.'" href="#">Show more...</a></td></tr>';
114 } 114 }
115 115
116 if(isset($_POST['ajax'])) { 116 if (isset($_POST['ajax'])) {
117 die($rows); 117 die($rows);
118 } else { 118 } else {
119 print $rows; 119 print $rows;
120 } 120 }
121
122
123 } 121 }
124 122
125 123 function get_notification_by_trigger($trigger)
126 function get_notification_by_trigger($trigger) { 124 {
127 $args = array( 125 $args = array(
128 'post_type' => 'notifications' 126 'post_type' => 'notifications',
129 , 'numberposts' => -1 127 'numberposts' => -1,
130 , 'orderby' => 'modified' 128 'orderby' => 'modified',
131 , 'order' => 'desc' 129 'order' => 'desc'
132 ); 130 );
133 131
134 $my_notif = false; 132 $my_notif = false;
135 133
136 foreach(get_posts($args) as $entry) { 134 foreach (get_posts($args) as $entry) {
137 $details = get_post_meta($entry->ID,'details',true); 135 $details = get_post_meta($entry->ID, 'details', true);
138 if ($details['type']=="triggered" && $details['trigger'] == $trigger) { 136 if ($details['type'] == "triggered" && $details['trigger'] == $trigger) {
139 $my_notif = $entry; 137 $my_notif = $entry;
140 break; 138 break;
141 } 139 }
142 } 140 }
143 141
144 return $my_notif; 142 return $my_notif;
145
146 } 143 }
147 144
148 /** 145 /**
149 * GET NUMBER OF NEW NOTICES 146 * GET NUMBER OF NEW NOTICES
150 @returns (Int) 147 @returns (Int)
151 */ 148 */
152 function get_num_notices() { 149 function get_num_notices()
150 {
153 // get number of notices for this user that are new... 151 // get number of notices for this user that are new...
154 $user = new User\CurrentAccount(); 152 $user = new User\CurrentAccount();
155 153
...@@ -157,11 +155,11 @@ function get_num_notices() { ...@@ -157,11 +155,11 @@ function get_num_notices() {
157 $notices = Vars::$notices; 155 $notices = Vars::$notices;
158 $notifications = array(); 156 $notifications = array();
159 // return $num; 157 // return $num;
160 if(empty($notices)) { 158 if (empty($notices)) {
161 return 0; 159 return 0;
162 } else { 160 } else {
163 foreach($notices as $notice) { 161 foreach ($notices as $notice) {
164 if ($notice['status']=="unread") { 162 if ($notice['status'] == "unread") {
165 $notifications[] = $notice; 163 $notifications[] = $notice;
166 } 164 }
167 } 165 }
...@@ -169,34 +167,36 @@ function get_num_notices() { ...@@ -169,34 +167,36 @@ function get_num_notices() {
169 return count($notifications); 167 return count($notifications);
170 } 168 }
171 169
172 function remove_notice($notification_id = -1) { 170 function remove_notice($notification_id = -1)
171 {
173 get_user_notices(Tools\getCurrentUser()->ID); 172 get_user_notices(Tools\getCurrentUser()->ID);
174 $notices = Vars::$notices; 173 $notices = Vars::$notices;
175 if (!empty($notices)) { 174 if (!empty($notices)) {
176 foreach($notices as $id => $notice) { 175 foreach ($notices as $id => $notice) {
177 if ($id==$notification_id) { 176 if ($id == $notification_id) {
178 $notices[$id]['status']="read"; 177 $notices[$id]['status'] = "read";
179 break; 178 break;
180 } 179 }
181 } 180 }
182 } 181 }
183 update_user_meta(Tools\getCurrentUser()->ID,'notices',$notices); 182 update_user_meta(Tools\getCurrentUser()->ID, 'notices', $notices);
184 } 183 }
185 184
186 /** 185 /**
187 Send Notifications 186 Send Notifications
188 @trigger = notification unique slug name 187 @trigger = notification unique slug name
189 */ 188 */
190 function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = array(),$send_override = false) { 189 function send_triggered_notification($uid = 0, $trigger = "NO_TRIGGER", $args = array(), $send_override = false)
190 {
191 global $wpdb; 191 global $wpdb;
192 $notification = get_notification_by_trigger($trigger); 192 $notification = get_notification_by_trigger($trigger);
193 193
194 if($notification) { 194 if ($notification) {
195 // get the notification and notificatio details.... 195 // get the notification and notificatio details....
196 $nid = $notification->ID; 196 $nid = $notification->ID;
197 $details = get_post_meta($nid,'details',true); 197 $details = get_post_meta($nid, 'details', true);
198 $email = get_post_meta($nid,'email',true); 198 $email = get_post_meta($nid, 'email', true);
199 $system = get_post_meta($nid,'system',true); 199 $system = get_post_meta($nid, 'system', true);
200 200
201 $notification->trigger = $details['trigger']; 201 $notification->trigger = $details['trigger'];
202 $notification->status = isset($details['status']) ? $details['status'] : "active"; 202 $notification->status = isset($details['status']) ? $details['status'] : "active";
...@@ -211,12 +211,12 @@ function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = arra ...@@ -211,12 +211,12 @@ function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = arra
211 $notices = Vars::$notices; 211 $notices = Vars::$notices;
212 212
213 $insert = array( 213 $insert = array(
214 'notification_id' => $nid 214 'notification_id' => $nid,
215 , 'status' => 'unread' 215 'status' => 'unread',
216 , 'sent_date' => current_time('timestamp') 216 'sent_date' => current_time('timestamp'),
217 , 'args' => $args 217 'args' => $args
218 ); 218 );
219 if(empty($notices)) { 219 if (empty($notices)) {
220 $notices = array(); 220 $notices = array();
221 } 221 }
222 222
...@@ -224,8 +224,7 @@ function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = arra ...@@ -224,8 +224,7 @@ function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = arra
224 224
225 $notices[$sequence] = $insert; 225 $notices[$sequence] = $insert;
226 226
227 227 update_user_meta($uid, 'notices', $notices);
228 update_user_meta($uid,'notices',$notices);
229 } 228 }
230 229
231 // if is_email =========================================== 230 // if is_email ===========================================
...@@ -233,7 +232,7 @@ function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = arra ...@@ -233,7 +232,7 @@ function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = arra
233 232
234 if ($uid == 0 && !isset($args['email'])) { 233 if ($uid == 0 && !isset($args['email'])) {
235 return; 234 return;
236 } elseif ( $uid == 0 && isset($args['email']) ) { 235 } elseif ($uid == 0 && isset($args['email'])) {
237 $to_email = $args['email']; 236 $to_email = $args['email'];
238 } else { 237 } else {
239 238
...@@ -259,9 +258,9 @@ function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = arra ...@@ -259,9 +258,9 @@ function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = arra
259 $html = $contents['html']; 258 $html = $contents['html'];
260 $alttext = strip_tags($contents['text']); 259 $alttext = strip_tags($contents['text']);
261 260
262 foreach($args as $key => $val) { 261 foreach ($args as $key => $val) {
263 if ( (filter_var($val, FILTER_VALIDATE_URL) !== false) && !empty($html)) { 262 if ((filter_var($val, FILTER_VALIDATE_URL) !== false) && !empty($html)) {
264 $html = str_replace("{".$key."}","<a href='".$val."'>".$val."</a>",$html); 263 $html = str_replace("{".$key."}", "<a href='".$val."'>".$val."</a>", $html);
265 } else { 264 } else {
266 $html = str_replace("{".$key."}", $val, $html); 265 $html = str_replace("{".$key."}", $val, $html);
267 $alttext = str_replace("{".$key."}", $val, $alttext); 266 $alttext = str_replace("{".$key."}", $val, $alttext);
...@@ -278,18 +277,21 @@ function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = arra ...@@ -278,18 +277,21 @@ function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = arra
278 $att2 = isset($attachments[1]) ? $attachments[1] : ''; 277 $att2 = isset($attachments[1]) ? $attachments[1] : '';
279 $att3 = isset($attachments[2]) ? $attachments[2] : ''; 278 $att3 = isset($attachments[2]) ? $attachments[2] : '';
280 279
281 $wpdb->query("INSERT INTO wp_mail_daemon (notification_id,from_email,to_email,subject,text,html,attachment1,attachment2,attachment3,sent,sent_date) VALUES ($nid,'$from_email','$to_email','$subject','$alttext','$html','$att1','$att2','$att3',0,'')"); 280 $wpdb->query(
282 281 "INSERT INTO wp_mail_daemon (notification_id,from_email,to_email,subject,text,html,attachment1,attachment2,attachment3,sent,sent_date) VALUES ($nid,'$from_email','$to_email','$subject','$alttext','$html','$att1','$att2','$att3',0,'')");
283 //send_email($uid,$email,$args, true); 282 //send_email($uid,$email,$args, true);
284 } 283 }
285 } 284 }
286 // if the system notification has set current user than get current user otherwise loop through the users needed. 285 // if the system notification has set current user than get current user otherwise loop through the users needed.
287 } 286 }
288 287
289 function send_email($uid = 0, $contents,$args, $override = false) { 288 function send_email($uid = 0, $contents, $args, $override = false)
290 if ( $uid == 0 && !isset($args['email'])) { return; } 289 {
290 if ($uid == 0 && !isset($args['email'])) {
291 return;
292 }
291 293
292 if ( isset($args['email'])) { 294 if (isset($args['email'])) {
293 $to_email = $args['email']; 295 $to_email = $args['email'];
294 } else { 296 } else {
295 $user = new WP_User($uid); 297 $user = new WP_User($uid);
...@@ -306,7 +308,6 @@ function send_email($uid = 0, $contents,$args, $override = false) { ...@@ -306,7 +308,6 @@ function send_email($uid = 0, $contents,$args, $override = false) {
306 $to_email = $user->user_email; 308 $to_email = $user->user_email;
307 } 309 }
308 } 310 }
309
310 } 311 }
311 312
312 $from_address = get_bloginfo('admin_email'); 313 $from_address = get_bloginfo('admin_email');
...@@ -323,16 +324,15 @@ function send_email($uid = 0, $contents,$args, $override = false) { ...@@ -323,16 +324,15 @@ function send_email($uid = 0, $contents,$args, $override = false) {
323 // it's text based only... no need to check format preference. 324 // it's text based only... no need to check format preference.
324 } else { 325 } else {
325 $message = $html; 326 $message = $html;
326 $headers .= 'MIME-Version: 1.0' . "\r\n"; 327 $headers .= 'MIME-Version: 1.0'."\r\n";
327 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 328 $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
328
329 // it's HTML formatted. 329 // it's HTML formatted.
330 // Check user preference if they want Text ONly?? 330 // Check user preference if they want Text ONly??
331 } 331 }
332 332
333 foreach($args as $key => $val) { 333 foreach ($args as $key => $val) {
334 if ( (filter_var($val, FILTER_VALIDATE_URL) !== false) && !empty($html)) { 334 if ((filter_var($val, FILTER_VALIDATE_URL) !== false) && !empty($html)) {
335 $message = str_replace("{".$key."}","<a href='".$val."'>".$val."</a>",$message); 335 $message = str_replace("{".$key."}", "<a href='".$val."'>".$val."</a>", $message);
336 } else { 336 } else {
337 $message = str_replace("{".$key."}", $val, $message); 337 $message = str_replace("{".$key."}", $val, $message);
338 $subject = str_replace("{".$key."}", $val, $subject); 338 $subject = str_replace("{".$key."}", $val, $subject);
...@@ -341,40 +341,45 @@ function send_email($uid = 0, $contents,$args, $override = false) { ...@@ -341,40 +341,45 @@ function send_email($uid = 0, $contents,$args, $override = false) {
341 341
342 // Additional headers 342 // Additional headers
343 //$headers .= 'To: '.$to_email.' <'.$to_email.'>' . "\r\n"; 343 //$headers .= 'To: '.$to_email.' <'.$to_email.'>' . "\r\n";
344 $headers .= 'From: CICBV <'.$from_address.'>' . "\r\n"; 344 $headers .= 'From: CICBV <'.$from_address.'>'."\r\n";
345 345
346 //die("To: $to_email, Subject: $subject, Message: $message, Header: $headers"); 346 //die("To: $to_email, Subject: $subject, Message: $message, Header: $headers");
347 347
348 mail($to_email, $subject, $message, $headers); 348 mail($to_email, $subject, $message, $headers);
349
350
351 } 349 }
352 350
353 function getGroups($grpID=0) { 351 function getGroups($grpID = 0)
352 {
354 global $userAccessManager; 353 global $userAccessManager;
355 354
356 $groups = array(); 355 $groups = array();
357 if($grpID > 0) { 356 if ($grpID > 0) {
358 $userGroups = $userAccessManager->getAccessHandler()->getUserGroups($grpID); 357 $userGroups = $userAccessManager
358 ->getAccessHandler()
359 ->getUserGroups($grpID);
359 return $userGroups->getGroupName(); 360 return $userGroups->getGroupName();
360 } else { 361 } else {
361 $userGroups = $userAccessManager->getAccessHandler()->getUserGroups(); 362 $userGroups = $userAccessManager
363 ->getAccessHandler()
364 ->getUserGroups();
362 } 365 }
363 foreach($userGroups as $group) { 366 foreach ($userGroups as $group) {
364 $groups[$group->getId()] = $group->getGroupName(); 367 $groups[$group->getId()] = $group->getGroupName();
365 } 368 }
366 return $groups; 369 return $groups;
367 } 370 }
368 371
369 function get_field_lookup($var) { 372 function get_field_lookup($var)
373 {
370 return isset(Vars::$field_lookup[$var]) ? Vars::$field_lookup[$var] : $var; 374 return isset(Vars::$field_lookup[$var]) ? Vars::$field_lookup[$var] : $var;
371 } 375 }
372 376
373 377 function current_url()
374 378 {
375 function current_url() {
376 $pageURL = 'http'; 379 $pageURL = 'http';
377 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} 380 if ($_SERVER["HTTPS"] == "on") {
381 $pageURL .= "s";
382 }
378 $pageURL .= "://"; 383 $pageURL .= "://";
379 if ($_SERVER["SERVER_PORT"] != "80") { 384 if ($_SERVER["SERVER_PORT"] != "80") {
380 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; 385 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
...@@ -384,27 +389,32 @@ function current_url() { ...@@ -384,27 +389,32 @@ function current_url() {
384 return $pageURL; 389 return $pageURL;
385 } 390 }
386 391
387 class Actions { 392 class Actions
388 public static function wp_ajax_update_notification_count() { 393 {
394 public static function wp_ajax_update_notification_count()
395 {
389 $count = get_num_notices(); 396 $count = get_num_notices();
390 $return = array('count'=>$count); 397 $return = array('count'=> $count);
391 die(json_encode($return)); 398 die(json_encode($return));
392 } 399 }
393 400
394 public static function wp_ajax_mark_read() { 401 public static function wp_ajax_mark_read()
402 {
395 remove_notice($_POST['index']); 403 remove_notice($_POST['index']);
396 } 404 }
397 405
398 public static function wp_ajax_print_user_notices() { 406 public static function wp_ajax_print_user_notices()
407 {
399 print_user_notices(); 408 print_user_notices();
400 } 409 }
401 410
402 public static function wp_ajax_remove_attachment() { 411 public static function wp_ajax_remove_attachment()
412 {
403 $id = $_POST['id']; 413 $id = $_POST['id'];
404 $email = get_post_meta($id,'email',true); 414 $email = get_post_meta($id, 'email', true);
405 $attachments = $email['attachments']; 415 $attachments = $email['attachments'];
406 foreach($attachments as $key => $name) { 416 foreach ($attachments as $key => $name) {
407 if ($name==$_POST['file']) { 417 if ($name == $_POST['file']) {
408 unset($attachments[$key]); 418 unset($attachments[$key]);
409 } 419 }
410 } 420 }
...@@ -415,18 +425,17 @@ class Actions { ...@@ -415,18 +425,17 @@ class Actions {
415 425
416 $return = array('success' => 'true'); 426 $return = array('success' => 'true');
417 die(json_encode($return)); 427 die(json_encode($return));
418
419 } 428 }
420
421
422 } 429 }
423 430
424 class Vars { 431 class Vars
432 {
425 public static $notices; 433 public static $notices;
426 public static $options; 434 public static $options;
427 public static $field_lookup = array( 435 public static $field_lookup = array(
428 'allusers' => "All Users" 436 'allusers' => "All Users",
429 , 'report' => "Report" 437 'report' => "Report"
430 ); 438 );
431 } 439 }
440
432 ?> 441 ?>
...\ No newline at end of file ...\ No newline at end of file
......