Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
a1a85c5a
authored
2015-02-09 13:54:17 -0500
by
Marty Penner
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Move a few classes to a proper PSR4 directory
1 parent
d17b9051
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
105 deletions
com/Notifications/Admin.php
com/Notifications/Notifications.php
com/Notifications/Admin.php
View file @
a1a85c5
...
...
@@ -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
;
}
...
...
com/Notifications/Notifications.php
View file @
a1a85c5
...
...
@@ -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
(
'_'
,
' '
,
$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'
];
}
...
...
Please
register
or
sign in
to post a comment