a1a85c5a by Marty Penner

Move a few classes to a proper PSR4 directory

1 parent d17b9051
......@@ -396,48 +396,3 @@ function create_notification()
}
}
}
class Actions
{
public static function init()
{
/** @var \wpdb $wpdb */
global $wpdb;
$wpdb->show_errors();
register_post_type(
'notifications',
[
'label' => __('Notifs', CBV_DOMAIN),
'public' => true,
'show_ui' => false,
'hierarchical' => false,
'exclude_from_search' => true
]
);
}
public static function admin_menu()
{
add_menu_page('Notifications', 'Notifications', CAPABILITY, 'notifications', __NAMESPACE__.'\display_page');
add_submenu_page(
'notifications',
'New Notification',
'New Notification',
CAPABILITY,
'notifications-create-new',
__NAMESPACE__.'\create_notification'
);
}
public function admin_init()
{
register_setting(SETTING_NS, SETTING_NS);
}
}
class Vars
{
public static $settings;
}
......
......@@ -16,9 +16,10 @@ call_user_func(
Tools\add_actions(__NAMESPACE__.'\Actions');
Vars::$options = new Tools\WP_Option(OPTION_NAME);
Vars::$notices = [];
if (is_admin()) {
require_once(__DIR__.DIRECTORY_SEPARATOR.'Validation.php');
require_once(__DIR__.DIRECTORY_SEPARATOR.'Admin.php');
require_once(__DIR__.'/Validation.php');
require_once(__DIR__.'/Admin.php');
}
}
);
......@@ -107,10 +108,10 @@ function print_user_notices($showOnlyUnread = false)
$system['system_message_type'] = 'notice';
}
$rows .= '<td width="80" style="vertical-align:middle;"><span>'
$rows .= '<td width="80" style="vertical-align: middle;"><span>'
.ucfirst(str_replace('_', '&nbsp;', $system['system_message_type']))
.'</span></td>';
$rows .= '<td style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">'
$rows .= '<td style="vertical-align: middle;">'.nl2br($content).'<br /><span class="legal">'
.__('Sent:', CBV_DOMAIN)
.CBV\tz_display('notice_sent_date', $notice['sent_date']).'</span></td>';
$rows .= '</tr>';
......@@ -168,7 +169,7 @@ function get_num_notices()
return 0;
} else {
foreach ($notices as $notice) {
if ($notice['status'] == "unread") {
if ($notice['status'] == 'unread') {
$notifications[] = $notice;
}
}
......@@ -208,7 +209,7 @@ function markNotice($notification_id = -1, $status = NOTIFICATION_STATUS_READ)
*
* @throws \Exception
*/
function send_triggered_notification($uid = 0, $trigger = "NO_TRIGGER", $args = [])
function send_triggered_notification($uid = 0, $trigger = 'NO_TRIGGER', $args = [])
{
/** @var \wpdb $wpdb */
global $wpdb;
......@@ -415,57 +416,3 @@ function current_url()
return $pageURL;
}
class Actions
{
public static function wp_ajax_update_notification_count()
{
$count = get_num_notices();
$return = ['count' => $count];
die(json_encode($return));
}
public static function wp_ajax_mark_read()
{
markNotice($_POST['index'], NOTIFICATION_STATUS_READ);
}
public static function wp_ajax_mark_unread()
{
markNotice($_POST['index'], NOTIFICATION_STATUS_UNREAD);
}
public static function wp_ajax_print_user_notices()
{
print_user_notices();
}
public static function wp_ajax_remove_attachment()
{
$id = $_POST['id'];
$email = get_post_meta($id, 'email', true);
$attachments = $email['attachments'];
foreach ($attachments as $key => $name) {
if ($name == $_POST['file']) {
unset($attachments[$key]);
}
}
$email['attachments'] = $attachments;
update_post_meta($id, 'email', $email);
$return = ['success' => 'true'];
die(json_encode($return));
}
}
class Vars
{
public static $notices;
public static $options;
public static $field_lookup = [
'allusers' => 'All Users',
'report' => 'Report'
];
}
......