[geeklog-hg] geeklog: Directory now shows inherited articles properly when a ...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Wed Jul 17 22:16:57 EDT 2013
changeset 9210:4660637cc082
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/4660637cc082
user: Tom <websitemaster at cogeco.net>
date: Wed Jul 17 22:09:02 2013 -0400
description:
Directory now shows inherited articles properly when a topic is selected in the drop down for both year (the total number) and month (article links) (bug #0001661)
diffstat:
public_html/directory.php | 57 +++++++++++++++++++++++-----------------------
1 files changed, 29 insertions(+), 28 deletions(-)
diffs (83 lines):
diff -r 6d7c7c535705 -r 4660637cc082 public_html/directory.php
--- a/public_html/directory.php Wed Jul 17 21:45:00 2013 -0400
+++ b/public_html/directory.php Wed Jul 17 22:09:02 2013 -0400
@@ -244,7 +244,7 @@
$start = sprintf('%04d-%02d-01 00:00:00', $year, $month);
$lastday = DIR_lastDayOfMonth($month, $year);
$end = sprintf('%04d-%02d-%02d 23:59:59', $year, $month, $lastday);
-
+
$sql = array();
$sql['mysql'] = "SELECT sid,title,UNIX_TIMESTAMP(date) AS day,DATE_FORMAT(date, '%e') AS mday
FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta
@@ -259,16 +259,19 @@
AND ta.type = 'article' AND ta.id = sid ";
if ($dir_topic != 'all') {
- $sql['mysql'] .= " AND ta.tid = '$dir_topic'";
- $sql['mssql'] = $sql['mysql'];
- $sql['pgsql'] .= " AND ta.tid = '$dir_topic'";
+ // Retrieve list of inherited topics
+ $tid_list = TOPIC_getChildList($dir_topic);
+ $sql['mysql'] .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$dir_topic}')))";
+ $sql['mssql'] .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$dir_topic}')))";
+ $sql['pgsql'] .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$dir_topic}')))";
+ } else {
+ $sql['mysql'] .= COM_getTopicSql('AND', 0, 'ta');
+ $sql['mssql'] .= COM_getTopicSql('AND', 0, 'ta');
+ $sql['pgsql'] .= COM_getTopicSql('AND', 0, 'ta');
}
- $sql['mysql'] .= COM_getTopicSql('AND', 0, 'ta') . COM_getPermSql('AND')
- . COM_getLangSQL('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
- $sql['mssql'] .= COM_getTopicSql('AND', 0, 'ta') . COM_getPermSql('AND')
- . COM_getLangSQL('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
- $sql['pgsql'] .= COM_getTopicSql('AND', 0, 'ta') . COM_getPermSql('AND')
- . COM_getLangSQL('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
+ $sql['mysql'] .= COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
+ $sql['mssql'] .= COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
+ $sql['pgsql'] .= COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
$result = DB_query($sql);
$numrows = DB_numRows($result);
@@ -357,25 +360,23 @@
FROM {$_TABLES['stories']} , {$_TABLES['topic_assignments']} ta
WHERE (date >= '$start') AND (date <= '$end') AND (draft_flag = 0) AND (date <= NOW())
AND ta.type = 'article' AND ta.id = sid ";
+
+ if ($dir_topic != 'all') {
+ // Retrieve list of inherited topics
+ $tid_list = TOPIC_getChildList($dir_topic);
+ $monthsql['mysql'] .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$dir_topic}')))";
+ $monthsql['mssql'] .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$dir_topic}')))";
+ $monthsql['pgsql'] .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$dir_topic}')))";
+ } else {
+ $monthsql['mysql'] .= COM_getTopicSql('AND', 0, 'ta');
+ $monthsql['mssql'] .= COM_getTopicSql('AND', 0, 'ta');
+ $monthsql['pgsql'] .= COM_getTopicSql('AND', 0, 'ta');
+ }
+ $monthsql['mysql'] .= COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND') . " GROUP BY MONTH(date) ORDER BY date ASC";
+ $monthsql['mssql'] .= COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND') . " GROUP BY MONTH(date) ORDER BY month(date) ASC";
+ $monthsql['pgsql'] .= COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND') . " GROUP BY month,date ORDER BY DATE ASC";
- if ($dir_topic != 'all') {
- $monthsql['mysql'] .= " AND ta.tid = '$dir_topic'";
- $monthsql['mssql'] .= " AND ta.tid = '$dir_topic'";
- $monthsql['pgsql'] .= " AND ta.tid = '$dir_topic'";
- }
- $monthsql['mysql'] .= COM_getTopicSql('AND', 0, 'ta') . COM_getPermSql('AND')
- . COM_getLangSQL('sid', 'AND');
- $monthsql['mssql'] .= COM_getTopicSql('AND', 0, 'ta') . COM_getPermSql('AND')
- . COM_getLangSQL('sid', 'AND');
- $monthsql['pgsql'] .= COM_getTopicSql('AND', 0, 'ta') . COM_getPermSql('AND')
- . COM_getLangSQL('sid', 'AND');
-
- $msql = array();
- $msql['mysql'] = $monthsql['mysql'] . " GROUP BY MONTH(date) ORDER BY date ASC";
- $msql['mssql'] = $monthsql['mssql'] . " GROUP BY MONTH(date) ORDER BY month(date) ASC";
- $msql['pgsql'] = $monthsql['pgsql'] . " GROUP BY month,date ORDER BY DATE ASC";
-
- $mresult = DB_query($msql);
+ $mresult = DB_query($monthsql);
$nummonths = DB_numRows($mresult);
if ($nummonths > 0) {
More information about the geeklog-cvs
mailing list