aboutsummaryrefslogtreecommitdiffstats
path: root/mod/dfrn_notify.php
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-05-21 23:41:57 -0700
committerFriendika <info@friendika.com>2011-05-21 23:41:57 -0700
commit558cb9d8981994610e1c9bac536a6e2bfb6d19b6 (patch)
tree2f803d93f54c2cb82ac47c05f1659d8827cef75e /mod/dfrn_notify.php
parentf3f063c0dd7fd8b706987b856d79c7b58924acbb (diff)
parentf4cb6b9b08f6dc392b1f008f0aa9e9181f9e8b21 (diff)
downloadvolse-hubzilla-558cb9d8981994610e1c9bac536a6e2bfb6d19b6.tar.gz
volse-hubzilla-558cb9d8981994610e1c9bac536a6e2bfb6d19b6.tar.bz2
volse-hubzilla-558cb9d8981994610e1c9bac536a6e2bfb6d19b6.zip
Merge pull request #104 from chriscase/master
Multipart text/html Email Updates
Diffstat (limited to 'mod/dfrn_notify.php')
-rw-r--r--mod/dfrn_notify.php163
1 files changed, 119 insertions, 44 deletions
diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php
index 9ea980338..5f6ed59d4 100644
--- a/mod/dfrn_notify.php
+++ b/mod/dfrn_notify.php
@@ -79,6 +79,9 @@ function dfrn_notify_post(&$a) {
// $importer in this case contains the contact record for the remote contact joined with the user record of our user.
$importer = $r[0];
+ foreach($importer as $key => $val) {
+ logger( "importer - key: " . $key . " val: " . $val);
+ }
if(($writable != (-1)) && ($writable != $importer['writable'])) {
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d LIMIT 1",
@@ -212,31 +215,31 @@ function dfrn_notify_post(&$a) {
// load the template for private message notifications
$tpl = get_intltext_template('mail_received_html_body_eml.tpl');
$email_html_body_tpl = replace_macros($tpl,array(
- '$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
+ '$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
'$htmlversion' => $msg['htmlversion'], // html version of the message
'$mimeboundary' => $msg['mimeboundary'], // mime message divider
- '$hostname' => $a->get_hostname() // name of this host
+ '$hostname' => $a->get_hostname() // name of this host
));
// 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(
- '$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
+ '$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
+ '$hostname' => $a->get_hostname() // name of this host
));
// use the EmailNotification library to send the message
@@ -389,22 +392,59 @@ function dfrn_notify_post(&$a) {
if((! $is_like) && ($importer['notify-flags'] & NOTIFY_COMMENT) && (! $importer['self'])) {
require_once('bbcode.php');
$from = stripslashes($datarray['author-name']);
- $tpl = get_intltext_template('cmnt_received_eml.tpl');
- $email_tpl = replace_macros($tpl, array(
- '$sitename' => $a->config['sitename'],
- '$siteurl' => $a->get_baseurl(),
- '$username' => $importer['username'],
- '$email' => $importer['email'],
- '$display' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $posted_id,
- '$from' => $from,
- '$body' => html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8')
+
+ // name of the automated email sender
+ $msg['notificationfromname'] = stripslashes($datarray['author-name']);;
+ // noreply address to send from
+ $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname();
+
+ // text version
+ // process the message body to display properly in text mode
+ $msg['textversion']
+ = html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8');
+
+ // html version
+ // process the message body to display properly in text mode
+ $msg['htmlversion']
+ = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), "<br />\n",$datarray['body']))));
+
+ // load the template for private message notifications
+ $tpl = get_intltext_template('cmnt_received_html_body_eml.tpl');
+ $email_html_body_tpl = replace_macros($tpl,array(
+ '$sitename' => $a->config['sitename'], // name of this site
+ '$siteurl' => $a->get_baseurl(), // descriptive url of this site
+ '$thumb' => $datarray['author-avatar'], // thumbnail url for sender icon
+ '$email' => $importer['email'], // email address to send to
+ '$url' => $datarray['author-link'], // full url for the site
+ '$from' => $from, // name of the person sending the message
+ '$body' => 'q1' .$msg['htmlversion'], // html version of the message
+ '$display' => $a->get_baseurl() . '/display/' . $importer['nick'] . '/' . $posted_id,
+ ));
+
+ // load the template for private message notifications
+ $tpl = get_intltext_template('cmnt_received_text_body_eml.tpl');
+ $email_text_body_tpl = replace_macros($tpl,array(
+ '$sitename' => $a->config['sitename'], // name of this site
+ '$siteurl' => $a->get_baseurl(), // descriptive url of this site
+ '$thumb' => $datarray['author-avatar'], // thumbnail url for sender icon
+ '$email' => $importer['email'], // email address to send to
+ '$url' => $datarray['author-link'], // full url for the site
+ '$from' => $from, // name of the person sending the message
+ '$body' => $msg['textversion'], // text version of the message
+ '$display' => $a->get_baseurl() . '/display/' . $importer['nick'] . '/' . $posted_id,
));
-
- $res = mail($importer['email'], sprintf(t('%s commented on an item at %s'), $from , $a->config['sitename']),
- $email_tpl,
- 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
- . 'Content-type: text/plain; charset=UTF-8' . "\n"
- . 'Content-transfer-encoding: 8bit' );
+
+ // use the EmailNotification library to send the message
+ require_once("include/EmailNotification.php");
+ EmailNotification::sendTextHtmlEmail(
+ $msg['notificationfromname'],
+ t("Administrator@") . $a->get_hostname(),
+ t("noreply") . '@' . $a->get_hostname(),
+ $importer['email'],
+ $from . t(" commented on an item at ") . $a->config['sitename'],
+ $email_html_body_tpl,
+ $email_text_body_tpl
+ );
}
}
@@ -468,7 +508,7 @@ function dfrn_notify_post(&$a) {
if(($datarray['type'] != 'activity') && ($importer['notify-flags'] & NOTIFY_COMMENT)) {
- $myconv = q("SELECT `author-link` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 ",
+ $myconv = q("SELECT `author-link`, `author-avatar` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 ",
dbesc($parent_uri),
intval($importer['importer_uid'])
);
@@ -479,22 +519,57 @@ function dfrn_notify_post(&$a) {
continue;
require_once('bbcode.php');
$from = stripslashes($datarray['author-name']);
- $tpl = get_intltext_template('cmnt_received_eml.tpl');
- $email_tpl = replace_macros($tpl, array(
- '$sitename' => $a->config['sitename'],
- '$siteurl' => $a->get_baseurl(),
- '$username' => $importer['username'],
- '$email' => $importer['email'],
- '$from' => $from,
- '$display' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $r,
- '$body' => html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8')
+
+ // name of the automated email sender
+ $msg['notificationfromname'] = stripslashes($datarray['author-name']);;
+ // noreply address to send from
+ $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname();
+
+ // text version
+ // process the message body to display properly in text mode
+ $msg['textversion']
+ = html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8');
+
+ // html version
+ // process the message body to display properly in text mode
+ $msg['htmlversion']
+ = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), "<br />\n",$datarray['body']))));
+
+ // load the template for private message notifications
+ $tpl = get_intltext_template('cmnt_received_html_body_eml.tpl');
+ $email_html_body_tpl = replace_macros($tpl,array(
+ '$sitename' => $a->config['sitename'], // name of this site
+ '$siteurl' => $a->get_baseurl(), // descriptive url of this site
+ '$thumb' => $conv['author-avatar'], // thumbnail url for sender icon
+ '$url' => $conv['author-link'], // full url for the site
+ '$from' => $from, // name of the person sending the message
+ '$body' => $msg['htmlversion'], // html version of the message
+ '$display' => $a->get_baseurl() . '/display/' . $importer['nick'] . '/' . $posted_id,
+ ));
+
+ // load the template for private message notifications
+ $tpl = get_intltext_template('cmnt_received_text_body_eml.tpl');
+ $email_text_body_tpl = replace_macros($tpl,array(
+ '$sitename' => $a->config['sitename'], // name of this site
+ '$siteurl' => $a->get_baseurl(), // descriptive url of this site
+ '$thumb' => $conv['author-avatar'], // thumbnail url for sender icon
+ '$url' => $conv['author-link'], // full url for the site
+ '$from' => $from, // name of the person sending the message
+ '$body' => $msg['textversion'], // text version of the message
+ '$display' => $a->get_baseurl() . '/display/' . $importer['nick'] . '/' . $posted_id,
));
- $res = mail($importer['email'], sprintf( t("%s commented on an item at %s") , $from ,$a->config['sitename']),
- $email_tpl,
- 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
- . 'Content-type: text/plain; charset=UTF-8' . "\n"
- . 'Content-transfer-encoding: 8bit' );
+ // use the EmailNotification library to send the message
+ require_once("include/EmailNotification.php");
+ EmailNotification::sendTextHtmlEmail(
+ $msg['notificationfromname'],
+ t("Administrator@") . $a->get_hostname(),
+ t("noreply") . '@' . $a->get_hostname(),
+ $importer['email'],
+ $from . t(" commented on an item at ") . $a->config['sitename'],
+ $email_html_body_tpl,
+ $email_text_body_tpl
+ );
break;
}