123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- defined('GNUSOCIAL') || die();
- class GroupFavoritedAction extends ShowgroupAction
- {
-
- public function title()
- {
- $base = $this->group->getFancyName();
- if ($this->page == 1) {
-
- return sprintf(_m('Popular posts in %s group'), $base);
- } else {
-
- return sprintf(
- _m('Popular posts in %1$s group, page %2$d'),
- $base,
- $this->page
- );
- }
- }
-
- public function showContent()
- {
- $groupId = (int)$this->group->id;
- $weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff'));
- $cutoff = sprintf(
- "fave.modified > CURRENT_TIMESTAMP - INTERVAL '%d' SECOND",
- common_config('popular', 'cutoff')
- );
- $offset = ($this->page - 1) * NOTICES_PER_PAGE;
- $limit = NOTICES_PER_PAGE + 1;
- $qry = <<<END
- SELECT *
- FROM notice INNER JOIN (
- SELECT notice_id AS id, {$weightexpr} AS weight
- FROM fave
- INNER JOIN group_inbox USING (notice_id)
- WHERE {$cutoff} AND group_inbox.group_id = {$groupId}
- GROUP BY notice_id
- ) AS t1 USING (id)
- ORDER BY weight DESC
- LIMIT {$limit} OFFSET {$offset};
- END;
- $notice = Memcached_DataObject::cachedQuery('Notice', $qry, 600);
- $nl = new NoticeList($notice, $this);
- $cnt = $nl->show();
- /*if ($cnt == 0) {
- $this->showEmptyList();
- }*/
- $this->pagination(
- $this->page > 1,
- $cnt > NOTICES_PER_PAGE,
- $this->page,
- 'groupfavorited',
- array('nickname' => $this->group->nickname)
- );
- }
- }
|