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
3429a884
authored
2018-02-13 10:27:11 -0500
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
admin notifications
1 parent
b91a8ab1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
1 deletions
com/Notifications/Notifications.php
com/Notifications/Notifications.php
View file @
3429a88
...
...
@@ -23,7 +23,7 @@ call_user_func(
}
}
);
/**
* @param $a
* @param $subkey
...
...
@@ -515,6 +515,95 @@ function send_triggered_notification($uid = 0, $trigger = 'NO_TRIGGER', $args =
}
}
function
send_admin_triggered_notification
(
$toEmail
,
$trigger
=
'NO_TRIGGER'
,
$args
=
[])
{
$lang
=
'en'
;
/** @var \StdClass $notification */
$notification
=
get_notification_by_trigger
(
$trigger
);
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
[
$lang
.
'_text'
]
!=
''
||
$email
[
$lang
.
'_html'
]
!=
''
)
&&
$email
[
$lang
.
'_subject'
]
!=
''
);
$notification
->
is_system
=
(
isset
(
$system
[
$lang
.
'_message'
])
&&
$system
[
$lang
.
'_message'
]
!=
''
);
// if is_system ==========================================
if
(
$notification
->
is_system
&&
$uid
!=
0
)
{
get_user_notices
(
$uid
);
$notices
=
Vars
::
$notices
;
// Add a system message into the usermeta as well to track the system notification.
$insert
=
[
'notification_id'
=>
$nid
,
'status'
=>
'unread'
,
'sent_date'
=>
current_time
(
'timestamp'
),
'message'
=>
$system
[
$lang
.
'_message'
],
'args'
=>
$args
];
}
}
$contents
=
$email
;
$fromEmail
=
get_bloginfo
(
'admin_email'
);
$subject
=
strip_tags
(
isset
(
$contents
[
$lang
.
'_subject'
])
&&
!
empty
(
$contents
[
$lang
.
'_subject'
])
?
$contents
[
$lang
.
'_subject'
]
:
$contents
[
'en_subject'
]
);
$html
=
isset
(
$contents
[
$lang
.
'_html'
])
&&
!
empty
(
$contents
[
$lang
.
'_html'
])
?
$contents
[
$lang
.
'_html'
]
:
@
$contents
[
'en_html'
];
$altText
=
strip_tags
(
isset
(
$contents
[
$lang
.
'_text'
])
&&
!
empty
(
$contents
[
$lang
.
'_text'
])
?
$contents
[
$lang
.
'_text'
]
:
$contents
[
'en_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
);
}
}
$sentSuccessfully
=
false
;
if
(
CBV\system_can_send_emails_using_wpdb
())
{
$response
=
\wpMandrill
::
mail
(
$toEmail
,
$subject
,
!
empty
(
$html
)
?
$html
:
$altText
,
[],
$attachments
);
if
(
is_array
(
$response
)
&&
isset
(
$response
[
0
][
'status'
])
&&
isset
(
$response
[
0
][
'status'
])
&&
!
in_array
(
$response
[
'status'
],
[
'rejected'
,
'invalid'
])
)
{
$sentSuccessfully
=
true
;
}
}
}
/**
* @param int $grpID
*
...
...
Please
register
or
sign in
to post a comment