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
4d94d9dc
authored
2010-11-10 20:35:39 +0000
by
Kevin Burton
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update to notifications
1 parent
4cd50c72
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
6 deletions
com/Notifications/Notifications.php
com/Notifications/Notifications.php
View file @
4d94d9d
<?php
namespace
Tz\WordPress\Tools\Notifications
;
use
Tz\WordPress\Tools
;
use
Tz\Common
;
use
Tz\WordPress\Tools
;
use
WP_User
;
use
Exception
,
StdClass
;
const
OPTION_NAME
=
"notif_options"
;
...
...
@@ -77,15 +79,15 @@ function remove_notice($notification_id = -1) {
Send Notifications
@trigger = notification unique slug name
*/
function
send_triggered_notification
(
$uid
,
$trigger
=
"NO_TRIGGER"
,
$args
=
array
())
{
function
send_triggered_notification
(
$uid
,
$trigger
=
"NO_TRIGGER"
,
$args
=
array
()
,
$send_override
=
false
)
{
$notification
=
get_notification_by_trigger
(
$trigger
);
if
(
$notification
)
{
// get the user and user details....
$user
=
Tools\getCurrentUser
();
$user
=
new
WP_User
(
$uid
);
//
Tools\getCurrentUser();
$notify_me
=
get_user_meta
(
$user
->
ID
,
'notify_me'
,
true
);
$notify_format
=
get_user_meta
(
$user
->
ID
,
'notify_format'
,
true
);
$email
=
get_user_meta
(
$user
->
ID
,
'email_address_preference'
,
true
);
$email
_preference
=
get_user_meta
(
$user
->
ID
,
'email_address_preference'
,
true
);
$cell
=
get_user_meta
(
$user
->
ID
,
'home_mobile'
,
true
);
// get the notification and notificatio details....
...
...
@@ -101,7 +103,7 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array())
$notification
->
type
=
$details
[
'type'
];
$notification
->
sendto
=
$details
[
'sendto'
];
$notification
->
is_email
=
((
$email
[
'text'
]
!=
""
||
$email
[
'html'
]
!=
""
))
?
true
:
false
;
$notification
->
is_email
=
((
$email
[
'text'
]
!=
""
||
$email
[
'html'
]
!=
""
)
&&
$email
[
'subject'
]
!=
""
)
?
true
:
false
;
$notification
->
is_system
=
(
isset
(
$system
[
'message'
])
&&
$system
[
'message'
]
!=
""
)
?
true
:
false
;
$notification
->
is_sms
=
(
isset
(
$sms
[
'message'
])
&&
$sms
[
'message'
]
!=
""
)
?
true
:
false
;
...
...
@@ -132,7 +134,8 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array())
// if is_email ===========================================
if
(
$notification
->
is_email
&&
$notify_me
)
{
if
(
$notification
->
is_email
&&
(
$notify_me
||
$send_override
))
{
send_email
(
$user
->
ID
,
$email
,
$args
,
$send_override
);
}
...
...
@@ -144,6 +147,48 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array())
// if the system notification has set current user than get current user otherwise loop through the users needed.
}
function
send_email
(
$uid
,
$contents
,
$args
)
{
$from_address
=
get_bloginfo
(
'admin_email'
);
$user
=
new
WP_User
(
$uid
);
$to_email
=
$user
->
user_email
;
$subject
=
$contents
[
'subject'
];
$html
=
$contents
[
'html'
];
$alttext
=
$contents
[
'text'
];
$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
"
;
// 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
);
}
else
{
$message
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$message
);
}
}
// Additional headers
//$headers .= 'To: '.$to_email.' <'.$to_email.'>' . "\r\n";
$headers
.=
'From: CICBV <'
.
$from_address
.
'>'
.
"
\r\n
"
;
mail
(
$to_email
,
$subject
,
$message
,
$headers
);
}
function
getGroups
(
$grpID
=
0
)
{
global
$userAccessManager
;
...
...
Please
register
or
sign in
to post a comment