[geeklog-cvs] geeklog: Updated staticpage PLG_getWhatsNewComment function to w...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Tue Mar 16 15:20:24 EDT 2010
changeset 7800:3b102042f8d1
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/3b102042f8d1
user: Tom <websitemaster at cogeco.net>
date: Tue Mar 16 14:55:16 2010 -0400
description:
Updated staticpage PLG_getWhatsNewComment function to work with User Profile page.
diffstat:
plugins/staticpages/functions.inc | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diffs (38 lines):
diff -r 3c38c64c3ced -r 3b102042f8d1 plugins/staticpages/functions.inc
--- a/plugins/staticpages/functions.inc Tue Mar 16 14:54:49 2010 -0400
+++ b/plugins/staticpages/functions.inc Tue Mar 16 14:55:16 2010 -0400
@@ -1558,17 +1558,28 @@
/**
* Return new Static Page comments for the What's New block
*
-* @return array list of new staticpage 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_staticpages()
+function plugin_getwhatsnewcomment_staticpages($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['staticpage']} sp"
- . " WHERE (sp.sp_id = sid) AND (sp.draft_flag = 0)" . COM_getPermSQL('AND', 0, 2, 'sp')
- . " 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['staticpage']} sp"
+ . " WHERE (sp.sp_id = sid) AND (sp.commentcode >= 0) AND (sp.draft_flag = 0)" . COM_getPermSQL('AND', 0, 2, 'sp')
+ . " 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, sp.sp_title title, cid, UNIX_TIMESTAMP({$_TABLES['comments']}.date) AS unixdate FROM {$_TABLES['comments']}, {$_TABLES['staticpage']} sp"
+ . " WHERE (sp.sp_id = sid) AND (sp.commentcode >= 0) AND (sp.draft_flag = 0)" . COM_getPermSQL('AND', 0, 2, 'sp')
+ . "{$stwhere} ORDER BY unixdate DESC LIMIT $numreturn";
+ }
$result = DB_query($sql);
$nrows = DB_numRows($result);
More information about the geeklog-cvs
mailing list