]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/groups.php
Merge branch 'master' of evan@dev.controlyourself.ca:/var/www/trunk
[quix0rs-gnu-social.git] / actions / groups.php
1 <?php
2 /**
3  * Laconica, the distributed open-source microblogging tool
4  *
5  * Latest groups information
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  Personal
23  * @package   Laconica
24  * @author    Evan Prodromou <evan@controlyourself.ca>
25  * @author    Sarven Capadisli <csarven@controlyourself.ca>
26  * @copyright 2008-2009 Control Yourself, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://laconi.ca/
29  */
30
31 if (!defined('LACONICA')) {
32     exit(1);
33 }
34
35 require_once INSTALLDIR.'/lib/grouplist.php';
36
37 /**
38  * Latest groups
39  *
40  * Show the latest groups on the site
41  *
42  * @category Personal
43  * @package  Laconica
44  * @author   Evan Prodromou <evan@controlyourself.ca>
45  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
46  * @link     http://laconi.ca/
47  */
48
49 class GroupsAction extends Action
50 {
51     var $page = null;
52     var $profile = null;
53
54     function title()
55     {
56         if ($this->page == 1) {
57             return _("Groups");
58         } else {
59             return sprintf(_("Groups, page %d"), $this->page);
60         }
61     }
62
63     function prepare($args)
64     {
65         parent::prepare($args);
66         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
67         return true;
68     }
69
70     function handle($args)
71     {
72         parent::handle($args);
73         $this->showPage();
74     }
75
76     function showLocalNav()
77     {
78         $nav = new PublicGroupNav($this);
79         $nav->show();
80     }
81
82     function showPageNotice()
83     {
84         $notice =
85           sprintf(_('%%%%site.name%%%% groups let you find and talk with ' .
86                     'people of similar interests. After you join a group ' .
87                     'you can send messages to all other members using the ' .
88                     'syntax "!groupname". Don\'t see a group you like? Try ' .
89                     '[searching for one](%%%%action.groupsearch%%%%) or ' .
90                     '[start your own!](%%%%action.newgroup%%%%)'));
91         $this->elementStart('div', 'instructions');
92         $this->raw(common_markup_to_html($notice));
93         $this->elementEnd('div');
94     }
95
96     function showContent()
97     {
98         $this->element('a', array('href' => common_local_url('newgroup'),
99                                   'id' => 'new_group'),
100                        _('Create a new group'));
101
102         $offset = ($this->page-1) * GROUPS_PER_PAGE;
103         $limit =  GROUPS_PER_PAGE + 1;
104
105         $groups = new User_group();
106         $groups->orderBy('created DESC');
107         $groups->limit($offset, $limit);
108
109         if ($groups->find()) {
110             $gl = new GroupList($groups, null, $this);
111             $cnt = $gl->show();
112         }
113
114         $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
115                           $this->page, 'groups');
116     }
117 }