Skip to content

Commit

Permalink
Updated PLG_getItemInfo to make use of options array for filtering items
Browse files Browse the repository at this point in the history
Options array not can include filters based on topics and created date for when returning multiple items. Articles supports this new feature.
  • Loading branch information
eSilverStrike committed Dec 1, 2018
1 parent 347f0ed commit 4aead9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 4 additions & 6 deletions system/lib-article.php
Expand Up @@ -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";
Expand All @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion system/lib-plugins.php
Expand Up @@ -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
*/
Expand Down

0 comments on commit 4aead9d

Please sign in to comment.