function handleDelete()
 {
     $args = array('profile_tag_id' => $this->list->id, 'profile_id' => $this->auth_user->id);
     $ptag = Profile_tag_subscription::pkeyGet($args);
     if (empty($ptag)) {
         // TRANS: Client error displayed when trying to unsubscribe from a non-subscribed list.
         $this->clientError(_('You are not subscribed to this list.'));
     }
     $result = Profile_tag_subscription::remove($this->list, $this->auth_user);
     if (empty($result)) {
         // TRANS: Client error displayed when an unknown error occurs unsubscribing from a list.
         $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);
     }
     return true;
 }
Exemplo n.º 2
0
 function handleDelete()
 {
     $args = array('profile_tag_id' => $this->list->id, 'profile_id' => $this->auth_user->id);
     $ptag = Profile_tag_subscription::pkeyGet($args);
     if (empty($ptag)) {
         $this->clientError(_('You are not subscribed to this list.'), 400, $this->format);
         return false;
     }
     Profile_tag_subscription::remove($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;
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * 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();
     Profile_tag_subscription::remove($this->peopletag, $cur);
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Page title for form that allows unsubscribing from a list.
         // TRANS: %1$s is a nickname, %2$s is a list, %3$s is a tagger nickname.
         $this->element('title', null, sprintf(_('%1$s unsubscribed from list %2$s by %3$s'), $cur->nickname, $this->peopletag->tag, $this->tagger->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $lf = new SubscribePeopletagForm($this, $this->peopletag);
         $lf->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         if (common_get_returnto()) {
             common_redirect(common_get_returnto(), 303);
             return true;
         }
         common_redirect(common_local_url('peopletagsbyuser', array('nickname' => $this->tagger->nickname)), 303);
     }
 }
Exemplo n.º 4
0
 /**
  * A remote user unsubscribed from our list.
  *
  * @return void
  * @throws Exception through clientError and serverError
  */
 function handleUnsubscribe()
 {
     if ($this->oprofile->isGroup()) {
         // TRANS: Client error displayed when trying to unsubscribe a group from a list.
         $this->clientError(_m('Groups cannot subscribe to lists.'));
     }
     common_log(LOG_INFO, sprintf('Remote profile %s unsubscribing from local peopletag %s', $this->oprofile->getUri(), $this->peopletag->getBestName()));
     try {
         Profile_tag_subscription::remove($this->peopletag->tagger, $this->peopletag->tag, $this->actor->id);
     } catch (Exception $e) {
         // TRANS: Client error displayed when trying to unsubscribe a remote user from a list fails.
         // TRANS: %1$s is a profile URL, %2$s is a list name.
         $this->serverError(sprintf(_m('Could not unsubscribe remote user %1$s from list %2$s.'), $this->oprofile->getUri(), $this->peopletag->getBestName()));
     }
 }
Exemplo n.º 5
0
 /**
  * A remote user unsubscribed from our list.
  */
 function handleUnsubscribe()
 {
     $oprofile = $this->ensureProfile();
     if (!$oprofile) {
         // TRANS: Client error displayed when trying to unsubscribe from non-existing list.
         $this->clientError(_m('Cannot read profile to cancel list subscription.'));
     }
     if ($oprofile->isGroup()) {
         // TRANS: Client error displayed when trying to unsubscribe a group from a list.
         $this->clientError(_m('Groups cannot subscribe to lists.'));
     }
     common_log(LOG_INFO, "Remote profile {$oprofile->uri} unsubscribing from local peopletag " . $this->peopletag->getBestName());
     $profile = $oprofile->localProfile();
     try {
         Profile_tag_subscription::remove($this->peopletag->tagger, $this->peopletag->tag, $profile->id);
     } catch (Exception $e) {
         // TRANS: Client error displayed when trying to unsubscribe a remote user from a list fails.
         // TRANS: %1$s is a profile URL, %2$s is a list name.
         $this->serverError(sprintf(_m('Could not unsubscribe remote user %1$s from list %2$s.'), $oprofile->uri, $this->peopletag->getBestName()));
         return;
     }
 }