*/
function notifyall_module() {}
-function notifyall_addon_admin(App $a, &$o)
+function notifyall_addon_admin(string &$o)
{
- $o = '<div></div> <a href="' . DI::baseUrl()->get() . '/notifyall">' . DI::l10n()->t('Send email to all members') . '</a></br/>';
+ $o = '<div></div> <a href="' . DI::baseUrl() . '/notifyall">' . DI::l10n()->t('Send email to all members') . '</a></br/>';
}
-function notifyall_post(App $a)
+function notifyall_post()
{
- if (!$a->isSiteAdmin()) {
+ if (!DI::userSession()->isSiteAdmin()) {
return;
}
return;
}
+ $condition = ['account_removed' => false, 'account_expired' => false];
+
// if this is a test, send it only to the admin(s)
// admin_email might be a comma separated list, but we need "a@b','c@d','e@f
if (intval($_REQUEST['test'])) {
- $email = DI::config()->get('config', 'admin_email');
- $email = "'" . str_replace([" ",","], ["","','"], $email) . "'";
+ $adminEmails = \Friendica\Model\User::getAdminListForEmailing(['email']);
+
+ $condition['email'] = array_column($adminEmails, 'email');
}
- $sql_extra = ((intval($_REQUEST['test'])) ? sprintf(" AND `email` in ( %s )", $email) : '');
- $recipients = DBA::p("SELECT DISTINCT `email` FROM `user` WHERE `verified` AND NOT `account_removed` AND NOT `account_expired` $sql_extra");
+ $recipients = DBA::p("SELECT DISTINCT `email` FROM `user`" . DBA::buildCondition($condition), $condition);
if (! $recipients) {
- notice(DI::l10n()->t('No recipients found.') . EOL);
+ DI::sysmsg()->addNotice(DI::l10n()->t('No recipients found.'));
return;
}
DI::emailer()->send($notifyEmail->withRecipient($recipient['email']));
}
- info(DI::l10n()->t('Emails sent'));
+ DI::sysmsg()->addInfo(DI::l10n()->t('Emails sent'));
DI::baseUrl()->redirect('admin');
}
-function notifyall_content(App $a)
+function notifyall_content()
{
- if (!$a->isSiteAdmin()) {
+ if (!DI::userSession()->isSiteAdmin()) {
return '';
}