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
37b90785
authored
2011-04-11 20:23:51 +0000
by
Kevin Burton
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
updated Notification to use daemon system for email notifications under system triggered.
1 parent
a7dd9328
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
1 deletions
com/Notifications/Notifications.php
com/Notifications/Notifications.php
View file @
37b9078
...
...
@@ -188,6 +188,7 @@ function remove_notice($notification_id = -1) {
@trigger = notification unique slug name
*/
function
send_triggered_notification
(
$uid
,
$trigger
=
"NO_TRIGGER"
,
$args
=
array
(),
$send_override
=
false
)
{
global
$wpdb
;
$notification
=
get_notification_by_trigger
(
$trigger
);
if
(
$notification
)
{
...
...
@@ -229,7 +230,51 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(),
// if is_email ===========================================
if
(
$notification
->
is_email
)
{
send_email
(
$uid
,
$email
,
$args
,
true
);
$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
)
.
"_"
;
$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
);
}
else
{
$html
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$html
);
$alttext
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$alttext
);
$subject
=
str_replace
(
"
{
".$key."
}
"
,
$val
,
$subject
);
}
}
$attachments
=
array
();
if
(
isset
(
$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,'')"
);
//send_email($uid,$email,$args, true);
}
}
// if the system notification has set current user than get current user otherwise loop through the users needed.
...
...
Please
register
or
sign in
to post a comment