123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- defined('GNUSOCIAL') || die();
- class FeaturedUsersSection extends ProfileSection
- {
- public function show()
- {
- $featured_nicks = common_config('nickname', 'featured');
- if (empty($featured_nicks)) {
- return;
- }
- parent::show();
- }
- public function getProfiles()
- {
- $featured_nicks = common_config('nickname', 'featured');
- if (!$featured_nicks) {
- return null;
- }
- $quoted_nicks = implode(
- ',',
- array_map(
- function (string $nick): string {
- return "'{$nick}'";
- },
- $featured_nicks
- )
- );
- $user_table = common_database_tablename('user');
- $limit = PROFILES_PER_SECTION + 1;
- $qry = <<<END
- SELECT profile.*
- FROM profile
- INNER JOIN {$user_table} ON profile.id = {$user_table}.id
- WHERE profile.nickname IN ({$quoted_nicks})
- ORDER BY profile.created DESC, profile.id DESC
- LIMIT {$limit};
- END;
- $profile = Memcached_DataObject::cachedQuery('Profile', $qry, 6 * 3600);
- return $profile;
- }
- public function title()
- {
- // TRANS: Title for featured users section.
- return _('Featured users');
- }
- public function divId()
- {
- return 'featured_users';
- }
- public function moreUrl()
- {
- return common_local_url('featured');
- }
- }
|