diff options
author | friendica <info@friendica.com> | 2011-12-25 23:00:19 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2011-12-25 23:00:19 -0800 |
commit | bb40e54dec9f72a3c415df5d3799eab0010c5ddf (patch) | |
tree | 06960364d62c495a9afa6c413d75445545861327 /include/enotify.php | |
parent | 205dcd8f5bd01feedd8877581876ec7253b4c15a (diff) | |
download | volse-hubzilla-bb40e54dec9f72a3c415df5d3799eab0010c5ddf.tar.gz volse-hubzilla-bb40e54dec9f72a3c415df5d3799eab0010c5ddf.tar.bz2 volse-hubzilla-bb40e54dec9f72a3c415df5d3799eab0010c5ddf.zip |
new notification module working for "email message received"
Diffstat (limited to 'include/enotify.php')
-rw-r--r-- | include/enotify.php | 108 |
1 files changed, 59 insertions, 49 deletions
diff --git a/include/enotify.php b/include/enotify.php index 11a5d70dd..05d2783d6 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -5,7 +5,7 @@ /* $notif_params = array( 'type' => NOTIFY_MAIL, - 'notify_flags' => $importer['notify_flags'], + 'notify_flags' => $importer['notify-flags'], 'language' => $importer['language'], 'to_name' => $importer['username'], 'to_email' => $importer['email'], @@ -20,6 +20,8 @@ function notification($params) { + logger('notification: entry'); + $a = get_app(); $banner = t('Friendica Notification'); $product = FRIENDICA_PLATFORM; @@ -36,78 +38,84 @@ function notification($params) { if($params['type'] == NOTIFY_MAIL) { + logger('notification: email'); + $subject = sprintf( t('New mail received at %s'),$sitename); $preamble = sprintf( t('%s sent you a new private message at %s.'),$params['source_name'],$sitename); - $sitelink = t('Please visit %s to view and/or reply to your private messages.'); - $tsitelink = sprintf( $email_visit, $siteurl . '/message' ); - $hsitelink = sprintf( $email_visit, '<a href="' . $siteurl . '/message">' . $sitename . '</a>'); + $sitelink = t('Please visit %s to view and/or reply to your private messages.'); + $tsitelink = sprintf( $sitelink, $siteurl . '/message' ); + $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/message">' . $sitename . '</a>'); } // send email notification if notification preferences permit require_once('bbcode.php'); - if(intval($params['notify-flags']) & intval($params['type'])) { + if(intval($params['notify_flags']) & intval($params['type'])) { - push_lang($params['language']); + logger('notification: sending email'); - $msg = array(); - $msg['fromname'] = $sender_name; - $msg['fromemail'] = $sender_email; + push_lang($params['language']); - $msg['textversion'] = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n", - $body))),ENT_QUOTES,'UTF-8')); - $msg['htmlversion'] = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), - "<br />\n",$body)))); + $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n", + $body))),ENT_QUOTES,'UTF-8')); + $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), + "<br />\n",$body)))); // load the template for private message notifications - $tpl = get_view_template('email_notify_html.tpl'); - $email_html_body_tpl = replace_macros($tpl,array( - '$banner' => $banner, - '$product' => $product, - '$preamble' => $preamble, - '$source_name' => $parama['source_name'], - '$source_link' => $params['source_link'], + $tpl = get_markup_template('email_notify_html.tpl'); + $email_html_body = replace_macros($tpl,array( + '$banner' => $banner, + '$product' => $product, + '$preamble' => $preamble, + '$sitename' => $sitename, + '$siteurl' => $siteurl, + '$source_name' => $parama['source_name'], + '$source_link' => $params['source_link'], '$source_photo' => $params['source_photo'], '$username' => $params['to_name'], '$hsitelink' => $hsitelink, '$thanks' => $thanks, '$site_admin' => $site_admin, - '$title' => stripslashes($msg['title']), // subject of the message - '$htmlversion' => $msg['htmlversion'], // html version of the message - + '$title' => stripslashes($title), + '$htmlversion' => $htmlversion, )); // load the template for private message notifications - $tpl = get_intltext_template('mail_received_text_body_eml.tpl'); - $email_text_body_tpl = replace_macros($tpl,array( - '$username' => $importer['username'], - '$siteName' => $a->config['sitename'], // name of this site - '$siteurl' => $a->get_baseurl(), // descriptive url of this site - '$thumb' => $importer['thumb'], // thumbnail url for sender icon - '$email' => $importer['email'], // email address to send to - '$url' => $importer['url'], // full url for the site - '$from' => $msg['from-name'], // name of the person sending the message - '$title' => stripslashes($msg['title']), // subject of the message - '$textversion' => $msg['textversion'], // text version of the message - '$mimeboundary' => $msg['mimeboundary'], // mime message divider - '$hostname' => $a->get_hostname() // name of this host + $tpl = get_markup_template('email_notify_text.tpl'); + $email_text_body = replace_macros($tpl,array( + '$banner' => $banner, + '$product' => $product, + '$preamble' => $preamble, + '$sitename' => $sitename, + '$siteurl' => $siteurl, + '$source_name' => $parama['source_name'], + '$source_link' => $params['source_link'], + '$source_photo' => $params['source_photo'], + '$username' => $params['to_name'], + '$tsitelink' => $tsitelink, + '$thanks' => $thanks, + '$site_admin' => $site_admin, + '$title' => stripslashes($title), + '$textversion' => $textversion, )); + logger('text: ' . $email_text_body); + // use the EmailNotification library to send the message - require_once("include/EmailNotification.php"); - EmailNotification::sendTextHtmlEmail( - $msg['notificationfromname'], - $msg['notificationfromemail'], - $msg['notificationfromemail'], - $importer['email'], - $subject, - $email_html_body_tpl, - $email_text_body_tpl - ); - pop_lang(); + + enotify::send(array( + 'fromName' => $sender_name, + 'fromEmail' => $sender_email, + 'replyTo' => $sender_email, + 'toEmail' => $params['to_email'], + 'messageSubject' => $subject, + 'htmlVersion' => $email_html_body, + 'textVersion' => $email_text_body + )); + pop_lang(); } } @@ -126,6 +134,8 @@ class enotify { * @param textVersion text only version of the message */ static public function send($params) { + + logger('enotify: send: ' . print_r($params,true)); $fromName = email_header_encode($params['fromName'],'UTF-8'); $messageSubject = email_header_encode($params['messageSubject'],'UTF-8'); @@ -159,8 +169,8 @@ class enotify { // send the message $res = mail( - $toEmail, // send to address - $messageSubject, // subject + $params['toEmail'], // send to address + $params['messageSubject'], // subject $multipartMessageBody, // message body $messageHeader // message headers ); |