]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/subscribers.php
Localisation updates from translatewiki.net
[quix0rs-gnu-social.git] / actions / subscribers.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * List a user's subscribers
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  Social
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 /**
36  * List a user's subscribers
37  *
38  * @category Social
39  * @package  StatusNet
40  * @author   Evan Prodromou <evan@status.net>
41  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
42  * @link     http://status.net/
43  */
44
45 class SubscribersAction extends GalleryAction
46 {
47     function title()
48     {
49         if ($this->page == 1) {
50             return sprintf(_('%s subscribers'), $this->user->nickname);
51         } else {
52             return sprintf(_('%s subscribers, page %d'),
53                            $this->user->nickname,
54                            $this->page);
55         }
56     }
57
58     function showPageNotice()
59     {
60         $user =& common_current_user();
61         if ($user && ($user->id == $this->profile->id)) {
62             $this->element('p', null,
63                            _('These are the people who listen to '.
64                              'your notices.'));
65         } else {
66             $this->element('p', null,
67                            sprintf(_('These are the people who '.
68                                      'listen to %s\'s notices.'),
69                                    $this->profile->nickname));
70         }
71     }
72
73     function showContent()
74     {
75         parent::showContent();
76
77         $offset = ($this->page-1) * PROFILES_PER_PAGE;
78         $limit =  PROFILES_PER_PAGE + 1;
79
80         $cnt = 0;
81
82         if ($this->tag) {
83             $subscribers = $this->user->getTaggedSubscribers($this->tag, $offset, $limit);
84         } else {
85             $subscribers = $this->user->getSubscribers($offset, $limit);
86         }
87
88         if ($subscribers) {
89             $subscribers_list = new SubscribersList($subscribers, $this->user, $this);
90             $cnt = $subscribers_list->show();
91             if (0 == $cnt) {
92                 $this->showEmptyListMessage();
93             }
94         }
95
96         $subscribers->free();
97
98         $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
99                           $this->page, 'subscribers',
100                           array('nickname' => $this->user->nickname));
101     }
102
103     function showEmptyListMessage()
104     {
105         if (common_logged_in()) {
106             $current_user = common_current_user();
107             if ($this->user->id === $current_user->id) {
108                 $message = _('You have no subscribers. Try subscribing to people you know and they might return the favor');
109             } else {
110                 $message = sprintf(_('%s has no subscribers. Want to be the first?'), $this->user->nickname);
111             }
112         }
113         else {
114             $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.register%%%%) and be the first?'), $this->user->nickname);
115         }
116
117         $this->elementStart('div', 'guide');
118         $this->raw(common_markup_to_html($message));
119         $this->elementEnd('div');
120     }
121
122     function showSections()
123     {
124         parent::showSections();
125         $cloud = new SubscribersPeopleTagCloudSection($this);
126         $cloud->show();
127
128         $cloud2 = new SubscribersPeopleSelfTagCloudSection($this);
129         $cloud2->show();
130     }
131 }
132
133 class SubscribersList extends SubscriptionList
134 {
135     function newListItem($profile)
136     {
137         return new SubscribersListItem($profile, $this->owner, $this->action);
138     }
139 }
140
141 class SubscribersListItem extends SubscriptionListItem
142 {
143     function showActions()
144     {
145         $this->startActions();
146         $this->showSubscribeButton();
147         // Relevant code!
148         $this->showBlockForm();
149         $this->endActions();
150     }
151
152     function showBlockForm()
153     {
154         $user = common_current_user();
155
156         if (!empty($user) && $this->owner->id == $user->id) {
157             $bf = new BlockForm($this->out, $this->profile,
158                                 array('action' => 'subscribers',
159                                       'nickname' => $this->owner->nickname));
160             $bf->show();
161         }
162     }
163 }