From 4aead9d3eb869fc2ecfb0744b587de3fe6057c38 Mon Sep 17 00:00:00 2001 From: Tom Homer Date: Sat, 1 Dec 2018 11:09:50 -0500 Subject: [PATCH] Updated PLG_getItemInfo to make use of options array for filtering items Options array not can include filters based on topics and created date for when returning multiple items. Articles supports this new feature. --- system/lib-article.php | 10 ++++------ system/lib-plugins.php | 5 ++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/system/lib-article.php b/system/lib-article.php index dd92bf38e..17174cfdf 100644 --- a/system/lib-article.php +++ b/system/lib-article.php @@ -1203,14 +1203,12 @@ function plugin_getiteminfo_story($sid, $what, $uid = 0, $options = array()) // Check options to see if filters enabled if (isset($options['filter']['date-created'])) { - //AND (date - - - + $filter_flag = true; + $where .= " (date >= '" . date('c', $options['filter']['date-created']) . "') AND"; } if (isset($options['filter']['topic-ids']) && !empty($options['filter']['topic-ids'])) { $filter_flag = true; - $where = " WHERE (ta.tid IN (" . $options['filter']['topic-ids'] . ")) AND"; + $where .= " (ta.tid IN (" . $options['filter']['topic-ids'] . ")) AND"; } } else { $where = " WHERE (sid = '" . DB_escapeString($sid) . "') AND"; @@ -1235,7 +1233,7 @@ function plugin_getiteminfo_story($sid, $what, $uid = 0, $options = array()) if ($sid != '*') { $sql .= ' LIMIT 1'; } -COM_errorLog($sql); + $result = DB_query($sql); $numRows = DB_numRows($result); diff --git a/system/lib-plugins.php b/system/lib-plugins.php index 9c2c4facc..627950420 100644 --- a/system/lib-plugins.php +++ b/system/lib-plugins.php @@ -2331,7 +2331,10 @@ function PLG_spamAction($content, $action = -1) * @param string $id ID of an item under the plugin's control or '*' * @param string $what comma-separated list of item properties * @param int $uid user ID or 0 = current user - * @param array $options (reserved for future extensions) + * @param array $options not required and may not be supported. + * string $options['filter'] Filters work only for returning multiple items (using *). Allows filtering based on different supported properties. Unsupported filters are ignored + * string $options['filter']['topic-ids'] Comma separated list of topic ids in single quotes to be used in a sql statement ie: 'topicid1','topicid2' + * string $options['filter']['date-created'] Returns items created from this Unix timestamp till current date * @return mixed string or array of strings with the information * @link http://wiki.geeklog.net/index.php/PLG_getItemInfo */