[geeklog-cvs] geeklog: One featured story per topic is now allowed, with only ...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Sep 27 12:21:41 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/37fa7ba6f86e
changeset: 7339:37fa7ba6f86e
user: Tom <websitemaster at cogeco.net>
date: Sat Sep 26 11:07:25 2009 -0400
description:
One featured story per topic is now allowed, with only one being able to be displayed as featured on the frontpage.
diffstat:
public_html/lib-common.php | 20 ++++++++++++++------
system/classes/story.class.php | 14 ++++++++------
2 files changed, 22 insertions(+), 12 deletions(-)
diffs (58 lines):
diff -r c71c0bedca65 -r 37fa7ba6f86e public_html/lib-common.php
--- a/public_html/lib-common.php Sun Sep 27 09:56:06 2009 +0200
+++ b/public_html/lib-common.php Sat Sep 26 11:07:25 2009 -0400
@@ -1950,12 +1950,20 @@
$curdate = date( "Y-m-d H:i:s", time() );
- if( DB_getItem( $_TABLES['stories'], 'COUNT(*)', "featured = 1 AND draft_flag = 0 AND date <= '$curdate'" ) > 1 )
- {
- // OK, we have two featured stories, 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'" );
+ // Loop through each topic
+ $sql = "SELECT tid FROM {$_TABLES['topics']}";
+ $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'" );
+ }
}
}
diff -r c71c0bedca65 -r 37fa7ba6f86e system/classes/story.class.php
--- a/system/classes/story.class.php Sun Sep 27 09:56:06 2009 +0200
+++ b/system/classes/story.class.php Sat Sep 26 11:07:25 2009 -0400
@@ -608,16 +608,18 @@
}
/* if a featured, non-draft, that goes live straight away, unfeature
- * other stories:
+ * other stories in same topic:
*/
if ($this->_featured == '1') {
// there can only be one non-draft featured story
if ($this->_draft_flag == 0 AND $this->_date <= time()) {
- $id[1] = 'featured';
- $values[1] = 1;
- $id[2] = 'draft_flag';
- $values[2] = 0;
- DB_change($_TABLES['stories'], 'featured', '0', $id, $values);
+ if ($this->_frontpage == 1) {
+ // un-feature any featured frontpage story
+ DB_query("UPDATE {$_TABLES['stories']} SET featured = 0 WHERE featured = 1 AND draft_flag = 0 AND frontpage = 1 AND date <= NOW()");
+ }
+
+ // un-feature any featured story in the same topic
+ DB_query("UPDATE {$_TABLES['stories']} SET featured = 0 WHERE featured = 1 AND draft_flag = 0 AND tid = '{$this->_tid}' AND date <= NOW()");
}
}
More information about the geeklog-cvs
mailing list