From 3d9845f4a45f963161e31fe18d69ed31e38af003 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 12 Feb 2011 03:14:59 -0800 Subject: preliminary ajax comment setups --- mod/item.php | 4 +++- mod/network.php | 2 +- mod/profile.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index a83373f59..0d9a674f2 100644 --- a/mod/item.php +++ b/mod/item.php @@ -490,7 +490,9 @@ function item_post(&$a) { } } - goaway($a->get_baseurl() . "/" . $_POST['return'] ); + if((x($_POST,'return')) && strlen($_POST['return'])) + goaway($a->get_baseurl() . "/" . $_POST['return'] ); + killme(); // NOTREACHED } diff --git a/mod/network.php b/mod/network.php index f11db45a8..f09b302e9 100644 --- a/mod/network.php +++ b/mod/network.php @@ -340,7 +340,7 @@ function network_content(&$a, $update = 0) { if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( - '$return_path' => $_SESSION['return_url'], + '$return_path' => '', // $_SESSION['return_url'], '$type' => 'net-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], diff --git a/mod/profile.php b/mod/profile.php index 8ec29d382..57abc479d 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -293,7 +293,7 @@ function profile_content(&$a, $update = 0) { } if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( - '$return_path' => $_SESSION['return_url'], + '$return_path' => '', // $_SESSION['return_url'], '$type' => 'wall-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], -- cgit v1.2.3 From 2d542e0f982598b792da6fbdf9cd7b29c2a04c83 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 12 Feb 2011 22:29:32 -0800 Subject: receiving comment notifications for conversations we aren't "involved" in --- mod/dfrn_notify.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index dffbb5974..755d674c1 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -391,8 +391,9 @@ function dfrn_notify_post(&$a) { intval($importer['importer_uid']) ); if(count($myconv)) { + $importer_url = $a->get_baseurl() . '/profile/' . $importer['nickname']; foreach($myconv as $conv) { - if(! link_compare($conv['author-link'],$importer['url'])) + if(! link_compare($conv['author-link'],$importer_url)) continue; require_once('bbcode.php'); $from = stripslashes($datarray['author-name']); -- cgit v1.2.3 From f98ba371cfdb0d0d47a5717aa60a5b703017cbe4 Mon Sep 17 00:00:00 2001 From: Chris Case Date: Sun, 13 Feb 2011 14:55:48 -0800 Subject: updated private message notification to use HTML, still need the foreign language message notifications updated --- mod/dfrn_notify.php | 56 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 755d674c1..49276647a 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -2,8 +2,6 @@ require_once('simplepie/simplepie.inc'); require_once('include/items.php'); - - function dfrn_notify_post(&$a) { $dfrn_id = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : ''); @@ -52,11 +50,17 @@ function dfrn_notify_post(&$a) { } - $r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`, - `contact`.`pubkey` AS `cpubkey`, `contact`.`prvkey` AS `cprvkey`, `user`.* FROM `contact` - LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` - WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `user`.`nickname` = '%s' $sql_extra LIMIT 1", + $r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`, + `contact`.`pubkey` AS `cpubkey`, + `contact`.`prvkey` AS `cprvkey`, + `contact`.`thumb` AS `thumb`, + `contact`.`url` as `url`, + `contact`.`name` as `senderName`, + `user`.* + FROM `contact` + LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` + WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND `user`.`nickname` = '%s' $sql_extra LIMIT 1", dbesc($a->argv[1]) ); @@ -169,29 +173,37 @@ function dfrn_notify_post(&$a) { require_once('bbcode.php'); if($importer['notify-flags'] & NOTIFY_MAIL) { - $body = html_entity_decode(strip_tags(bbcode(stripslashes($msg['body']))),ENT_QUOTES,'UTF-8'); - - if(function_exists('quoted_printable_encode')) +// $body = html_entity_decode(strip_tags(bbcode(stripslashes(nl2br($msg['body'])))),ENT_QUOTES,'UTF-8'); +// $body = strip_tags(bbcode(stripslashes(nl2br($msg['body'])))); + + /*if(function_exists('quoted_printable_encode')) $body = quoted_printable_encode($body); else - $body = qp($body); + $body = qp($body);*/ + $msg['body'] = str_replace(array("\\r\\n", "\\r", "\\n"), "
", $msg['body']); + $msg['body'] = html_entity_decode(strip_tags(bbcode($msg['body']))); $tpl = load_view_file('view/mail_received_eml.tpl'); $email_tpl = replace_macros($tpl, array( - '$sitename' => $a->config['sitename'], - '$siteurl' => $a->get_baseurl(), - '$username' => $importer['username'], - '$email' => $importer['email'], - '$from' => $msg['from-name'], - '$title' => stripslashes($msg['title']), - '$body' => $body + '$siteName' => $a->config['sitename'], + '$siteurl' => $a->get_baseurl(), + '$username' => $importer['username'], + '$thumb' => $importer['thumb'], + '$email' => $importer['email'], + '$url' => $importer['url'], + '$senderName' => $importer['senderName'], + '$from' => $msg['from-name'], + '$title' => stripslashes($msg['title']), + '$body' => $msg['body'], + '$hostname' => $a->get_hostname() )); - + $res = mail($importer['email'], t('New mail received at ') . $a->config['sitename'], - $email_tpl, 'From: ' . t('Administrator') . '@' . $a->get_hostname() . "\r\n" + $email_tpl, + 'From: ' . t('Administrator') . '@' . $a->get_hostname() . "\r\n" . 'MIME-Version: 1.0' . "\r\n" - . 'Content-type: text/plain; charset=UTF-8' . "\r\n" - . 'Content-transfer-encoding: quoted-printable' . "\r\n" + . 'Content-type: text/html; charset=iso-8859-1' . "\r\n" + . 'Content-transfer-encoding: 7-bit' . "\r\n" ); } xml_status(0); -- cgit v1.2.3 From 5eebb373e5ac761ba0f2020a85fa6db7544f7229 Mon Sep 17 00:00:00 2001 From: Chris Case Date: Mon, 14 Feb 2011 03:59:54 -0800 Subject: revamped private message templates, added multipart messages with text and html versions, updated de, en, fr and it. Translated the french version of the private message template. --- mod/dfrn_notify.php | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 49276647a..ffd9020c5 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -181,8 +181,28 @@ function dfrn_notify_post(&$a) { else $body = qp($body);*/ - $msg['body'] = str_replace(array("\\r\\n", "\\r", "\\n"), "
", $msg['body']); - $msg['body'] = html_entity_decode(strip_tags(bbcode($msg['body']))); + //$msg['body'] = str_replace(array("\\r\\n", "\\r", "\\n"), "
", $msg['body']); + //$msg['body'] = html_entity_decode(strip_tags(bbcode($msg['body']))); + $msg['mimeboundary'] =rand(0,9)."-" + .rand(10000000000,9999999999)."-" + .rand(10000000000,9999999999)."=:" + .rand(10000,99999); + + $msg['notificationfromname'] = t('Administrator'); + $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname(); + $msg['headers'] = + "From: {$msg['notificationfromname']} <{$msg['notificationfromemail']}>\n" . + "Reply-To: {$msg['notificationfromemail']}\n" . + "MIME-Version: 1.0\n" . + "Content-Type: multipart/alternative; boundary=\"{$msg['mimeboundary']}\""; + + + $msg['textversion'] + = html_entity_decode(strip_tags(bbcode(stripslashes($msg['body']))),ENT_QUOTES,'UTF-8'); + //$TextMessage = html_entity_decode(strip_tags(bbcode(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",$msg['body'])))); ; + $msg['htmlversion'] + = str_replace(array("\\r\\n", "\\r", "\\n"), "
\n",html_entity_decode($msg['body'])); + $tpl = load_view_file('view/mail_received_eml.tpl'); $email_tpl = replace_macros($tpl, array( '$siteName' => $a->config['sitename'], @@ -194,16 +214,22 @@ function dfrn_notify_post(&$a) { '$senderName' => $importer['senderName'], '$from' => $msg['from-name'], '$title' => stripslashes($msg['title']), - '$body' => $msg['body'], + '$textversion' => $msg['textversion'], + '$htmlversion' => $msg['htmlversion'], + '$mimeboundary' => $msg['mimeboundary'], '$hostname' => $a->get_hostname() )); + logger("message headers: " . $msg['headers']); + logger("message body: " . $mail_tpl); + + $res = mail($importer['email'], t('New mail received at ') . $a->config['sitename'], - $email_tpl, - 'From: ' . t('Administrator') . '@' . $a->get_hostname() . "\r\n" + $email_tpl, $msg['headers'] + /* 'From: ' . t('Administrator') . '@' . $a->get_hostname() . "\r\n" . 'MIME-Version: 1.0' . "\r\n" - . 'Content-type: text/html; charset=iso-8859-1' . "\r\n" - . 'Content-transfer-encoding: 7-bit' . "\r\n" + . 'Content-type: text/html; charset=utf-8' . "\r\n" + . 'Content-transfer-encoding: quoted-printable' . "\r\n" */ ); } xml_status(0); -- cgit v1.2.3 From df209907536a3c5e093b8ae95070ca9941c6c797 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 14 Feb 2011 04:43:49 -0800 Subject: ajax comments --- mod/item.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 0d9a674f2..2cc2b9eb2 100644 --- a/mod/item.php +++ b/mod/item.php @@ -492,6 +492,9 @@ function item_post(&$a) { if((x($_POST,'return')) && strlen($_POST['return'])) goaway($a->get_baseurl() . "/" . $_POST['return'] ); + + $json = array('success' => 1); + echo json_encode($json); killme(); // NOTREACHED } -- cgit v1.2.3 From 42eb6dd723abd31aaaf6c1608f2dec645f4e20b5 Mon Sep 17 00:00:00 2001 From: Chris Case Date: Mon, 14 Feb 2011 05:44:27 -0800 Subject: fixed a bbcode issue with rich text html messages, fixed some issues with plain text. --- mod/dfrn_notify.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index ffd9020c5..7231e8fd2 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -198,10 +198,10 @@ function dfrn_notify_post(&$a) { $msg['textversion'] - = html_entity_decode(strip_tags(bbcode(stripslashes($msg['body']))),ENT_QUOTES,'UTF-8'); + = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",$msg['body']))),ENT_QUOTES,'UTF-8')); //$TextMessage = html_entity_decode(strip_tags(bbcode(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",$msg['body'])))); ; $msg['htmlversion'] - = str_replace(array("\\r\\n", "\\r", "\\n"), "
\n",html_entity_decode($msg['body'])); + = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "
\n",$msg['body'])))); $tpl = load_view_file('view/mail_received_eml.tpl'); $email_tpl = replace_macros($tpl, array( -- cgit v1.2.3 From 1dea6a2d711ddf39a5239dc86a1e3c4b7a650064 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 14 Feb 2011 20:21:28 -0800 Subject: wrong return url for ajax comments on display and photos pages --- mod/display.php | 2 +- mod/photos.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/display.php b/mod/display.php index 3215ae90a..b07e1aee5 100644 --- a/mod/display.php +++ b/mod/display.php @@ -153,7 +153,7 @@ function display_content(&$a) { } if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( - '$return_path' => $_SESSION['return_url'], + '$return_path' => '', // $_SESSION['return_url'], '$type' => 'wall-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], diff --git a/mod/photos.php b/mod/photos.php index 9acde458d..a44eb5a5f 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1048,7 +1048,7 @@ function photos_content(&$a) { if($can_post || can_write_wall($a,$owner_uid)) { if($link_item['last-child']) { $o .= replace_macros($cmnt_tpl,array( - '$return_path' => $return_url, + '$return_path' => '', // $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], -- cgit v1.2.3 From 0d853433eb9b3e6d7bd4305f42bad739ca7a7e48 Mon Sep 17 00:00:00 2001 From: Chris Case Date: Tue, 15 Feb 2011 03:31:20 -0800 Subject: fixed error which was causing multiple line breaks, added comments to better document what is occuring, cleaned up code, removed unnecessary parameters from templating step --- mod/dfrn_notify.php | 75 +++++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 34 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 7231e8fd2..5f91f1b1b 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -173,63 +173,70 @@ function dfrn_notify_post(&$a) { require_once('bbcode.php'); if($importer['notify-flags'] & NOTIFY_MAIL) { -// $body = html_entity_decode(strip_tags(bbcode(stripslashes(nl2br($msg['body'])))),ENT_QUOTES,'UTF-8'); -// $body = strip_tags(bbcode(stripslashes(nl2br($msg['body'])))); - - /*if(function_exists('quoted_printable_encode')) - $body = quoted_printable_encode($body); - else - $body = qp($body);*/ - - //$msg['body'] = str_replace(array("\\r\\n", "\\r", "\\n"), "
", $msg['body']); - //$msg['body'] = html_entity_decode(strip_tags(bbcode($msg['body']))); + // generate a mime boundary $msg['mimeboundary'] =rand(0,9)."-" .rand(10000000000,9999999999)."-" .rand(10000000000,9999999999)."=:" .rand(10000,99999); + // name of the automated email sender $msg['notificationfromname'] = t('Administrator'); + // noreply address to send from $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname(); + // message headers $msg['headers'] = "From: {$msg['notificationfromname']} <{$msg['notificationfromemail']}>\n" . "Reply-To: {$msg['notificationfromemail']}\n" . "MIME-Version: 1.0\n" . "Content-Type: multipart/alternative; boundary=\"{$msg['mimeboundary']}\""; - + // text version + // process the message body to display properly in text mode + // 1) substitute a \n character for the "\" then "n", so it behaves properly (it doesn't come in as a \n character) + // 2) remove escape slashes + // 3) decode any bbcode from the message editor + // 4) decode any encoded html tags + // 5) remove html tags $msg['textversion'] = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",$msg['body']))),ENT_QUOTES,'UTF-8')); - //$TextMessage = html_entity_decode(strip_tags(bbcode(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",$msg['body'])))); ; + + // html version + // process the message body to display properly in text mode + // 1) substitute a
tag for the "\" then "n", so it behaves properly (it doesn't come in as a \n character) + // 2) remove escape slashes + // 3) decode any bbcode from the message editor + // 4) decode any encoded html tags $msg['htmlversion'] - = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "
\n",$msg['body'])))); - - $tpl = load_view_file('view/mail_received_eml.tpl'); + = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), "
\n",$msg['body'])))); + + // load the template for private message notifications + $tpl = load_view_file('view/mail_received_eml.tpl'); + + // import the data into the template $email_tpl = replace_macros($tpl, array( - '$siteName' => $a->config['sitename'], - '$siteurl' => $a->get_baseurl(), - '$username' => $importer['username'], - '$thumb' => $importer['thumb'], - '$email' => $importer['email'], - '$url' => $importer['url'], - '$senderName' => $importer['senderName'], - '$from' => $msg['from-name'], - '$title' => stripslashes($msg['title']), - '$textversion' => $msg['textversion'], - '$htmlversion' => $msg['htmlversion'], - '$mimeboundary' => $msg['mimeboundary'], - '$hostname' => $a->get_hostname() + '$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 + '$htmlversion' => $msg['htmlversion'], // html version of the message + '$mimeboundary' => $msg['mimeboundary'], // mime message divider + '$hostname' => $a->get_hostname() // name of this host )); logger("message headers: " . $msg['headers']); logger("message body: " . $mail_tpl); - $res = mail($importer['email'], t('New mail received at ') . $a->config['sitename'], - $email_tpl, $msg['headers'] - /* 'From: ' . t('Administrator') . '@' . $a->get_hostname() . "\r\n" - . 'MIME-Version: 1.0' . "\r\n" - . 'Content-type: text/html; charset=utf-8' . "\r\n" - . 'Content-transfer-encoding: quoted-printable' . "\r\n" */ + // send the message + $res = mail( + $importer['email'], // send to address + t('New mail received at ') . $a->config['sitename'], // subject + $email_tpl, // message body + $msg['headers'] // message headers ); } xml_status(0); -- cgit v1.2.3