]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/usergroups.php
Profile/Peopletag file splitting for autoload
[quix0rs-gnu-social.git] / actions / usergroups.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * User 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  * User groups page
39  *
40  * Show the groups a user belongs to
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 class UsergroupsAction extends GalleryAction
49 {
50     function title()
51     {
52         if ($this->page == 1) {
53             // TRANS: Page title for first page of groups for a user.
54             // TRANS: %s is a nickname.
55             return sprintf(_('%s groups'), $this->getTarget()->getNickname());
56         } else {
57             // TRANS: Page title for all but the first page of groups for a user.
58             // TRANS: %1$s is a nickname, %2$d is a page number.
59             return sprintf(_('%1$s groups, page %2$d'),
60                            $this->getTarget()->getNickname(),
61                            $this->page);
62         }
63     }
64
65     function showContent()
66     {
67         $this->elementStart('p', array('id' => 'new_group'));
68         $this->element('a', array('href' => common_local_url('newgroup'),
69                                   'class' => 'more'),
70                        // TRANS: Link text on group page to create a new group.
71                        _('Create a new group'));
72         $this->elementEnd('p');
73
74         $this->elementStart('p', array('id' => 'group_search'));
75         $this->element('a', array('href' => common_local_url('groupsearch'),
76                                   'class' => 'more'),
77                        // TRANS: Link text on group page to search for groups.
78                        _('Search for more groups'));
79         $this->elementEnd('p');
80
81         if (Event::handle('StartShowUserGroupsContent', array($this))) {
82             $offset = ($this->page-1) * GROUPS_PER_PAGE;
83             $limit =  GROUPS_PER_PAGE + 1;
84
85             $groups = $this->getTarget()->getGroups($offset, $limit);
86
87             if ($groups instanceof User_group) {
88                 $gl = new GroupList($groups, $this->getTarget(), $this);
89                 $cnt = $gl->show();
90                 $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE,
91                               $this->page, 'usergroups',
92                               array('nickname' => $this->getTarget()->getNickname()));
93             } else {
94                 $this->showEmptyListMessage();
95             }
96
97             Event::handle('EndShowUserGroupsContent', array($this));
98         }
99     }
100
101     function showEmptyListMessage()
102     {
103         // TRANS: Text on group page for a user that is not a member of any group.
104         // TRANS: %s is a user nickname.
105         $message = sprintf(_('%s is not a member of any group.'), $this->getTarget()->getNickname()) . ' ';
106
107         if (common_logged_in()) {
108             $current_user = common_current_user();
109             if ($this->scoped->sameAs($this->getTarget())) {
110                 // TRANS: Text on group page for a user that is not a member of any group. This message contains
111                 // TRANS: a Markdown link in the form [link text](link) and a variable that should not be changed.
112                 $message .= _('Try [searching for groups](%%action.groupsearch%%) and joining them.');
113             }
114         }
115         $this->elementStart('div', 'guide');
116         $this->raw(common_markup_to_html($message));
117         $this->elementEnd('div');
118     }
119
120     function showProfileBlock()
121     {
122         $block = new AccountProfileBlock($this, $this->getTarget());
123         $block->show();
124     }
125 }