[geeklog-cvs] geeklog: Send a notification when a comment goes into the submis...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Aug 16 13:44:54 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/e6b9b651bbce
changeset: 7253:e6b9b651bbce
user:      Dirk Haun <dirk at haun-online.de>
date:      Sun Aug 16 17:55:44 2009 +0200
description:
Send a notification when a comment goes into the submission queue

diffstat:

 public_html/docs/history |   1 +
 system/lib-comment.php   |  33 +++++++++++++++++++++------------
 2 files changed, 22 insertions(+), 12 deletions(-)

diffs (88 lines):

diff -r abaeea30d843 -r e6b9b651bbce public_html/docs/history
--- a/public_html/docs/history	Sun Aug 09 20:30:15 2009 +0200
+++ b/public_html/docs/history	Sun Aug 16 17:55:44 2009 +0200
@@ -3,6 +3,7 @@
 ??? ??, 2009 (1.6.1)
 ------------
 
+- Send a notification when a comment goes into the submission queue [Dirk]
 - Added a link back to the story to the "Mail Story to a Friend" form [Dirk]
 - Only list [code], [raw] tags when story.* permissions are required [Dirk]
 - [page_break] was not listed when all HTML was allowed for Root users [Dirk]
diff -r abaeea30d843 -r e6b9b651bbce system/lib-comment.php
--- a/system/lib-comment.php	Sun Aug 09 20:30:15 2009 +0200
+++ b/system/lib-comment.php	Sun Aug 16 17:55:44 2009 +0200
@@ -1042,10 +1042,10 @@
  * @param    int         $pid        ID of parent comment
  * @param    string      $type       Type of comment this is (article, polls, etc)
  * @param    string      $postmode   Indicates if text is HTML or plain text
- * @return   int         0 for success, > 0 indicates error
+ * @return   int         -1 == queued, 0 == comment saved, > 0 indicates error
  *
  */
-function CMT_saveComment ($title, $comment, $sid, $pid, $type, $postmode)
+function CMT_saveComment($title, $comment, $sid, $pid, $type, $postmode)
 {
     global $_CONF, $_TABLES, $_USER, $LANG03;
 
@@ -1133,7 +1133,7 @@
                     "'$sid',$uid,'$comment',NOW(),'$title',$pid,'{$_SERVER['REMOTE_ADDR']}','$type'");
         }
 
-        $ret = -1;
+        $ret = -1; // comment queued
     } elseif ($pid > 0) {
         DB_lockTable ($_TABLES['comments']);
         
@@ -1200,11 +1200,15 @@
         }
     }
 
-    // Send notification of comment if no errors and notications enabled for comments
-    if (($ret == 0) && isset ($_CONF['notification']) &&
-            in_array ('comment', $_CONF['notification'])) {
-        CMT_sendNotification ($title, $comment, $uid, $_SERVER['REMOTE_ADDR'],
-                          $type, $cid);
+    // Send notification of comment if no errors and notifications enabled
+    // for comments
+    if ((($ret == -1) || ($ret == 0)) && isset($_CONF['notification']) &&
+            in_array('comment', $_CONF['notification'])) {
+        if ($ret == -1) {
+            $cid = 0; // comment went into the submission queue
+        }
+        CMT_sendNotification($title, $comment, $uid, $_SERVER['REMOTE_ADDR'],
+                             $type, $cid);
     }
     
     return $ret;
@@ -1218,12 +1222,12 @@
 * @param    $uid        int         user id
 * @param    $ipaddress  string      poster's IP address
 * @param    $type       string      type of comment ('article', 'poll', ...)
-* @param    $cid        int         comment id
+* @param    $cid        int         comment id (or 0 when in submission queue)
 *
 */
 function CMT_sendNotification ($title, $comment, $uid, $ipaddress, $type, $cid)
 {
-    global $_CONF, $_TABLES, $LANG03, $LANG08, $LANG09;
+    global $_CONF, $_TABLES, $LANG01, $LANG03, $LANG08, $LANG09;
 
     // we have to undo the addslashes() call from savecomment()
     $title = stripslashes ($title);
@@ -1255,8 +1259,13 @@
         $mailbody .= $comment . "\n\n";
     }
 
-    $mailbody .= $LANG08[33] . ' <' . $_CONF['site_url']
-              . '/comment.php?mode=view&cid=' . $cid . ">\n\n";
+    if ($cid == 0) {
+        $mailbody .= $LANG01[10] . ' <' . $_CONF['site_admin_url']
+                  . "/moderation.php>\n\n";
+    } else {
+        $mailbody .= $LANG08[33] . ' <' . $_CONF['site_url']
+                  . '/comment.php?mode=view&cid=' . $cid . ">\n\n";
+    }
 
     $mailbody .= "\n------------------------------\n";
     $mailbody .= "\n$LANG08[34]\n";



More information about the geeklog-cvs mailing list