]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/GroupFavorited/groupfavoritedaction.php
More info for a proper, fancy-url lighttpd setup
[quix0rs-gnu-social.git] / plugins / GroupFavorited / groupfavoritedaction.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * List of popular notices
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Public
23  * @package   StatusNet
24  * @author    Zach Copley <zach@status.net>
25  * @author    Evan Prodromou <evan@status.net>
26  * @copyright 2008-2009 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
32     exit(1);
33 }
34
35 class GroupFavoritedAction extends ShowgroupAction
36 {
37     /**
38      * Title of the page
39      *
40      * @return string page title, with page number
41      */
42     function title()
43     {
44         $base = $this->group->getFancyName();
45
46         if ($this->page == 1) {
47             // TRANS: %s is a group name.
48             return sprintf(_m('Popular posts in %s group'), $base);
49         } else {
50             // TRANS: %1$s is a group name, %2$s is a group number.
51             return sprintf(_m('Popular posts in %1$s group, page %2$d'),
52                            $base,
53                            $this->page);
54         }
55     }
56
57     /**
58      * Content area
59      *
60      * Shows the list of popular notices
61      *
62      * @return void
63      */
64     function showContent()
65     {
66         $groupId = intval($this->group->id);
67         $weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff'));
68         $cutoff = sprintf("fave.modified > '%s'",
69                           common_sql_date(time() - common_config('popular', 'cutoff')));
70
71         $qry = 'SELECT notice.*, '.
72           $weightexpr . ' as weight ' .
73           'FROM notice ' .
74           "JOIN group_inbox ON notice.id = group_inbox.notice_id " .
75           'JOIN fave ON notice.id = fave.notice_id ' .
76           "WHERE $cutoff AND group_id = $groupId " .
77           'GROUP BY id,profile_id,uri,content,rendered,url,created,notice.modified,reply_to,is_local,source,notice.conversation ' .
78           'ORDER BY weight DESC';
79
80         $offset = ($this->page - 1) * NOTICES_PER_PAGE;
81         $limit  = NOTICES_PER_PAGE + 1;
82
83         if (common_config('db', 'type') == 'pgsql') {
84             $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
85         } else {
86             $qry .= ' LIMIT ' . $offset . ', ' . $limit;
87         }
88
89         $notice = Memcached_DataObject::cachedQuery('Notice',
90                                                     $qry,
91                                                     600);
92
93         $nl = new NoticeList($notice, $this);
94
95         $cnt = $nl->show();
96
97         if ($cnt == 0) {
98             //$this->showEmptyList();
99         }
100
101         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
102                           $this->page, 'groupfavorited',
103                           array('nickname' => $this->group->nickname));
104     }
105 }