3 * Laconica, the distributed open-source microblogging tool
5 * List of a user's subscriptions
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.
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.
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/>.
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/
31 if (!defined('LACONICA')) {
36 * A list of the user's subscriptions
40 * @author Evan Prodromou <evan@controlyourself.ca>
41 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
42 * @link http://laconi.ca/
45 if (!defined('LACONICA')) { exit(1); }
47 class SubscriptionsAction extends GalleryAction
51 if ($this->page == 1) {
52 return sprintf(_('%s subscriptions'), $this->user->nickname);
54 return sprintf(_('%s subscriptions, page %d'),
55 $this->user->nickname,
60 function showPageNotice()
62 $user =& common_current_user();
63 if ($user && ($user->id == $this->profile->id)) {
64 $this->element('p', null,
65 _('These are the people whose notices '.
68 $this->element('p', null,
69 sprintf(_('These are the people whose '.
70 'notices %s listens to.'),
71 $this->profile->nickname));
77 return $this->getTags('subscribed', 'subscriber');
80 function showContent()
82 parent::showContent();
84 $offset = ($this->page-1) * PROFILES_PER_PAGE;
85 $limit = PROFILES_PER_PAGE + 1;
90 $subscriptions = $this->user->getTaggedSubscriptions($this->tag, $offset, $limit);
92 $subscriptions = $this->user->getSubscriptions($offset, $limit);
96 $subscriptions_list = new SubscriptionsList($subscriptions, $this->user, $this);
97 $cnt = $subscriptions_list->show();
99 $this->showEmptyListMessage();
103 $subscriptions->free();
105 $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
106 $this->page, 'subscriptions',
107 array('nickname' => $this->user->nickname));
110 function showEmptyListMessage()
112 if (common_logged_in()) {
113 $current_user = common_current_user();
114 if ($this->user->id === $current_user->id) {
115 $message = _('You\'re not listening to anyone\'s notices right now, try subscribing to people you know. Try [people search](%%action.peoplesearch%%), look for members in groups you\'re interested in and in our [featured users](%%action.featured%%). If you\'re a [Twitter user](%%action.twittersettings%%), you can automatically subscribe to people you already follow there.');
117 $message = sprintf(_('%s is not listening to anyone.'), $this->user->nickname);
121 $message = sprintf(_('%s is not listening to anyone.'), $this->user->nickname);
124 $this->elementStart('div', 'guide');
125 $this->raw(common_markup_to_html($message));
126 $this->elementEnd('div');
129 function showSections()
131 parent::showSections();
132 $cloud = new SubscriptionsPeopleTagCloudSection($this);
135 $cloud2 = new SubscriptionsPeopleSelfTagCloudSection($this);
140 // XXX SubscriptionsList and SubscriptionList are dangerously close
142 class SubscriptionsList extends SubscriptionList
144 function newListItem($profile)
146 return new SubscriptionsListItem($profile, $this->owner, $this->action);
150 class SubscriptionsListItem extends SubscriptionListItem
152 function showProfile()
154 $this->startProfile();
156 $this->showFullName();
157 $this->showLocation();
158 $this->showHomepage();
162 $cur = common_current_user();
163 if (!empty($cur) && $cur->id == $this->owner->id) {
164 $this->showOwnerControls();
169 function showOwnerControls()
171 $sub = Subscription::pkeyGet(array('subscriber' => $this->owner->id,
172 'subscribed' => $this->profile->id));
177 $this->out->elementStart('form', array('id' => 'subedit-' . $this->profile->id,
179 'class' => 'form_subscription_edit',
180 'action' => common_local_url('subedit')));
181 $this->out->hidden('token', common_session_token());
182 $this->out->hidden('profile', $this->profile->id);
183 $this->out->checkbox('jabber', _('Jabber'), $sub->jabber);
184 $this->out->checkbox('sms', _('SMS'), $sub->sms);
185 $this->out->submit('save', _('Save'));
186 $this->out->elementEnd('form');