[geeklog-cvs] geeklog: Fixed COM_featuredCheck bug which did not check to make...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Apr 5 12:44:54 EDT 2010
changeset 7876:d2621bed7585
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/d2621bed7585
user: Tom <websitemaster at cogeco.net>
date: Mon Apr 05 12:40:18 2010 -0400
description:
Fixed COM_featuredCheck bug which did not check to make sure there is only 1 front page featured story
Fixed COM_featuredCheck to unfeature more than one story if need be (ie if there is more than 2 featured stories in the same topic which go live at the same time in the future)
diffstat:
public_html/lib-common.php | 37 ++++++++++++++++++++++++-------------
1 files changed, 24 insertions(+), 13 deletions(-)
diffs (49 lines):
diff -r d2aa069815b2 -r d2621bed7585 public_html/lib-common.php
--- a/public_html/lib-common.php Mon Apr 05 12:35:29 2010 -0400
+++ b/public_html/lib-common.php Mon Apr 05 12:40:18 2010 -0400
@@ -1951,21 +1951,32 @@
{
global $_TABLES;
- $curdate = date( "Y-m-d H:i:s", time() );
-
+ // Look for multiple featured frontpage articles. If more than one pick the newest.
+ $sql = "SELECT sid FROM {$_TABLES['stories']} WHERE featured = 1 AND draft_flag = 0 AND frontpage = 1 AND date <= NOW() ORDER BY date DESC LIMIT 2";
+ $resultB = DB_query($sql);
+ $numB = DB_numRows($resultB);
+ if ($numB > 1) {
+ $B = DB_fetchArray($resultB);
+ // un-feature all other featured frontpage story
+ $sql = "UPDATE {$_TABLES['stories']} SET featured = 0 WHERE featured = 1 AND draft_flag = 0 AND frontpage = 1 AND date <= NOW() AND sid NOT '{$B['sid']}'";
+ DB_query($sql);
+ }
+
// Loop through each topic
$sql = "SELECT tid FROM {$_TABLES['topics']}" . COM_getPermSQL();
- $result = DB_query( $sql );
- $num = DB_numRows( $result );
- for( $i = 0; $i < $num; $i++)
- {
- $A = DB_fetchArray( $result );
-
- if( DB_getItem( $_TABLES['stories'], 'COUNT(*)', "featured = 1 AND draft_flag = 0 AND tid = '{$A['tid']}' AND date <= '$curdate'" ) > 1 )
- {
- // OK, we have two featured stories in a topic, fix that
- $sid = DB_getItem( $_TABLES['stories'], 'sid', "featured = 1 AND draft_flag = 0 ORDER BY date LIMIT 1" );
- DB_query( "UPDATE {$_TABLES['stories']} SET featured = 0 WHERE sid = '$sid'" );
+ $result = DB_query($sql);
+ $num = DB_numRows($result);
+ for($i = 0; $i < $num; $i++) {
+ $A = DB_fetchArray($result);
+
+ $sql = "SELECT sid FROM {$_TABLES['stories']} WHERE featured = 1 AND draft_flag = 0 AND tid = '{$A['tid']}' AND date <= NOW() ORDER BY date DESC LIMIT 2";
+ $resultB = DB_query($sql);
+ $numB = DB_numRows($resultB);
+ if ($numB > 1) {
+ // OK, we have two or more featured stories in a topic, fix that
+ $B = DB_fetchArray($resultB);
+ $sql = "UPDATE {$_TABLES['stories']} SET featured = 0 WHERE featured = 1 AND draft_flag = 0 AND tid = '{$A['tid']}' AND date <= NOW() AND sid NOT '{$B['sid']}'";
+ DB_query($sql);
}
}
}
More information about the geeklog-cvs
mailing list