/**
  * Subscribe to list
  *
  * @return boolean success
  */
 function handlePost()
 {
     $result = Profile_tag_subscription::add($this->list, $this->auth_user);
     if (empty($result)) {
         // TRANS: Client error displayed when an unknown error occurs in the list subscribers action.
         $this->clientError(_('An error occured.'), 500);
     }
     switch ($this->format) {
         case 'xml':
             $this->showSingleXmlList($this->list);
             break;
         case 'json':
             $this->showSingleJsonList($this->list);
             break;
         default:
             // TRANS: Client error displayed when coming across a non-supported API method.
             $this->clientError(_('API method not found.'), 404);
     }
 }
 /**
  * Subscribe to list
  *
  * @return boolean success
  */
 function handlePost()
 {
     $result = Profile_tag_subscription::add($this->list, $this->auth_user);
     if (empty($result)) {
         $this->clientError(_('An error occured.'), 500, $this->format);
         return false;
     }
     switch ($this->format) {
         case 'xml':
             $this->showSingleXmlList($this->list);
             break;
         case 'json':
             $this->showSingleJsonList($this->list);
             break;
         default:
             $this->clientError(_('API method not found.'), 404, $this->format);
             return false;
             break;
     }
 }
 /**
  * A remote user subscribed.
  * @fixme move permission checks and event call into common code,
  *        currently we're doing the main logic in joingroup action
  *        and so have to repeat it here.
  */
 function handleSubscribe()
 {
     if ($this->oprofile->isGroup()) {
         // TRANS: Client error displayed when trying to subscribe a group to a list.
         $this->clientError(_m('Groups cannot subscribe to lists.'));
     }
     common_log(LOG_INFO, sprintf('Remote profile %s subscribing to local peopletag %s', $this->oprofile->getUri(), $this->peopletag->getBestName()));
     if ($this->peopletag->hasSubscriber($this->actor)) {
         // Already a member; we'll take it silently to aid in resolving
         // inconsistencies on the other side.
         return true;
     }
     // should we block those whom the tagger has blocked from listening to
     // his own updates?
     try {
         Profile_tag_subscription::add($this->peopletag, $this->actor);
     } catch (Exception $e) {
         // TRANS: Server error displayed when subscribing a remote user to a list fails.
         // TRANS: %1$s is a profile URI, %2$s is a list name.
         $this->serverError(sprintf(_m('Could not subscribe remote user %1$s to list %2$s.'), $this->oprofile->getUri(), $this->peopletag->getBestName()));
     }
 }
 /**
  * Handle the request
  *
  * On POST, add the current user to the group
  *
  * @param array $args unused
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $cur = common_current_user();
     try {
         Profile_tag_subscription::add($this->peopletag, $cur);
     } catch (Exception $e) {
         // TRANS: Server error displayed subscribing to a list fails.
         // TRANS: %1$s is a user nickname, %2$s is a list, %3$s is the error message (no period).
         $this->serverError(sprintf(_('Could not subscribe user %1$s to list %2$s: %3$s'), $cur->nickname, $this->peopletag->tag), $e->getMessage());
     }
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title of form to subscribe to a list.
         // TRANS: %1%s is a user nickname, %2$s is a list, %3$s is a tagger nickname.
         $this->element('title', null, sprintf(_('%1$s subscribed to list %2$s by %3$s'), $cur->nickname, $this->peopletag->tag, $this->tagger->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $lf = new UnsubscribePeopletagForm($this, $this->peopletag);
         $lf->show();
         $this->elementEnd('body');
         $this->endHTML();
     } else {
         common_redirect(common_local_url('peopletagsubscribers', array('tagger' => $this->tagger->nickname, 'tag' => $this->peopletag->tag)), 303);
     }
 }
 /**
  * Attempt to finalize subscription.
  * validateFeed must have been run first.
  *
  * Calls showForm on failure or success on success.
  */
 function saveFeed()
 {
     $user = common_current_user();
     $ptag = $this->oprofile->localPeopletag();
     if ($ptag->hasSubscriber($user->id)) {
         // TRANS: OStatus remote group subscription dialog error.
         $this->showForm(_m('Already subscribed!'));
         return;
     }
     try {
         Profile_tag_subscription::add($ptag, $user);
         $this->success();
     } catch (Exception $e) {
         $this->showForm($e->getMessage());
     }
 }