[geeklog-cvs] geeklog: Updated polls PLG_getWhatsNewComment function to work w...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Tue Mar 16 15:20:23 EDT 2010


changeset 7799:3c38c64c3ced
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/3c38c64c3ced
user: Tom <websitemaster at cogeco.net>
date: Tue Mar 16 14:54:49 2010 -0400
description:
Updated polls PLG_getWhatsNewComment function to work with User Profile page.

diffstat:

 plugins/polls/functions.inc |  24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diffs (39 lines):

diff -r a4240b2a68c4 -r 3c38c64c3ced plugins/polls/functions.inc
--- a/plugins/polls/functions.inc	Tue Mar 16 14:53:55 2010 -0400
+++ b/plugins/polls/functions.inc	Tue Mar 16 14:54:49 2010 -0400
@@ -1575,18 +1575,28 @@
 /**
 * Return new Polls comments for the What's New block
 *
-* @return   array list of new poll comments (dups, type, title, sid, lastdate)
+* @param    string  $numreturn  If 0 will return results for What's New Block. 
+*                               If > 0 will return last X new comments for User Profile.
+* @param    string  $uid        ID of the user to return results for. 0 = all users.
+* @return   array list of new comments (dups, type, title, sid, lastdate) or (sid, title, cid, unixdate)
 *
 */
-function plugin_getwhatsnewcomment_polls()
+function plugin_getwhatsnewcomment_polls($numreturn = 0, $uid = 0)
 {
     global $_CONF, $_TABLES;
 
-    // Comments
-    $sql['mysql'] = "SELECT DISTINCT COUNT(*) AS dups, type, title, sid, max(date) AS lastdate FROM {$_TABLES['comments']}, {$_TABLES['polltopics']} pt"
-        . " WHERE (pt.pid = sid)" . COM_getPermSQL('AND', 0, 2, 'pt')
-        . " AND (date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newcommentsinterval']} SECOND))) GROUP BY sid,type, title, sid ORDER BY 5 DESC LIMIT 15";
-  
+    if ($uid > 0) {
+        $stwhere = " AND ({$_TABLES['comments']}.uid = $uid)";
+    }    
+    if ($numreturn == 0 ) {
+        $sql['mysql'] = "SELECT DISTINCT COUNT(*) AS dups, type, title, sid, max(date) AS lastdate FROM {$_TABLES['comments']}, {$_TABLES['polltopics']} pt"
+        . " WHERE (pt.pid = sid) AND (pt.commentcode >= 0)" . COM_getPermSQL('AND', 0, 2, 'pt')
+            . " AND (date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newcommentsinterval']} SECOND))) GROUP BY sid,type, title, sid ORDER BY 5 DESC LIMIT 15";
+    } else {
+        $sql['mysql'] = "SELECT {$_TABLES['comments']}.sid, pt.topic title, cid, UNIX_TIMESTAMP({$_TABLES['comments']}.date) AS unixdate FROM {$_TABLES['comments']}, {$_TABLES['polltopics']} pt"
+            . " WHERE (pt.pid = sid) AND (pt.commentcode >= 0)" . COM_getPermSQL('AND', 0, 2, 'pt')
+            . "{$stwhere} ORDER BY unixdate DESC LIMIT $numreturn";
+    }
     $result = DB_query($sql);
     $nrows = DB_numRows($result);
     if ($nrows > 0) {



More information about the geeklog-cvs mailing list