From 185e315bd074dd2f0c743974b8d8cfc3bd873d27 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 13 May 2018 14:22:45 +0200 Subject: [PATCH 1/7] enclose senders name in quotation marks --- notifyall/notifyall.php | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/notifyall/notifyall.php b/notifyall/notifyall.php index 5ea0db38..6c65c5c6 100644 --- a/notifyall/notifyall.php +++ b/notifyall/notifyall.php @@ -12,41 +12,53 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\L10n; use Friendica\Util\Emailer; -function notifyall_install() { +function notifyall_install() +{ logger("installed notifyall"); } -function notifyall_uninstall() { +function notifyall_uninstall() +{ logger("removed notifyall"); } function notifyall_module() {} -function notifyall_addon_admin(&$a, &$o) { - +function notifyall_addon_admin(&$a, &$o) +{ $o = '
    ' . L10n::t('Send email to all members') . '
'; } -function notifyall_post(&$a) { +function notifyall_post(&$a) +{ if(! is_site_admin()) + { return; + } $text = trim($_REQUEST['text']); + if(! $text) + { return; + } $sitename = $a->config['sitename']; if (!x($a->config['admin_name'])) - $sender_name = L10n::t('%s Administrator', $sitename); - else - $sender_name = L10n::t('%1$s, %2$s Administrator', $a->config['admin_name'], $sitename); + { + $sender_name = '"' . L10n::t('%s Administrator', $sitename) . '"'; + } else { + $sender_name = '"' . L10n::t('%1$s, %2$s Administrator', $a->config['admin_name'], $sitename) . '"'; + } if (! x($a->config['sender_email'])) + { $sender_email = 'noreply@' . $a->get_hostname(); - else + } else { $sender_email = $a->config['sender_email']; + } $subject = $_REQUEST['subject']; @@ -57,7 +69,8 @@ function notifyall_post(&$a) { // 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'])) { + if (intval($_REQUEST['test'])) + { $email = $a->config['admin_email']; $email = "'" . str_replace([" ",","], ["","','"], $email) . "'"; } @@ -65,12 +78,14 @@ function notifyall_post(&$a) { $recips = q("SELECT DISTINCT `email` FROM `user` WHERE `verified` AND NOT `account_removed` AND NOT `account_expired` $sql_extra"); - if (! $recips) { + if (! $recips) + { notice(L10n::t('No recipients found.') . EOL); return; } - foreach ($recips as $recip) { + foreach ($recips as $recip) + { Emailer::send([ 'fromName' => $sender_name, 'fromEmail' => $sender_email, From d1bf9bd4b7f0f18dfc6cae19859cf2ebe6c3073f Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 13 May 2018 17:14:13 +0200 Subject: [PATCH 2/7] noX --- notifyall/notifyall.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifyall/notifyall.php b/notifyall/notifyall.php index 6c65c5c6..a8b22a67 100644 --- a/notifyall/notifyall.php +++ b/notifyall/notifyall.php @@ -46,7 +46,7 @@ function notifyall_post(&$a) $sitename = $a->config['sitename']; - if (!x($a->config['admin_name'])) + if (empty($a->config['admin_name'])) { $sender_name = '"' . L10n::t('%s Administrator', $sitename) . '"'; } else { From 82ff2c2dd2f74ea72f00b013bb9bb41109d8e6c7 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 13 May 2018 17:16:06 +0200 Subject: [PATCH 3/7] more free Apps for the world --- notifyall/notifyall.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/notifyall/notifyall.php b/notifyall/notifyall.php index a8b22a67..8596328e 100644 --- a/notifyall/notifyall.php +++ b/notifyall/notifyall.php @@ -11,6 +11,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\L10n; use Friendica\Util\Emailer; +use Friendica\App; function notifyall_install() { @@ -24,13 +25,13 @@ function notifyall_uninstall() function notifyall_module() {} -function notifyall_addon_admin(&$a, &$o) +function notifyall_addon_admin(App &$a, &$o) { $o = '
    ' . L10n::t('Send email to all members') . '
'; } -function notifyall_post(&$a) +function notifyall_post(App &$a) { if(! is_site_admin()) { From 8401cfb6f9cd33502d2785ecfc0728a2d6fe4a0b Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 13 May 2018 17:17:40 +0200 Subject: [PATCH 4/7] less & --- notifyall/notifyall.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notifyall/notifyall.php b/notifyall/notifyall.php index 8596328e..10162c50 100644 --- a/notifyall/notifyall.php +++ b/notifyall/notifyall.php @@ -25,13 +25,13 @@ function notifyall_uninstall() function notifyall_module() {} -function notifyall_addon_admin(App &$a, &$o) +function notifyall_addon_admin(App $a, &$o) { $o = '
    ' . L10n::t('Send email to all members') . '
'; } -function notifyall_post(App &$a) +function notifyall_post(App $a) { if(! is_site_admin()) { From a74dbd6ad0d8fbf6b74f6b86435899a2e28ec284 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Mon, 14 May 2018 06:59:26 +0200 Subject: [PATCH 5/7] nitpickers --- notifyall/notifyall.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notifyall/notifyall.php b/notifyall/notifyall.php index 10162c50..76e24662 100644 --- a/notifyall/notifyall.php +++ b/notifyall/notifyall.php @@ -33,7 +33,7 @@ function notifyall_addon_admin(App $a, &$o) function notifyall_post(App $a) { - if(! is_site_admin()) + if(!is_site_admin()) { return; } @@ -50,7 +50,7 @@ function notifyall_post(App $a) if (empty($a->config['admin_name'])) { $sender_name = '"' . L10n::t('%s Administrator', $sitename) . '"'; - } else { + } else { $sender_name = '"' . L10n::t('%1$s, %2$s Administrator', $a->config['admin_name'], $sitename) . '"'; } From c297dfb24f46446b2a87afd5843224c18125cbc8 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Mon, 14 May 2018 07:02:31 +0200 Subject: [PATCH 6/7] bracings --- notifyall/notifyall.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/notifyall/notifyall.php b/notifyall/notifyall.php index 76e24662..a764b2ac 100644 --- a/notifyall/notifyall.php +++ b/notifyall/notifyall.php @@ -33,29 +33,25 @@ function notifyall_addon_admin(App $a, &$o) function notifyall_post(App $a) { - if(!is_site_admin()) - { + if(!is_site_admin()) { return; } $text = trim($_REQUEST['text']); - if(! $text) - { + if(! $text) { return; } $sitename = $a->config['sitename']; - if (empty($a->config['admin_name'])) - { + if (empty($a->config['admin_name'])) { $sender_name = '"' . L10n::t('%s Administrator', $sitename) . '"'; } else { $sender_name = '"' . L10n::t('%1$s, %2$s Administrator', $a->config['admin_name'], $sitename) . '"'; } - if (! x($a->config['sender_email'])) - { + if (! x($a->config['sender_email'])) { $sender_email = 'noreply@' . $a->get_hostname(); } else { $sender_email = $a->config['sender_email']; @@ -70,8 +66,7 @@ function notifyall_post(App $a) // 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'])) - { + if (intval($_REQUEST['test'])) { $email = $a->config['admin_email']; $email = "'" . str_replace([" ",","], ["","','"], $email) . "'"; } @@ -79,14 +74,12 @@ function notifyall_post(App $a) $recips = q("SELECT DISTINCT `email` FROM `user` WHERE `verified` AND NOT `account_removed` AND NOT `account_expired` $sql_extra"); - if (! $recips) - { + if (! $recips) { notice(L10n::t('No recipients found.') . EOL); return; } - foreach ($recips as $recip) - { + foreach ($recips as $recip) { Emailer::send([ 'fromName' => $sender_name, 'fromEmail' => $sender_email, From 6244cfe58adb061cafafc03a632cdbea3717350d Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Mon, 14 May 2018 14:45:29 +0200 Subject: [PATCH 7/7] no more space to breath --- notifyall/notifyall.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifyall/notifyall.php b/notifyall/notifyall.php index a764b2ac..c58d8c8e 100644 --- a/notifyall/notifyall.php +++ b/notifyall/notifyall.php @@ -74,7 +74,7 @@ function notifyall_post(App $a) $recips = q("SELECT DISTINCT `email` FROM `user` WHERE `verified` AND NOT `account_removed` AND NOT `account_expired` $sql_extra"); - if (! $recips) { + if (! $recips) { notice(L10n::t('No recipients found.') . EOL); return; }