a1a85c5a by Marty Penner

Move a few classes to a proper PSR4 directory

1 parent d17b9051
...@@ -396,48 +396,3 @@ function create_notification() ...@@ -396,48 +396,3 @@ function create_notification()
396 } 396 }
397 } 397 }
398 } 398 }
399
400 class Actions
401 {
402
403 public static function init()
404 {
405 /** @var \wpdb $wpdb */
406 global $wpdb;
407 $wpdb->show_errors();
408
409 register_post_type(
410 'notifications',
411 [
412 'label' => __('Notifs', CBV_DOMAIN),
413 'public' => true,
414 'show_ui' => false,
415 'hierarchical' => false,
416 'exclude_from_search' => true
417 ]
418 );
419 }
420
421 public static function admin_menu()
422 {
423 add_menu_page('Notifications', 'Notifications', CAPABILITY, 'notifications', __NAMESPACE__.'\display_page');
424 add_submenu_page(
425 'notifications',
426 'New Notification',
427 'New Notification',
428 CAPABILITY,
429 'notifications-create-new',
430 __NAMESPACE__.'\create_notification'
431 );
432 }
433
434 public function admin_init()
435 {
436 register_setting(SETTING_NS, SETTING_NS);
437 }
438 }
439
440 class Vars
441 {
442 public static $settings;
443 }
......
...@@ -16,9 +16,10 @@ call_user_func( ...@@ -16,9 +16,10 @@ call_user_func(
16 Tools\add_actions(__NAMESPACE__.'\Actions'); 16 Tools\add_actions(__NAMESPACE__.'\Actions');
17 Vars::$options = new Tools\WP_Option(OPTION_NAME); 17 Vars::$options = new Tools\WP_Option(OPTION_NAME);
18 Vars::$notices = []; 18 Vars::$notices = [];
19
19 if (is_admin()) { 20 if (is_admin()) {
20 require_once(__DIR__.DIRECTORY_SEPARATOR.'Validation.php'); 21 require_once(__DIR__.'/Validation.php');
21 require_once(__DIR__.DIRECTORY_SEPARATOR.'Admin.php'); 22 require_once(__DIR__.'/Admin.php');
22 } 23 }
23 } 24 }
24 ); 25 );
...@@ -107,10 +108,10 @@ function print_user_notices($showOnlyUnread = false) ...@@ -107,10 +108,10 @@ function print_user_notices($showOnlyUnread = false)
107 $system['system_message_type'] = 'notice'; 108 $system['system_message_type'] = 'notice';
108 } 109 }
109 110
110 $rows .= '<td width="80" style="vertical-align:middle;"><span>' 111 $rows .= '<td width="80" style="vertical-align: middle;"><span>'
111 .ucfirst(str_replace('_', '&nbsp;', $system['system_message_type'])) 112 .ucfirst(str_replace('_', '&nbsp;', $system['system_message_type']))
112 .'</span></td>'; 113 .'</span></td>';
113 $rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">' 114 $rows .= '<td style="vertical-align: middle;">'.nl2br($content).'<br /><span class="legal">'
114 .__('Sent:', CBV_DOMAIN) 115 .__('Sent:', CBV_DOMAIN)
115 .CBV\tz_display('notice_sent_date', $notice['sent_date']).'</span></td>'; 116 .CBV\tz_display('notice_sent_date', $notice['sent_date']).'</span></td>';
116 $rows .= '</tr>'; 117 $rows .= '</tr>';
...@@ -168,7 +169,7 @@ function get_num_notices() ...@@ -168,7 +169,7 @@ function get_num_notices()
168 return 0; 169 return 0;
169 } else { 170 } else {
170 foreach ($notices as $notice) { 171 foreach ($notices as $notice) {
171 if ($notice['status'] == "unread") { 172 if ($notice['status'] == 'unread') {
172 $notifications[] = $notice; 173 $notifications[] = $notice;
173 } 174 }
174 } 175 }
...@@ -208,7 +209,7 @@ function markNotice($notification_id = -1, $status = NOTIFICATION_STATUS_READ) ...@@ -208,7 +209,7 @@ function markNotice($notification_id = -1, $status = NOTIFICATION_STATUS_READ)
208 * 209 *
209 * @throws \Exception 210 * @throws \Exception
210 */ 211 */
211 function send_triggered_notification($uid = 0, $trigger = "NO_TRIGGER", $args = []) 212 function send_triggered_notification($uid = 0, $trigger = 'NO_TRIGGER', $args = [])
212 { 213 {
213 /** @var \wpdb $wpdb */ 214 /** @var \wpdb $wpdb */
214 global $wpdb; 215 global $wpdb;
...@@ -415,57 +416,3 @@ function current_url() ...@@ -415,57 +416,3 @@ function current_url()
415 416
416 return $pageURL; 417 return $pageURL;
417 } 418 }
418
419 class Actions
420 {
421 public static function wp_ajax_update_notification_count()
422 {
423 $count = get_num_notices();
424 $return = ['count' => $count];
425 die(json_encode($return));
426 }
427
428 public static function wp_ajax_mark_read()
429 {
430 markNotice($_POST['index'], NOTIFICATION_STATUS_READ);
431 }
432
433 public static function wp_ajax_mark_unread()
434 {
435 markNotice($_POST['index'], NOTIFICATION_STATUS_UNREAD);
436 }
437
438 public static function wp_ajax_print_user_notices()
439 {
440 print_user_notices();
441 }
442
443 public static function wp_ajax_remove_attachment()
444 {
445 $id = $_POST['id'];
446 $email = get_post_meta($id, 'email', true);
447 $attachments = $email['attachments'];
448 foreach ($attachments as $key => $name) {
449 if ($name == $_POST['file']) {
450 unset($attachments[$key]);
451 }
452 }
453
454 $email['attachments'] = $attachments;
455
456 update_post_meta($id, 'email', $email);
457
458 $return = ['success' => 'true'];
459 die(json_encode($return));
460 }
461 }
462
463 class Vars
464 {
465 public static $notices;
466 public static $options;
467 public static $field_lookup = [
468 'allusers' => 'All Users',
469 'report' => 'Report'
470 ];
471 }
......