Skip to content

Commit

Permalink
Fixed issues with plugin_getiteminfo_story
Browse files Browse the repository at this point in the history
Fixed plugin_getiteminfo_story not filtering when story Id is specified (would only filter by date and topics if * passed)
Also fixed date passed to sql database for filters.

For issue #1050
  • Loading branch information
eSilverStrike committed Feb 7, 2022
1 parent f1a5ede commit d6e898c
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions system/lib-article.php
Original file line number Diff line number Diff line change
Expand Up @@ -1398,19 +1398,28 @@ function plugin_getiteminfo_story($sid, $what, $uid = 0, $options = array())
$groupBySQL = '';
$filter_flag = false;
if ($sid === '*') {
// Check options to see if filters enabled
if (isset($options['filter']['date-created'])) {
$filter_flag = true;
$where .= " AND (date >= '" . date('c', $options['filter']['date-created']) . "')";
}
if (isset($options['filter']['topic-ids']) && !empty($options['filter']['topic-ids'])) {
$filter_flag = true;
$where .= " AND (ta.tid IN (" . $options['filter']['topic-ids'] . "))";
}

} else {
$where .= " AND (sid = '" . DB_escapeString($sid) . "')";
}

// *********************************
// Moved out of $sid === '*' if statement above since XML Sitemap needs to filter even when it knows an ID
// Assuming this doesn't mess anything else up??? See issue #1050

// Check options to see if filters enabled
if (isset($options['filter']['date-created'])) {
$filter_flag = true;
// $where .= " AND (date >= '" . date('c', $options['filter']['date-created']) . "')";
$where .= " AND (date >= '" . date('Y-m-d H:i:s', $options['filter']['date-created']) . "')";
}

if (isset($options['filter']['topic-ids']) && !empty($options['filter']['topic-ids'])) {
$filter_flag = true;
$where .= " AND (ta.tid IN (" . $options['filter']['topic-ids'] . "))";
}
// *********************************************

if (!SEC_hasRights('story.edit', 'AND', $uid)) {
$where .= ' AND (draft_flag = 0) AND (date <= NOW())';
}
Expand Down

0 comments on commit d6e898c

Please sign in to comment.