Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv12058
Modified Files:
NEWS comment.php serendipity_config.inc.php
serendipity_functions.inc.php serendipity_lang_de.inc.php
serendipity_lang_en.inc.php db.sql
Log Message:
* Minor code-cleanup (spaces)
* German/English localization of new comment-subscription
* SQL-Schema change (default value)
* Calendar can now only be scrolled betwen first and last entries to the
blogs +/- one month. If no entries exist, you can scroll +/- one year from
now. This will keep spiders from indexing your site till 2039 :-)
* Removed unused function serendipity_addComment()
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- NEWS 15 Aug 2003 02:53:15 -0000 1.11
+++ NEWS 16 Aug 2003 11:05:48 -0000 1.12
@@ -2,6 +2,8 @@
Version 0.3 ()
------------------------------------
+ * Allow subscription of blog-visitors to receive comments for an entry (tomsommer)
+ * Restrict calendar to only browse between the dates you have comments available for (garvinhicking)
* Added external plugin to display the latest comments on a sidebar (experimental, garvinhicking)
* Add Link to extended entry in RSS-feed, if existing (garvinhicking)
* Unified admin login functionality (tomsommer)
Index: comment.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/comment.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- comment.php 15 Aug 2003 23:04:36 -0000 1.20
+++ comment.php 16 Aug 2003 11:05:48 -0000 1.21
@@ -95,11 +95,11 @@
serendipity_displayCommentForm($id);
}
} else {
- $comment['url'] = $serendipity['POST']['url'];
- $comment['comment'] = trim($serendipity['POST']['comment']);
- $comment['name'] = $serendipity['POST']['name'];
- $comment['email'] = $serendipity['POST']['email'];
- $comment['subscribe'] = $serendipity['POST']['subscribe'];
+ $comment['url'] = $serendipity['POST']['url'];
+ $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_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config.inc.php,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- serendipity_config.inc.php 15 Aug 2003 23:04:36 -0000 1.22
+++ serendipity_config.inc.php 16 Aug 2003 11:05:48 -0000 1.23
@@ -51,6 +51,10 @@
$serendipity[$row['name']] = isset($translation[$row['value']]) ? $translation[$row['value']] : $row['value'];
}
+if ($serendipity['embed']) {
+ $serendipity['baseURL'] = 'http://' . $_SERVER['HTTP_HOST'] . $serendipity['serendipityHTTPPath'];
+}
+
// defaults for newly added configuration directives. Should be removed after first release.
if (!isset($serendipity['indexFile'])) {
$serendipity['indexFile'] = 'index.php';
@@ -151,11 +155,7 @@
$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.';
-
+$serendipity['signature'] = sprintf(SIGNATURE, $serendipity['blogTitle']);
/**
* Local Variables:
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- serendipity_functions.inc.php 15 Aug 2003 23:04:36 -0000 1.131
+++ serendipity_functions.inc.php 16 Aug 2003 11:05:48 -0000 1.132
@@ -162,19 +162,21 @@
</tr>
<tr>
<td> </td>
- <td class="serendipity_commentsLabel"><input type="checkbox" name="serendipity[remember]" <?php echo $serendipity['COOKIE']['remember'] ; ?> /> <?php echo REMEMBER_INFO; ?>
+ <td class="serendipity_commentsLabel">
+ <input type="checkbox" name="serendipity[remember]" <?php echo $serendipity['COOKIE']['remember'] ; ?> /> <?php echo REMEMBER_INFO; ?>
<?php
- if ( $serendipity['allowSubscriptions'] ) {
+ if ($serendipity['allowSubscriptions']) {
?>
- <br /><input type="checkbox" name="serendipity[subscribe]" /> Subscribe to this entry
+ <br />
+ <input type="checkbox" name="serendipity[subscribe]" /> <?php echo SUBSCRIBE_TO_THIS_ENTRY; ?>
<?php
}
?>
</td>
</tr>
- <tr>
+ <tr>
<td> </td>
- <td><input type="submit" value="<?php echo SUBMIT_COMMENT; ?>" /> </td>
+ <td><input type="submit" value="<?php echo SUBMIT_COMMENT; ?>" /></td>
</tr>
</table>
</form>
@@ -249,8 +251,20 @@
$endts = mktime(23, 59, 59, $month + 1, 1, $year);
+ // Get first and last entry
+ $minmax = serendipity_db_query("SELECT MAX(timestamp) AS max, MIN(timestamp) AS min FROM {$serendipity['dbPrefix']}entries");
+ if (!is_array($minmax) || !is_array($minmax[0]) || $minmax[0]['min'] < 1 || $minmax[0]['max'] < 1) {
+ // If no entry is available yet, allow scrolling a year back and forth
+ $minmax = array(
+ '0' => array(
+ 'min' => mktime(0, 0, 0, 1, 1, date('Y')-1),
+ 'max' => mktime(0, 0, 0, 1, 1, date('Y'+1))
+ )
+ );
+ }
+
// Find out about diary entries
- $querystring = "SELECT timestamp from $serendipity[dbPrefix]entries WHERE timestamp >= $ts and timestamp <= $endts";
+ $querystring = "SELECT timestamp from {$serendipity['dbPrefix']}entries WHERE timestamp >= $ts and timestamp <= $endts";
$rows = serendipity_db_query($querystring);
$activeDays = array();
if (is_array($rows)) {
@@ -269,14 +283,30 @@
<table width="100%" class="serendipity_calendar" cellspacing="1">
<tr>
<td align="left" class="serendipity_calendarHeader">
- <a title="<?php echo BACK; ?>" href="<?php echo $serendipity['serendipityHTTPPath'] . $serendipity['indexFile']; ?>?serendipity[calendarZoom]=<?php echo $previousYear . sprintf('%02d',$previousMonth); ?>"><img alt="<?php echo BACK; ?>" src="<?php echo serendipity_getTemplateFile('img/back.png'); ?>" border="0" /></a></td>
+<?php
+ // Only allow to scroll to the previous month if the first entry is from the month before
+ if ($ts > ($minmax[0]['min'] - 2678400)) {
+?>
+ <a title="<?php echo BACK; ?>" href="<?php echo $serendipity['serendipityHTTPPath'] . $serendipity['indexFile']; ?>?serendipity[calendarZoom]=<?php echo $previousYear . sprintf('%02d',$previousMonth); ?>"><img alt="<?php echo BACK; ?>" src="<?php echo serendipity_getTemplateFile('img/back.png'); ?>" border="0" /></a>
+<?php
+ }
+?>
+ </td>
<td colspan="5" align="center" valign="bottom" class="serendipity_calendarHeader">
<b><nobr><a href="<?php echo $link; ?>"><?php echo $serendipity["months"][$month] . ' \'' . substr($year, 2); ?></a></nobr></b>
</td>
<td align="right" class="serendipity_calendarHeader">
- <a title="<?php echo FORWARD; ?>" href="<?php echo $serendipity['serendipityHTTPPath'] . $serendipity['indexFile']; ?>?serendipity[calendarZoom]=<?php echo $nextYear . sprintf('%02d', $nextMonth); ?>"><img alt="<?php echo FORWARD; ?>" src="<?php echo serendipity_getTemplateFile('img/forward.png'); ?>" border="0" /></a></td>
+<?php
+ // Only allow to scroll to the next month if the last entry is from the month before
+ if ($endts < ($minmax[0]['max'] + 2678400)) {
+?>
+ <a title="<?php echo FORWARD; ?>" href="<?php echo $serendipity['serendipityHTTPPath'] . $serendipity['indexFile']; ?>?serendipity[calendarZoom]=<?php echo $nextYear . sprintf('%02d', $nextMonth); ?>"><img alt="<?php echo FORWARD; ?>" src="<?php echo serendipity_getTemplateFile('img/forward.png'); ?>" border="0" /></a>
+<?php
+ }
+?>
+ </td>
</tr>
<tr>
@@ -802,14 +832,14 @@
$url = serendipity_db_escape_string($commentInfo['url']);
$email = serendipity_db_escape_string($commentInfo['email']);
- if ( isset($commentInfo['subscribe']) ) {
+ 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, subscribed)";
+ $t = time();
+ $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);
@@ -824,60 +854,48 @@
AND e.authorid = a.authorid";
$row = serendipity_db_query($query, true);
- if($row['mail_comments']) {
+ if ($row['mail_comments']) {
serendipity_sendComment($row['email'], $name, $email, $url, $id, $row['title'], $comments, $type);
}
- if ( $serendipity['allowSubscriptions'] ) {
+
+ 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 .'"';
+ $subject = '[' . $serendipity['blogTitle'] . '] ' . sprintf(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'
+ AND email <> '$posterMail'
+ AND subscribed = 'true'
GROUP BY email";
$subscribers = serendipity_db_query($sql);
- if ( !is_array($subscribers) ) {
+ 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";
+ foreach ($subscribers as $subscriber) {
+ $text = sprintf(
+ SUBSCRIPTION_MAIL,
+
+ $subscriber['author'],
+ $serendipity['blogTitle'],
+ $title,
+ $poster,
+ $entryURI
+ );
- mail($subscriber['email'], $subject, $text.$serendipity['signature'], "From: {$serendipity['blogTitle']} <$fromEmail>\r\n");
- }
-
-}
-
-/**
-* Adds a comment
-**/
-function serendipity_addComment($entry, $id) {
- global $serendipity;
-
- $querystring = "INSERT INTO ".$serendipity["dbPrefix"]."comments VALUES ".
- "VALUES (NULL, $id, ".time().", '".strip_tags($entry["author"])."', ".
- "'".strip_tags($entry["email"])."', '".strip_tags($entry["url"])."', '$REMOTE_ADDR', ".
- "'".strip_tags($entry["body"])."')";
- serendipity_db_query($querystring);
- serendipity_db_query("UPDATE ".$serendipity["dbPrefix"]." SET comments=comments+1 WHERE id LIKE $id");
+ mail($subscriber['email'], $subject, $text . $serendipity['signature'], "From: {$serendipity['blogTitle']} <$fromEmail>\r\n");
+ }
}
function serendipity_sendComment($to, $fromName, $fromEmail, $fromUrl, $id, $title, $comment, $type = 'NORMAL') {
@@ -909,7 +927,7 @@
. "\n" . strip_tags($comment);
}
- return mail($to, $subject, $text.$serendipity['signature'], "From: {$serendipity['blogTitle']} <$fromEmail>\r\n");
+ return mail($to, $subject, $text . $serendipity['signature'], "From: {$serendipity['blogTitle']} <$fromEmail>\r\n");
}
function serendipity_fetchReferences($id)
Index: serendipity_lang_de.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_lang_de.inc.php,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- serendipity_lang_de.inc.php 10 Aug 2003 22:23:45 -0000 1.21
+++ serendipity_lang_de.inc.php 16 Aug 2003 11:05:48 -0000 1.22
@@ -245,6 +245,10 @@
define('RUNNING', 'Sie benutzen serendipity v.');
define('TOGGLE_ALL', 'Alle Optionen ein-/ausblenden');
define('TOGGLE_OPTION', 'Option ein-/ausblenden');
+define('SUBSCRIBE_TO_THIS_ENTRY', 'Bei Aktualisierung dieser Kommentare benachrichtigen');
+define('NEW_COMMENT_TO_SUBSCRIBED_ENTRY', 'Benachrichtigung zu neuem Kommentar des Eintrags "%s"');
+define('SUBSCRIPTION_MAIL', "Hallo %s,\n\nEin neues Kommentar wurde dem Eintrag hinzugefügt, den Sie auf \"%s\" namens \"%s\" finden.\nDer Name des Autoren ist: %s\n\nSie können den Eintrag hier finden: %s\n");
+define('SIGNATURE', "\n-- \n%s wird betrieben mit Serendipity.\nDas allerbeste blog, Sie können es auch nutzen.\nWie das geht, sehen Sie auf <http://s9y.org>.");
define('serendipity_LANG_LOADED', true);
/* vim: set sts=4 ts=4 expandtab : */
Index: serendipity_lang_en.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_lang_en.inc.php,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- serendipity_lang_en.inc.php 13 Aug 2003 17:12:48 -0000 1.29
+++ serendipity_lang_en.inc.php 16 Aug 2003 11:05:48 -0000 1.30
@@ -246,6 +246,11 @@
define('TOGGLE_ALL', 'Toggle expand all');
define('TOGGLE_OPTION', 'Toggle option');
+define('SUBSCRIBE_TO_THIS_ENTRY', 'Subscribe to this entry');
+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\"\nThe name of the poster is: %s\n\nYou can find the entry here: %s\n");
+define('SIGNATURE', "\n-- \n%s is powered by Serendipity.\nThe best blog around, you can use it too.\nCheck out <http://s9y.org> to find out how.");
+
define('serendipity_LANG_LOADED', true);
/* vim: set sts=4 ts=4 expandtab : */
?>
Index: db.sql
===================================================================
RCS file: /cvsroot/php-blog/serendipity/db.sql,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- db.sql 5 Aug 2003 14:32:35 -0000 1.20
+++ db.sql 16 Aug 2003 11:05:48 -0000 1.21
@@ -25,7 +25,8 @@
url varchar(200) default null,
ip varchar(15) default null,
body text,
- type varchar(100) default 'regular'
+ type varchar(100) default 'regular',
+ subscribed enum('true', 'false') not null default 'false'
);
CREATE {FULLTEXT} INDEX body on {PREFIX}comments (body);
|