X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fsubscriptions.php;h=7a87a144f7640ef8b8a8a5870bb6d0c125e2fa77;hb=cadad553793844e7ef56bab164b1a5866d8d16e7;hp=653c6d2b5e5c2d0b52a016256f86bb73ae723702;hpb=b6cfd2dffeeb733f07818db5f4ce11d4b3d51771;p=quix0rs-gnu-social.git diff --git a/actions/subscriptions.php b/actions/subscriptions.php index 653c6d2b5e..7a87a144f7 100644 --- a/actions/subscriptions.php +++ b/actions/subscriptions.php @@ -1,96 +1,87 @@ . */ -if (!defined('LACONICA')) { exit(1) } +if (!defined('LACONICA')) { exit(1); } -class SubscriptionsAction extends Action { - - function handle($args) { - parent::handle($args); - $nickname = $this->arg('nickname'); - $profile = Profile::staticGet('nickname', $nickname); - if (!$profile) { - $this->no_such_user(); - } - $user = User::staticGet($profile->id); - if (!$user) { - $this->no_such_user(); - } - $page = $this->arg('page') || 1; - $this->show_subscriptions($profile, $page); - } +require_once(INSTALLDIR.'/lib/gallery.php'); - function show_subscriptions($profile, $page) { +class SubscriptionsAction extends GalleryAction +{ - $sub = DB_DataObject::factory('subscriptions'); - $sub->subscriber = $profile->id; - - # We ask for an extra one to know if we need to do another page - - $sub->limit((($page-1)*SUBSCRIPTIONS_PER_PAGE)+1, SUBSCRIPTIONS_PER_PAGE + 1); + function gallery_type() + { + return _('Subscriptions'); + } - $subs_count = $subs->find(); - - common_start_element('div', 'subscriptions'); - - $idx = 0; - - while ($subs->fetch()) { - $idx++; - if ($idx % SUBSCRIPTIONS_PER_ROW == 1) { - common_start_element('div', 'row'); - } + function get_instructions(&$profile) + { + $user =& common_current_user(); + if ($user && ($user->id == $profile->id)) { + return _('These are the people whose notices you listen to.'); + } else { + return sprintf(_('These are the people whose notices %s listens to.'), $profile->nickname); + } + } - common_start_element('a', array('title' => $subs->fullname || - $subs->nickname, - 'href' => $subs->profileurl, - 'class' => 'subscription')); - common_element('img', array('src' => $subs->avatar, - 'class' => 'avatar')); - common_end_element('a'); - - if ($idx % SUBSCRIPTIONS_PER_ROW == 0) { - common_end_element('div'); - } - - if ($idx == SUBSCRIPTIONS_PER_PAGE) { - break; - } - } + function fields() + { + return array('subscribed', 'subscriber'); + } - if ($page > 1) { - common_element('a', array('href' => - common_local_url('subscriptions', - array('nickname' => $profile->nickname, - 'page' => $page - 1)), - 'class' => 'prev'), - _t('Previous')); - } - - if ($subs_count > SUBSCRIPTIONS_PER_PAGE) { - common_element('a', array('href' => - common_local_url('subscriptions', - array('nickname' => $profile->nickname, - 'page' => $page + 1)), - 'class' => 'next'), - _t('Next')); - } - common_end_element('div'); - } -} \ No newline at end of file + function div_class() + { + return 'subscriptions'; + } + + function get_other(&$subs) + { + return $subs->subscribed; + } + + function profile_list_class() + { + return 'SubscriptionsList'; + } +} + +class SubscriptionsList extends ProfileList +{ + + function show_owner_controls($profile) + { + + $sub = Subscription::pkeyGet(array('subscriber' => $this->owner->id, + 'subscribed' => $profile->id)); + if (!$sub) { + return; + } + + $this->elementStart('form', array('id' => 'subedit-' . $profile->id, + 'method' => 'post', + 'class' => 'subedit', + 'action' => common_local_url('subedit'))); + $this->hidden('token', common_session_token()); + $this->hidden('profile', $profile->id); + $this->checkbox('jabber', _('Jabber'), $sub->jabber); + $this->checkbox('sms', _('SMS'), $sub->sms); + $this->submit('save', _('Save')); + $this->elementEnd('form'); + return; + } +}