]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/groups.php
Merge branch '0.9.x' into adminpanel
[quix0rs-gnu-social.git] / actions / groups.php
1 <?php
2 /**
3  * StatusNet, 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   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @author    Sarven Capadisli <csarven@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 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  StatusNet
44  * @author   Evan Prodromou <evan@status.net>
45  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
46  * @link     http://status.net/
47  */
48
49 class GroupsAction extends Action
50 {
51     var $page = null;
52     var $profile = null;
53
54     function isReadOnly($args)
55     {
56         return true;
57     }
58
59     function title()
60     {
61         if ($this->page == 1) {
62             return _("Groups");
63         } else {
64             return sprintf(_("Groups, page %d"), $this->page);
65         }
66     }
67
68     function prepare($args)
69     {
70         parent::prepare($args);
71         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
72         return true;
73     }
74
75     function handle($args)
76     {
77         parent::handle($args);
78         $this->showPage();
79     }
80
81     function showLocalNav()
82     {
83         $nav = new PublicGroupNav($this);
84         $nav->show();
85     }
86
87     function showPageNotice()
88     {
89         $notice =
90           sprintf(_('%%%%site.name%%%% groups let you find and talk with ' .
91                     'users of similar interests. After you join a group ' .
92                     'you can send messages to all other members using the ' .
93                     'syntax "!groupname". Are you not seeing any groups ' .
94                     'you like? Try ' .
95                     '[searching for one](%%%%action.groupsearch%%%%) or ' .
96                     '[start your own](%%%%action.newgroup%%%%)!'));
97         $this->elementStart('div', 'instructions');
98         $this->raw(common_markup_to_html($notice));
99         $this->elementEnd('div');
100     }
101
102     function showContent()
103     {
104         if (common_logged_in()) {
105             $this->elementStart('p', array('id' => 'new_group'));
106             $this->element('a', array('href' => common_local_url('newgroup'),
107                                       'class' => 'more'),
108                            _('Create a new group'));
109             $this->elementEnd('p');
110         }
111
112         $offset = ($this->page-1) * GROUPS_PER_PAGE;
113         $limit =  GROUPS_PER_PAGE + 1;
114
115         $groups = new User_group();
116         $groups->orderBy('created DESC');
117         $groups->limit($offset, $limit);
118
119         $cnt = 0;
120         if ($groups->find()) {
121             $gl = new GroupList($groups, null, $this);
122             $cnt = $gl->show();
123         }
124
125         $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
126                           $this->page, 'groups');
127     }
128
129     function showSections()
130     {
131         $gbp = new GroupsByPostsSection($this);
132         $gbp->show();
133         $gbm = new GroupsByMembersSection($this);
134         $gbm->show();
135     }
136 }