6 * Description: Send admin email message to all account holders. <b>-><a href=/notifyall TARGET = "_blank">send now!</a><-</b>
8 * Author: Mike Macgirvin (Inital Author of the hubbwall Addon for the Hubzilla Project)
9 * Author: Rabuzarus <https://friendica.kommune4.de/profile/rabuzarus> (Port to Friendica)
12 require_once('include/Emailer.php');
14 function notifyall_install() {
15 logger("installed notifyall");
18 function notifyall_uninstall() {
19 logger("removed notifyall");
22 function notifyall_module() {}
24 function notifyall_plugin_admin(&$a, &$o) {
26 $o = '<div></div> <a href="' . z_root() . '/notifyall">' . t('Send email to all members') . '</a></br/>';
31 function notifyall_post(&$a) {
35 $text = trim($_REQUEST['text']);
39 $sitename = $a->config['sitename'];
41 if (!x($a->config['admin_name']))
42 $sender_name = sprintf(t('%s Administrator'), $sitename);
44 $sender_name = sprintf(t('%1$s, %2$s Administrator'), $a->config['admin_name'], $sitename);
46 if (! x($a->config['sender_email']))
47 $sender_email = 'noreply@' . $a->get_hostname();
49 $sender_email = $a->config['sender_email'];
50 $subject = $_REQUEST['subject'];
53 $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r", "\\n"),array( "", "\n"), $text))),ENT_QUOTES,'UTF-8'));
55 $htmlversion = bbcode(stripslashes(str_replace(array("\\r","\\n"), array("","<br />\n"),$text)));
57 $sql_extra = ((intval($_REQUEST['test'])) ? sprintf(" AND `email` = '%s' ", get_config('system','admin_email')) : '');
60 $recips = q("SELECT `email` FROM `user` WHERE `verified` AND NOT `account_removed` AND NOT `account_expired` $sql_extra");
63 notice( t('No recipients found.') . EOL);
67 foreach($recips as $recip) {
71 'fromName' => $sender_name,
72 'fromEmail' => $sender_email,
73 'replyTo' => $sender_email,
74 'toEmail' => $recip['email'],
75 'messageSubject' => $subject,
76 'htmlVersion' => $htmlversion,
77 'textVersion' => $textversion
81 notice( t('Emails sent'));
85 function notifyall_content(&$a) {
89 $title = t('Send email to all members of this Friendica instance.');
91 $o = replace_macros(get_markup_template('notifyall_form.tpl','addon/notifyall/'),array(
93 '$text' => htmlspecialchars($_REQUEST['text']),
94 '$subject' => array('subject',t('Message subject'),$_REQUEST['subject'],''),
95 '$test' => array('test',t('Test mode (only send to administrator)'), 0,''),
96 '$submit' => t('Submit')