As I am reading through the thread "Future of S9Y" I decided
to put my enhancement for email notifications in a new thread (here).
Problem:
* Notification email for a comment, does not contain the text of the comment.
* Missing signature (required in some jurisdictions [just to play safe])
Solution:
You need to change 2 files!
* Some constants in the language file. Use YOUR address not the example
address here.
* One php function
* Watch out, since my code here is based on S9Y 1.1.2. There might be
some differences.
Code: Select all
<?php
/*
based on S9Y 1.1.2
*/
/*
.../lang/UTF-8/serendipity_lang_en.inc.php
*/
//...
@define('NEW_COMMENT_TO_SUBSCRIBED_ENTRY', 'New comment to subscribed entry "%s"');
@define('SUBSCRIPTION_MAIL', "Hello %s,\n\nA new comment was made to the entry you are monitoring on \"%s\", entitled \"%s\"\n\n*Comments* (by %s): \"%s\"\n\nYou can find the entry here: %s\n\nYou can unsubscribe by clicking on this link: %s\n");
@define('SUBSCRIPTION_TRACKBACK_MAIL', "Hello %s,\n\nA new trackback was added to the entry you are monitoring on \"%s\", entitled \"%s\"\n\n*Comments* (by %s): \"%s\"\n\nYou can find the entry here: %s\n\nYou can unsubscribe by clicking on this link: %s\n");
@define('SIGNATURE', "\n-- \n%s, John Doe, 250 E 62th Street #14A,\nNew York, NY10015, USA\n\nDisclaimer: This email has been automatically generated from\na comment submission. The content should not be regarded\nas approved by the blog owner.\n\nPowered by Serendipity. The best blog around, you can use it too.\nCheck out <http://s9y.org> to find out how.");
//...
/*
.../include/functions_comments.inc.php
*/
function serendipity_mailSubscribers($entry_id, $poster, $posterMail, $title, $fromEmail = 'none@example.com', $cid = null) {
global $serendipity;
$entryURI = serendipity_archiveURL($entry_id, $title, 'baseURL') . ($cid > 0 ? '#c' . $cid : '');
$subject = sprintf(NEW_COMMENT_TO_SUBSCRIBED_ENTRY, $title);
$pgsql_insert = '';
$mysql_insert = '';
if ($serendipity['dbType'] == 'postgres') {
$pgsql_insert = 'DISTINCT ON (email)';
} else {
$mysql_insert = 'GROUP BY email';
}
$sql = "SELECT $pgsql_insert author, email, type, body
FROM {$serendipity['dbPrefix']}comments
WHERE entry_id = '". (int)$entry_id ."'
AND email <> '" . serendipity_db_escape_string($posterMail) . "'
AND email <> ''
AND subscribed = 'true' $mysql_insert";
$subscribers = serendipity_db_query($sql);
if (!is_array($subscribers)) {
return;
}
foreach ($subscribers as $subscriber) {
if ($subscriber['type'] == 'TRACKBACK') {
$text = sprintf(
SUBSCRIPTION_TRACKBACK_MAIL,
$subscriber['author'],
$serendipity['blogTitle'],
$title,
$poster,
$subscriber['body'],
$entryURI,
serendipity_rewriteURL('unsubscribe/' . urlencode($subscriber['email']) . '/' . (int)$entry_id, 'baseURL')
);
} else {
$text = sprintf(
SUBSCRIPTION_MAIL,
$subscriber['author'],
$serendipity['blogTitle'],
$title,
$poster,
$subscriber['body'],
$entryURI,
serendipity_rewriteURL('unsubscribe/' . urlencode($subscriber['email']) . '/' . (int)$entry_id, 'baseURL')
);
}
serendipity_sendMail($subscriber['email'], $subject, $text, $fromEmail);
}
}
?>
John