/** * Handle request * * Does the subscription and returns results. * * @param Array $args unused. * * @return void */ function handle($args) { // Throws exception on error $ptag = Profile_tag::unTag($this->user->id, $this->tagged->id, $this->peopletag->tag); if (!$ptag) { $user = User::staticGet('id', $this->tagged->id); if ($user) { $this->clientError(sprintf(_('There was an unexpected error while delisting %s.'), $user->nickname)); } else { // TRANS: Client error displayed when an unknown error occurs while listing a user. // TRANS: %s is a profile URL. $this->clientError(sprintf(_('There was a problem listing %s. ' . 'The remote server is probably not responding correctly, ' . 'please try retrying later.'), $this->profile->profileurl)); } return false; } if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title after removing a user from a list. $this->element('title', null, _('Unlisted')); $this->elementEnd('head'); $this->elementStart('body'); $unsubscribe = new TagButton($this, $this->tagged, $this->peopletag); $unsubscribe->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { $url = common_local_url('subscriptions', array('nickname' => $this->user->nickname)); common_redirect($url, 303); } }
function handle($channel) { $profile = $this->getProfile($this->other); $cur = $this->user->getProfile(); if (!$profile) { // TRANS: Client error displayed trying to perform an action related to a non-existing profile. $channel->error($cur, _('No such profile.')); return; } if (!$cur->canTag($profile)) { // TRANS: Error displayed when trying to tag a user that cannot be tagged. $channel->error($cur, _('You cannot tag this user.')); return; } $tags = array_map('common_canonical_tag', preg_split('/[\\s,]+/', $this->tags)); foreach ($tags as $tag) { if (!common_valid_profile_tag($tag)) { // TRANS: Error displayed if a given tag is invalid. // TRANS: %s is the invalid tag. $channel->error($cur, sprintf(_('Invalid tag: "%s"'), $tag)); return; } } try { foreach ($tags as $tag) { Profile_tag::unTag($cur->id, $profile->id, $tag); } } catch (Exception $e) { // TRANS: Error displayed if untagging a user fails. // TRANS: %1$s is the untagged user, %2$s is the error message (no punctuation). $channel->error($cur, sprintf(_('Error untagging %1$s: %2$s'), $profile->nickname, $e->getMessage())); return; } // TRANS: Succes message displayed if untagging a user succeeds. // TRANS: %1$s is the untagged user's nickname, %2$s is a list of tags. // TRANS: Plural is decided based on the number of tags removed (not part of message). $channel->output($cur, sprintf(_m('The following tag was removed from user %1$s: %2$s.', 'The following tags were removed from user %1$s: %2$s.', count($tags)), $profile->nickname, implode(_(', '), $tags))); }
function handleUntag() { if ($this->activity->target->type == ActivityObject::_LIST) { if ($this->activity->objects[0]->type != ActivityObject::PERSON) { // TRANS: Client exception. throw new ClientException(_m('Not a person object.')); return false; } // this is a peopletag $tagged = User::staticGet('uri', $this->activity->objects[0]->id); if (empty($tagged)) { // TRANS: Client exception. throw new ClientException(_m('Unidentified profile being untagged.')); } if ($tagged->id !== $this->user->id) { // TRANS: Client exception. throw new ClientException(_m('This user is not the one being untagged.')); } // save the list $tagger = $this->ensureProfile(); $list = Ostatus_profile::ensureActivityObjectProfile($this->activity->target); $ptag = $list->localPeopletag(); $result = Profile_tag::unTag($ptag->tagger, $tagged->id, $ptag->tag); if (!$result) { // TRANS: Client exception. throw new ClientException(_m('The tag could not be deleted.')); } } }