X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FSearch.php;h=316e41c250564f632e5d2eb85e940c3a9bd44ee7;hb=f23ecaff6af1982112469f90d6bcdf0408b0f22e;hp=ca8960ef35bc6ec2437a0cc078ceffca441a89a6;hpb=70e5639e2973662705b44e643ac46ce68dd6dade;p=friendica.git diff --git a/src/Model/Search.php b/src/Model/Search.php index ca8960ef35..316e41c250 100644 --- a/src/Model/Search.php +++ b/src/Model/Search.php @@ -1,6 +1,6 @@ ?", 0]; - $tags = []; + $abandon_days = intval(DI::config()->get('system', 'account_abandon_days')); + if (!empty($abandon_days)) { + $user_condition = DBA::mergeConditions($user_condition, ["`last-activity` > ?", DateTimeFormat::utc('now - ' . $abandon_days . ' days')]); + } + $condition = $user_condition; + $condition[0] = "SELECT DISTINCT(`term`) FROM `search` INNER JOIN `user` ON `search`.`uid` = `user`.`uid` WHERE " . $user_condition[0]; + $sql = array_shift($condition); + $termsStmt = DBA::p($sql, $condition); + + $tags = []; while ($term = DBA::fetch($termsStmt)) { - $tags[] = trim($term['term'], '#'); + $tags[] = trim(mb_strtolower($term['term']), '#'); } DBA::close($termsStmt); + + $condition = $user_condition; + $condition[0] = "SELECT `include-tags` FROM `channel` INNER JOIN `user` ON `channel`.`uid` = `user`.`uid` WHERE " . $user_condition[0]; + $sql = array_shift($condition); + $channels = DBA::p($sql, $condition); + while ($channel = DBA::fetch($channels)) { + foreach (explode(',', $channel['include-tags']) as $tag) { + $tag = trim(mb_strtolower($tag)); + if (empty($tag)) { + continue; + } + if (!in_array($tag, $tags)) { + $tags[] = $tag; + } + } + } + DBA::close($channels); + + sort($tags); + return $tags; } }