}
}
+ /**
+ * Fetch the blocked tags as SQL
+ *
+ * @return string
+ */
+ private static function getBlockedSQL()
+ {
+ $blocked_txt = DI::config()->get('system', 'blocked_tags');
+ if (empty($blocked_txt)) {
+ return '';
+ }
+
+ $blocked = explode(',', $blocked_txt);
+ array_walk($blocked, function(&$value) { $value = "'" . DBA::escape(trim($value)) . "'";});
+ return " AND NOT `name` IN (" . implode(',', $blocked) . ")";
+ }
+
/**
* Creates a list of the most frequent global hashtags over the given period
*
*/
public static function setGlobalTrendingHashtags(int $period, int $limit = 10)
{
+ $block_sql = self::getBlockedSQL();
+
$tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score`
FROM `tag-search-view`
- WHERE `private` = ? AND `uid` = ? AND `received` > DATE_SUB(NOW(), INTERVAL ? HOUR)
+ WHERE `private` = ? AND `uid` = ? AND `received` > DATE_SUB(NOW(), INTERVAL ? HOUR) $block_sql
GROUP BY `term` ORDER BY `score` DESC LIMIT ?",
Item::PUBLIC, 0, $period, $limit);
*/
public static function setLocalTrendingHashtags(int $period, int $limit = 10)
{
+ $block_sql = self::getBlockedSQL();
+
$tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score`
FROM `tag-search-view`
- WHERE `private` = ? AND `wall` AND `origin` AND `received` > DATE_SUB(NOW(), INTERVAL ? HOUR)
+ WHERE `private` = ? AND `wall` AND `origin` AND `received` > DATE_SUB(NOW(), INTERVAL ? HOUR) $block_sql
GROUP BY `term` ORDER BY `score` DESC LIMIT ?",
Item::PUBLIC, $period, $limit);
// Deny public access to the local user directory.
'block_local_dir' => false,
+ // blocked_tags (String)
+ // Comma separated list of hash tags that shouldn't be displayed in the trending tags
+ 'blocked_tags' => '',
+
// community_no_sharer (Boolean)
// Don't display sharing accounts on the global community
'community_no_sharer' => false,