Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv24930
Modified Files:
comment.php serendipity_functions.inc.php
serendipity_config.inc.php serendipity_config_local.tpl
Log Message:
* Allow users to subscribe to entries. Thereby getting a mail each time *another* user posts a comment
* Make this an option in the configuration, for blogOwners not wanting this feature
* Make Email Signature RFC compliant [-- ]
* Move Email Signature to _config, so we don't have diffirent signatures all over the place
Index: comment.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/comment.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- comment.php 8 Aug 2003 22:29:37 -0000 1.19
+++ comment.php 15 Aug 2003 23:04:36 -0000 1.20
@@ -99,6 +99,7 @@
$comment['comment'] = trim($serendipity['POST']['comment']);
$comment['name'] = $serendipity['POST']['name'];
$comment['email'] = $serendipity['POST']['email'];
+ $comment['subscribe'] = $serendipity['POST']['subscribe'];
if ( !empty($comment['comment']) ) {
serendipity_saveComment($serendipity['POST']['entry_id'], $comment, 'NORMAL');
printf(
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -d -r1.130 -r1.131
--- serendipity_functions.inc.php 13 Aug 2003 16:58:01 -0000 1.130
+++ serendipity_functions.inc.php 15 Aug 2003 23:04:36 -0000 1.131
@@ -162,7 +162,19 @@
</tr>
<tr>
<td> </td>
- <td class="serendipity_commentsLabel"><input type="submit" value="<?php echo SUBMIT_COMMENT; ?>" /> <input type="checkbox" name="serendipity[remember]" <?php echo $serendipity['COOKIE']['remember'] ; ?> /> <?php echo REMEMBER_INFO; ?></td>
+ <td class="serendipity_commentsLabel"><input type="checkbox" name="serendipity[remember]" <?php echo $serendipity['COOKIE']['remember'] ; ?> /> <?php echo REMEMBER_INFO; ?>
+<?php
+ if ( $serendipity['allowSubscriptions'] ) {
+?>
+ <br /><input type="checkbox" name="serendipity[subscribe]" /> Subscribe to this entry
+<?php
+ }
+?>
+ </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td><input type="submit" value="<?php echo SUBMIT_COMMENT; ?>" /> </td>
</tr>
</table>
</form>
@@ -789,10 +801,16 @@
$name = serendipity_db_escape_string($commentInfo['name']);
$url = serendipity_db_escape_string($commentInfo['url']);
$email = serendipity_db_escape_string($commentInfo['email']);
-
+
+ if ( isset($commentInfo['subscribe']) ) {
+ $subscribe = 'true';
+ } else {
+ $subscribe = 'false';
+ }
+
$t = time();
- $query = "INSERT INTO {$serendipity['dbPrefix']}comments (entry_id, author, email, url, body, type, timestamp, title)";
- $query .= " VALUES ('$id', '$name', '$email', '$url', '$commentsFixed', '$type', '$t', '$title')";
+ $query = "INSERT INTO {$serendipity['dbPrefix']}comments (entry_id, author, email, url, body, type, timestamp, title, subscribed)";
+ $query .= " VALUES ('$id', '$name', '$email', '$url', '$commentsFixed', '$type', '$t', '$title', '$subscribe')";
serendipity_db_query($query);
@@ -809,9 +827,45 @@
if($row['mail_comments']) {
serendipity_sendComment($row['email'], $name, $email, $url, $id, $row['title'], $comments, $type);
}
+ if ( $serendipity['allowSubscriptions'] ) {
+ serendipity_mailSubscribers($id, $name, $email, $row['title'], $row['email']);
+ }
serendipity_purgeEntry($id, $t);
}
+
+function serendipity_mailSubscribers($entry_id, $poster, $posterMail, $title, $fromEmail = 'no...@ex...') {
+ global $serendipity;
+
+ $entryURI = serendipity_archiveURL($entry_id, $title);
+ $subject = '[' . $serendipity['blogTitle'] . '] New comment to subscribed entry "' . $title .'"';
+
+ $sql = "SELECT author, email
+ FROM {$serendipity['dbPrefix']}comments
+ WHERE entry_id = $entry_id
+ AND email <> '$posterMail'
+ AND subscribed = 'true'
+ GROUP BY email";
+ $subscribers = serendipity_db_query($sql);
+
+ if ( !is_array($subscribers) ) {
+ return;
+ }
+
+ foreach ( $subscribers as $subscriber ) {
+ $text = 'Hello '. $subscriber['author'] .','
+ . "\n"
+ . "\n" . 'A new comment was made to the entry you are monitoring on "'. $serendipity['blogTitle'] .'", entitled "'. $title .'"'
+ . "\n" . 'The name of the poster is: '. $poster
+ . "\n"
+ . "\n" . 'You can find the entry here: '. $entryURI
+ . "\n";
+
+ mail($subscriber['email'], $subject, $text.$serendipity['signature'], "From: {$serendipity['blogTitle']} <$fromEmail>\r\n");
+ }
+
+}
+
/**
* Adds a comment
**/
@@ -855,12 +909,7 @@
. "\n" . strip_tags($comment);
}
- $signature = "\n--"
- . "\n" . $serendipity[blogTitle] . ' is powered by Serendipity.'
- . "\n" . 'The best blog around, you can use it too.'
- . "\n" . 'Check out <http://s9y.org> to find out how.';
-
- return mail($to, $subject, $text.$signature, "From: $fromName <$fromEmail>\r\n");
+ return mail($to, $subject, $text.$serendipity['signature'], "From: {$serendipity['blogTitle']} <$fromEmail>\r\n");
}
function serendipity_fetchReferences($id)
Index: serendipity_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config.inc.php,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- serendipity_config.inc.php 8 Aug 2003 23:33:48 -0000 1.21
+++ serendipity_config.inc.php 15 Aug 2003 23:04:36 -0000 1.22
@@ -150,6 +150,13 @@
$serendipity['user'] = $_SESSION['serendipityUser'];
$serendipity['email'] = $_SESSION['serendipityEmail'];
+/* Signature sent with all mails */
+$serendipity['signature'] = "\n-- "
+ . "\n" . $serendipity['blogTitle'] . ' is powered by Serendipity.'
+ . "\n" . 'The best blog around, you can use it too.'
+ . "\n" . 'Check out <http://s9y.org> to find out how.';
+
+
/**
* Local Variables:
* c-basic-offset: 4
Index: serendipity_config_local.tpl
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config_local.tpl,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- serendipity_config_local.tpl 9 Aug 2003 00:57:49 -0000 1.14
+++ serendipity_config_local.tpl 15 Aug 2003 23:04:36 -0000 1.15
@@ -22,6 +22,7 @@
$serendipity['pass'] = '{Admin password|pass|protected|john}'; // Password for admin login
$serendipity['email'] = '{Admin email|email|string|jo...@ex...}'; // Email for admin login
$serendipity['want_mail'] = '{Send mails to admin?|want_mail|bool|1}'; // Do you want to receive emails when comments are posted to your entries?
+$serendipity['allowSubscriptions'] = '{Allow users to subscribe to entries?|allowSubscriptions|bool|1} // Allow users to subscribe to an entry and thereby receive a mail when new comments are made to that entry
$serendipity['blogTitle'] = '{Blog name|blogTitle|string|John Doe's personal blog}'; // The title of your blog
$serendipity['blogDescription'] = '{Blog description|blogDescription|string|Welcome to my blog...}'; // Description of your blog
|