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
6d59626b
authored
2012-07-03 15:07:14 -0400
by
Marty Penner
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Apply basic auto code formatting to the main Notifications file
1 parent
b40ead7d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
236 additions
and
227 deletions
com/Notifications/Notifications.php
com/Notifications/Notifications.php
View file @
6d59626
...
...
@@ -9,159 +9,157 @@ use Tz\WordPress\CBV\User;
use
WP_User
;
use
Exception
,
StdClass
;
const
OPTION_NAME
=
"notif_options"
;
call_user_func
(
function
()
{
Tools\add_actions
(
__NAMESPACE__
.
'\Actions'
);
call_user_func
(
function
()
{
Tools\add_actions
(
__NAMESPACE__
.
'\Actions'
);
Vars
::
$options
=
new
Tools\WP_Option
(
OPTION_NAME
);
Vars
::
$notices
=
Array
();
Vars
::
$notices
=
Array
();
if
(
is_admin
())
{
require_once
(
__DIR__
.
DIRECTORY_SEPARATOR
.
'Validation.php'
);
require_once
(
__DIR__
.
DIRECTORY_SEPARATOR
.
'Admin.php'
);
require_once
(
__DIR__
.
DIRECTORY_SEPARATOR
.
'Validation.php'
);
require_once
(
__DIR__
.
DIRECTORY_SEPARATOR
.
'Admin.php'
);
}
});
function
subval_sort
(
$a
,
$subkey
,
$sort
)
{
foreach
(
$a
as
$k
=>
$v
)
{
$b
[
$k
]
=
strtolower
(
$v
[
$subkey
]);
}
$sort
(
$b
);
foreach
(
$b
as
$key
=>
$val
)
{
$c
[]
=
$a
[
$key
];
}
return
$c
;
function
subval_sort
(
$a
,
$subkey
,
$sort
)
{
foreach
(
$a
as
$k
=>
$v
)
{
$b
[
$k
]
=
strtolower
(
$v
[
$subkey
]);
}
$sort
(
$b
);
foreach
(
$b
as
$key
=>
$val
)
{
$c
[]
=
$a
[
$key
];
}
return
$c
;
}
function
get_user_notices
(
$uid
)
{
$notices
=
get_user_meta
(
$uid
,
'notices'
,
true
);
if
(
!
empty
(
$notices
))
{
$notices
=
subval_sort
(
$notices
,
'sent_date'
,
'arsort'
);
function
get_user_notices
(
$uid
)
{
$notices
=
get_user_meta
(
$uid
,
'notices'
,
true
);
if
(
!
empty
(
$notices
))
{
$notices
=
subval_sort
(
$notices
,
'sent_date'
,
'arsort'
);
Vars
::
$notices
=
$notices
;
}
}
function
print_user_notices
(
$show_more
=
true
)
{
function
print_user_notices
(
$show_more
=
true
)
{
$user
=
new
User\CurrentAccount
();
get_user_notices
(
$user
->
ID
);
if
(
CBV\on_page
(
'/dashboard'
))
{
$limit
=
5
;
$limit
=
5
;
}
else
{
$limit
=
10
;
$limit
=
10
;
}
$notices
=
Vars
::
$notices
;
$total_rows
=
count
(
$notices
);
$next_id
=
isset
(
$_POST
[
'last_id'
])
?
(
$_POST
[
'last_id'
]
+
1
)
:
0
;
$end
=
((
$next_id
+
$limit
)
<
$total_rows
)
?
(
$next_id
+
$limit
)
:
$total_rows
;
$notices
=
Vars
::
$notices
;
$total_rows
=
count
(
$notices
);
$next_id
=
isset
(
$_POST
[
'last_id'
])
?
(
$_POST
[
'last_id'
]
+
1
)
:
0
;
$end
=
((
$next_id
+
$limit
)
<
$total_rows
)
?
(
$next_id
+
$limit
)
:
$total_rows
;
if
(
count
(
$notices
)
<
1
)
{
//print '<tr><td colspan="3">You have no new notices.</td></tr>';
}
$rows
=
""
;
$last_id
=
0
;
for
(
$i
=
0
;
$i
<
$total_rows
;
$i
++
)
{
$rows
=
""
;
$last_id
=
0
;
for
(
$i
=
0
;
$i
<
$total_rows
;
$i
++
)
{
$the_notice
=
get_post
(
$notices
[
$i
][
'notification_id'
]);
$system
=
get_post_meta
(
$notices
[
$i
][
'notification_id'
],
'system'
,
true
);
$system
=
get_post_meta
(
$notices
[
$i
][
'notification_id'
],
'system'
,
true
);
$content
=
$system
[
'message'
];
$id
=
$the_notice
->
ID
;
$id
=
$the_notice
->
ID
;
if
(
isset
(
$notices
[
$i
][
'args'
])
&&
count
(
$notices
[
$i
][
'args'
])
>
0
)
:
foreach
(
$notices
[
$i
][
'args'
]
as
$key
=>
$val
)
{
if
(
filter_var
(
$val
,
FILTER_VALIDATE_URL
)
!==
false
)
{
$content
=
str_replace
(
"
{
".$key."
}
"
,
"<a href='"
.
$val
.
"'>Click here</a>"
,
$content
);
}
else
{
$content
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$content
);
foreach
(
$notices
[
$i
][
'args'
]
as
$key
=>
$val
)
{
if
(
filter_var
(
$val
,
FILTER_VALIDATE_URL
)
!==
false
)
{
$content
=
str_replace
(
"
{
".$key."
}
"
,
"<a href='"
.
$val
.
"'>Click here</a>"
,
$content
);
}
else
{
$content
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$content
);
}
}
endif
;
$rows
.=
'<tr class="notice-row" id="'
.
$i
.
'">'
;
if
(
$notices
[
$i
][
'status'
]
==
"unread"
)
{
$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>'
;
}
else
{
$rows
.=
'<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><img src="assets/images/blank.gif" width="12" height="12" /></td>'
;
}
endif
;
$rows
.=
'<tr class="notice-row" id="'
.
$i
.
'">'
;
if
(
$notices
[
$i
][
'status'
]
==
"unread"
)
{
$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>'
;
}
else
{
$rows
.=
'<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><img src="assets/images/blank.gif" width="12" height="12" /></td>'
;
}
/*
if($system['system_message_type']=="none"):
$rows .= '<td colspan="2" style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date("M j, Y @ h:ia",$notices[$i]['sent_date']).'</span></td>';
else:
*/
if
(
$system
[
'system_message_type'
]
==
"none"
)
{
$system
[
'system_message_type'
]
=
"notice"
;
}
$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">Sent: '
.
date
(
"M j, Y @ h:ia"
,
$notices
[
$i
][
'sent_date'
])
.
'</span></td>'
;
/*endif;*/
$rows
.=
'</tr>'
;
/*
if($system['system_message_type']=="none"):
$rows .= '<td colspan="2" style="vertical-align:middle;">'.nl2br($content).'<br /><span class="legal">Sent: '.date("M j, Y @ h:ia",$notices[$i]['sent_date']).'</span></td>';
else:
*/
if
(
$system
[
'system_message_type'
]
==
"none"
)
{
$system
[
'system_message_type'
]
=
"notice"
;
}
$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">Sent: '
.
date
(
"M j, Y @ h:ia"
,
$notices
[
$i
][
'sent_date'
])
.
'</span></td>'
;
/*endif;*/
$rows
.=
'</tr>'
;
$last_id
=
$i
;
}
if
(
$end
<
$total_rows
&&
CBV\on_page
(
'/notices'
))
{
//$rows .= '<tr id="TzMoreRows"><td colspan="4"><a onclick="return false;" class="load_more_notices" id="'.$last_id.'" href="#">Show more...</a></td></tr>';
}
if
(
isset
(
$_POST
[
'ajax'
]))
{
if
(
isset
(
$_POST
[
'ajax'
]))
{
die
(
$rows
);
}
else
{
print
$rows
;
}
}
}
function
get_notification_by_trigger
(
$trigger
)
{
function
get_notification_by_trigger
(
$trigger
)
{
$args
=
array
(
'post_type'
=>
'notifications'
,
'numberposts'
=>
-
1
,
'orderby'
=>
'modified'
,
'order'
=>
'desc'
'post_type'
=>
'notifications'
,
'numberposts'
=>
-
1
,
'orderby'
=>
'modified'
,
'order'
=>
'desc'
);
$my_notif
=
false
;
foreach
(
get_posts
(
$args
)
as
$entry
)
{
$details
=
get_post_meta
(
$entry
->
ID
,
'details'
,
true
);
if
(
$details
[
'type'
]
==
"triggered"
&&
$details
[
'trigger'
]
==
$trigger
)
{
foreach
(
get_posts
(
$args
)
as
$entry
)
{
$details
=
get_post_meta
(
$entry
->
ID
,
'details'
,
true
);
if
(
$details
[
'type'
]
==
"triggered"
&&
$details
[
'trigger'
]
==
$trigger
)
{
$my_notif
=
$entry
;
break
;
}
}
return
$my_notif
;
return
$my_notif
;
}
/**
* GET NUMBER OF NEW NOTICES
@returns (Int)
*/
function
get_num_notices
()
{
@returns (Int)
*/
function
get_num_notices
()
{
// get number of notices for this user that are new...
$user
=
new
User\CurrentAccount
();
get_user_notices
(
$user
->
ID
);
$notices
=
Vars
::
$notices
;
$notices
=
Vars
::
$notices
;
$notifications
=
array
();
// return $num;
if
(
empty
(
$notices
))
{
return
0
;
if
(
empty
(
$notices
))
{
return
0
;
}
else
{
foreach
(
$notices
as
$notice
)
{
if
(
$notice
[
'status'
]
==
"unread"
)
{
foreach
(
$notices
as
$notice
)
{
if
(
$notice
[
'status'
]
==
"unread"
)
{
$notifications
[]
=
$notice
;
}
}
...
...
@@ -169,41 +167,43 @@ function get_num_notices() {
return
count
(
$notifications
);
}
function
remove_notice
(
$notification_id
=
-
1
)
{
function
remove_notice
(
$notification_id
=
-
1
)
{
get_user_notices
(
Tools\getCurrentUser
()
->
ID
);
$notices
=
Vars
::
$notices
;
if
(
!
empty
(
$notices
))
{
foreach
(
$notices
as
$id
=>
$notice
)
{
if
(
$id
==
$notification_id
)
{
$notices
[
$id
][
'status'
]
=
"read"
;
foreach
(
$notices
as
$id
=>
$notice
)
{
if
(
$id
==
$notification_id
)
{
$notices
[
$id
][
'status'
]
=
"read"
;
break
;
}
}
}
update_user_meta
(
Tools\getCurrentUser
()
->
ID
,
'notices'
,
$notices
);
update_user_meta
(
Tools\getCurrentUser
()
->
ID
,
'notices'
,
$notices
);
}
/**
Send Notifications
@trigger = notification unique slug name
*/
function
send_triggered_notification
(
$uid
=
0
,
$trigger
=
"NO_TRIGGER"
,
$args
=
array
(),
$send_override
=
false
)
{
Send Notifications
@trigger = notification unique slug name
*/
function
send_triggered_notification
(
$uid
=
0
,
$trigger
=
"NO_TRIGGER"
,
$args
=
array
(),
$send_override
=
false
)
{
global
$wpdb
;
$notification
=
get_notification_by_trigger
(
$trigger
);
if
(
$notification
)
{
if
(
$notification
)
{
// get the notification and notificatio details....
$nid
=
$notification
->
ID
;
$details
=
get_post_meta
(
$nid
,
'details'
,
true
);
$email
=
get_post_meta
(
$nid
,
'email'
,
true
);
$system
=
get_post_meta
(
$nid
,
'system'
,
true
);
$notification
->
trigger
=
$details
[
'trigger'
];
$notification
->
status
=
isset
(
$details
[
'status'
])
?
$details
[
'status'
]
:
"active"
;
$notification
->
type
=
$details
[
'type'
];
$notification
->
sendto
=
$details
[
'sendto'
];
$notification
->
is_email
=
((
$email
[
'text'
]
!=
""
||
$email
[
'html'
]
!=
""
)
&&
$email
[
'subject'
]
!=
""
)
?
true
:
false
;
$notification
->
is_system
=
(
isset
(
$system
[
'message'
])
&&
$system
[
'message'
]
!=
""
)
?
true
:
false
;
$nid
=
$notification
->
ID
;
$details
=
get_post_meta
(
$nid
,
'details'
,
true
);
$email
=
get_post_meta
(
$nid
,
'email'
,
true
);
$system
=
get_post_meta
(
$nid
,
'system'
,
true
);
$notification
->
trigger
=
$details
[
'trigger'
];
$notification
->
status
=
isset
(
$details
[
'status'
])
?
$details
[
'status'
]
:
"active"
;
$notification
->
type
=
$details
[
'type'
];
$notification
->
sendto
=
$details
[
'sendto'
];
$notification
->
is_email
=
((
$email
[
'text'
]
!=
""
||
$email
[
'html'
]
!=
""
)
&&
$email
[
'subject'
]
!=
""
)
?
true
:
false
;
$notification
->
is_system
=
(
isset
(
$system
[
'message'
])
&&
$system
[
'message'
]
!=
""
)
?
true
:
false
;
// if is_system ==========================================
if
(
$notification
->
is_system
&&
$uid
!=
0
)
{
...
...
@@ -211,128 +211,128 @@ function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = arra
$notices
=
Vars
::
$notices
;
$insert
=
array
(
'notification_id'
=>
$nid
,
'status'
=>
'unread'
,
'sent_date'
=>
current_time
(
'timestamp'
)
,
'args'
=>
$args
'notification_id'
=>
$nid
,
'status'
=>
'unread'
,
'sent_date'
=>
current_time
(
'timestamp'
),
'args'
=>
$args
);
if
(
empty
(
$notices
))
{
if
(
empty
(
$notices
))
{
$notices
=
array
();
}
$sequence
=
Sequencer\generate
(
'NTC'
);
$notices
[
$sequence
]
=
$insert
;
update_user_meta
(
$uid
,
'notices'
,
$notices
);
$notices
[
$sequence
]
=
$insert
;
update_user_meta
(
$uid
,
'notices'
,
$notices
);
}
// if is_email ===========================================
if
(
$notification
->
is_email
)
{
if
(
$uid
==
0
&&
!
isset
(
$args
[
'email'
]))
{
return
;
}
elseif
(
$uid
==
0
&&
isset
(
$args
[
'email'
])
)
{
}
elseif
(
$uid
==
0
&&
isset
(
$args
[
'email'
])
)
{
$to_email
=
$args
[
'email'
];
}
else
{
$user
=
new
User\Account
(
$uid
);
$user
=
new
User\Account
(
$uid
);
$email_address_preference
=
get_user_meta
(
$user
->
ID
,
'email_address_preference'
,
true
);
if
(
empty
(
$email_address_preference
))
{
$to_email
=
$user
->
user_email
;
}
else
{
$pp
=
strtolower
(
$email_address_preference
)
.
"_"
;
$pp
=
strtolower
(
$email_address_preference
)
.
"_"
;
$to_email
=
get_user_meta
(
$user
->
ID
,
$pp
.
'email'
,
true
);
if
(
empty
(
$to_email
))
{
$to_email
=
$user
->
user_email
;
}
}
}
}
$contents
=
$email
;
$from_email
=
get_bloginfo
(
'admin_email'
);
$subject
=
strip_tags
(
$contents
[
'subject'
]);
$html
=
$contents
[
'html'
];
$alttext
=
strip_tags
(
$contents
[
'text'
]);
foreach
(
$args
as
$key
=>
$val
)
{
if
(
(
filter_var
(
$val
,
FILTER_VALIDATE_URL
)
!==
false
)
&&
!
empty
(
$html
))
{
$html
=
str_replace
(
"
{
".$key."
}
"
,
"<a href='"
.
$val
.
"'>"
.
$val
.
"</a>"
,
$html
);
$contents
=
$email
;
$from_email
=
get_bloginfo
(
'admin_email'
);
$subject
=
strip_tags
(
$contents
[
'subject'
]);
$html
=
$contents
[
'html'
];
$alttext
=
strip_tags
(
$contents
[
'text'
]);
foreach
(
$args
as
$key
=>
$val
)
{
if
((
filter_var
(
$val
,
FILTER_VALIDATE_URL
)
!==
false
)
&&
!
empty
(
$html
))
{
$html
=
str_replace
(
"
{
".$key."
}
"
,
"<a href='"
.
$val
.
"'>"
.
$val
.
"</a>"
,
$html
);
}
else
{
$html
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$html
);
$html
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$html
);
$alttext
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$alttext
);
$subject
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$subject
);
}
}
$attachments
=
array
();
$attachments
=
array
();
if
(
isset
(
$contents
[
'attachments'
]))
{
$attachments
=
$contents
[
'attachments'
];
$attachments
=
$contents
[
'attachments'
];
}
$att1
=
isset
(
$attachments
[
0
])
?
$attachments
[
0
]
:
''
;
$att2
=
isset
(
$attachments
[
1
])
?
$attachments
[
1
]
:
''
;
$att3
=
isset
(
$attachments
[
2
])
?
$attachments
[
2
]
:
''
;
$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,'')"
);
$att1
=
isset
(
$attachments
[
0
])
?
$attachments
[
0
]
:
''
;
$att2
=
isset
(
$attachments
[
1
])
?
$attachments
[
1
]
:
''
;
$att3
=
isset
(
$attachments
[
2
])
?
$attachments
[
2
]
:
''
;
$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,'')"
);
//send_email($uid,$email,$args, true);
}
}
}
}
// if the system notification has set current user than get current user otherwise loop through the users needed.
}
function
send_email
(
$uid
=
0
,
$contents
,
$args
,
$override
=
false
)
{
if
(
$uid
==
0
&&
!
isset
(
$args
[
'email'
]))
{
return
;
}
function
send_email
(
$uid
=
0
,
$contents
,
$args
,
$override
=
false
)
{
if
(
$uid
==
0
&&
!
isset
(
$args
[
'email'
]))
{
return
;
}
if
(
isset
(
$args
[
'email'
]))
{
if
(
isset
(
$args
[
'email'
]))
{
$to_email
=
$args
[
'email'
];
}
else
{
$user
=
new
WP_User
(
$uid
);
$user
=
new
WP_User
(
$uid
);
$email_address_preference
=
get_user_meta
(
$user
->
ID
,
'email_address_preference'
,
true
);
if
(
empty
(
$email_address_preference
))
{
$to_email
=
$user
->
user_email
;
}
else
{
$pp
=
strtolower
(
$email_address_preference
)
.
"_"
;
$pp
=
strtolower
(
$email_address_preference
)
.
"_"
;
$to_email
=
get_user_meta
(
$user
->
ID
,
$pp
.
'email'
,
true
);
if
(
empty
(
$to_email
))
{
$to_email
=
$user
->
user_email
;
}
}
}
}
$from_address
=
get_bloginfo
(
'admin_email'
);
$from_address
=
get_bloginfo
(
'admin_email'
);
$subject
=
strip_tags
(
$contents
[
'subject'
]);
$html
=
$contents
[
'html'
];
$alttext
=
$contents
[
'text'
];
$headers
=
""
;
$headers
=
""
;
if
(
empty
(
$html
))
{
$message
=
$alttext
;
$message
=
strip_tags
(
$message
);
// it's text based only... no need to check format preference.
}
else
{
$message
=
$html
;
$headers
.=
'MIME-Version: 1.0'
.
"
\r\n
"
;
$headers
.=
'Content-type: text/html; charset=iso-8859-1'
.
"
\r\n
"
;
$headers
.=
'MIME-Version: 1.0'
.
"
\r\n
"
;
$headers
.=
'Content-type: text/html; charset=iso-8859-1'
.
"
\r\n
"
;
// it's HTML formatted.
// Check user preference if they want Text ONly??
}
foreach
(
$args
as
$key
=>
$val
)
{
if
(
(
filter_var
(
$val
,
FILTER_VALIDATE_URL
)
!==
false
)
&&
!
empty
(
$html
))
{
$message
=
str_replace
(
"
{
".$key."
}
"
,
"<a href='"
.
$val
.
"'>"
.
$val
.
"</a>"
,
$message
);
foreach
(
$args
as
$key
=>
$val
)
{
if
((
filter_var
(
$val
,
FILTER_VALIDATE_URL
)
!==
false
)
&&
!
empty
(
$html
))
{
$message
=
str_replace
(
"
{
".$key."
}
"
,
"<a href='"
.
$val
.
"'>"
.
$val
.
"</a>"
,
$message
);
}
else
{
$message
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$message
);
$subject
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$subject
);
...
...
@@ -341,92 +341,101 @@ function send_email($uid = 0, $contents,$args, $override = false) {
// Additional headers
//$headers .= 'To: '.$to_email.' <'.$to_email.'>' . "\r\n";
$headers
.=
'From: CICBV <'
.
$from_address
.
'>'
.
"
\r\n
"
;
$headers
.=
'From: CICBV <'
.
$from_address
.
'>'
.
"
\r\n
"
;
//die("To: $to_email, Subject: $subject, Message: $message, Header: $headers");
mail
(
$to_email
,
$subject
,
$message
,
$headers
);
}
function
getGroups
(
$grpID
=
0
)
{
function
getGroups
(
$grpID
=
0
)
{
global
$userAccessManager
;
$groups
=
array
();
if
(
$grpID
>
0
)
{
$userGroups
=
$userAccessManager
->
getAccessHandler
()
->
getUserGroups
(
$grpID
);
return
$userGroups
->
getGroupName
();
if
(
$grpID
>
0
)
{
$userGroups
=
$userAccessManager
->
getAccessHandler
()
->
getUserGroups
(
$grpID
);
return
$userGroups
->
getGroupName
();
}
else
{
$userGroups
=
$userAccessManager
->
getAccessHandler
()
->
getUserGroups
();
$userGroups
=
$userAccessManager
->
getAccessHandler
()
->
getUserGroups
();
}
foreach
(
$userGroups
as
$group
)
{
foreach
(
$userGroups
as
$group
)
{
$groups
[
$group
->
getId
()]
=
$group
->
getGroupName
();
}
return
$groups
;
}
function
get_field_lookup
(
$var
)
{
function
get_field_lookup
(
$var
)
{
return
isset
(
Vars
::
$field_lookup
[
$var
])
?
Vars
::
$field_lookup
[
$var
]
:
$var
;
}
function
current_url
()
{
function
current_url
()
{
$pageURL
=
'http'
;
if
(
$_SERVER
[
"HTTPS"
]
==
"on"
)
{
$pageURL
.=
"s"
;}
if
(
$_SERVER
[
"HTTPS"
]
==
"on"
)
{
$pageURL
.=
"s"
;
}
$pageURL
.=
"://"
;
if
(
$_SERVER
[
"SERVER_PORT"
]
!=
"80"
)
{
$pageURL
.=
$_SERVER
[
"SERVER_NAME"
]
.
":"
.
$_SERVER
[
"SERVER_PORT"
]
.
$_SERVER
[
"REQUEST_URI"
];
$pageURL
.=
$_SERVER
[
"SERVER_NAME"
]
.
":"
.
$_SERVER
[
"SERVER_PORT"
]
.
$_SERVER
[
"REQUEST_URI"
];
}
else
{
$pageURL
.=
$_SERVER
[
"SERVER_NAME"
]
.
$_SERVER
[
"REQUEST_URI"
];
$pageURL
.=
$_SERVER
[
"SERVER_NAME"
]
.
$_SERVER
[
"REQUEST_URI"
];
}
return
$pageURL
;
}
class
Actions
{
public
static
function
wp_ajax_update_notification_count
()
{
$count
=
get_num_notices
();
$return
=
array
(
'count'
=>
$count
);
class
Actions
{
public
static
function
wp_ajax_update_notification_count
()
{
$count
=
get_num_notices
();
$return
=
array
(
'count'
=>
$count
);
die
(
json_encode
(
$return
));
}
public
static
function
wp_ajax_mark_read
()
{
public
static
function
wp_ajax_mark_read
()
{
remove_notice
(
$_POST
[
'index'
]);
}
public
static
function
wp_ajax_print_user_notices
()
{
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
);
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'
])
{
foreach
(
$attachments
as
$key
=>
$name
)
{
if
(
$name
==
$_POST
[
'file'
])
{
unset
(
$attachments
[
$key
]);
}
}
$email
[
'attachments'
]
=
$attachments
;
update_post_meta
(
$id
,
'email'
,
$email
);
$return
=
array
(
'success'
=>
'true'
);
die
(
json_encode
(
$return
));
}
}
class
Vars
{
class
Vars
{
public
static
$notices
;
public
static
$options
;
public
static
$field_lookup
=
array
(
'allusers'
=>
"All Users"
,
'report'
=>
"Report"
'allusers'
=>
"All Users"
,
'report'
=>
"Report"
);
}
?>
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment