/** * Remove a user from a list (untag someone) * * @return boolean success */ function handleDelete() { if ($this->auth_user->id != $this->list->tagger) { // TRANS: Client error displayed when trying to remove members from a list without having the right to do so. $this->clientError(_('You are not allowed to remove members from this list.'), 401); } if (!$this->target instanceof Profile) { // TRANS: Client error displayed when trying to modify list members without specifying them. $this->clientError(_('You must specify a member.')); } $args = array('tagger' => $this->auth_user->id, 'tagged' => $this->target->id, 'tag' => $this->list->tag); $ptag = Profile_tag::pkeyGet($args); if (empty($ptag)) { // TRANS: Client error displayed when trying to remove a list member that is not part of a list. $this->clientError(_('The user you are trying to remove from the list is not a member.')); } if (!$ptag->delete()) { // TRANS: Client error displayed when an unknown error occurs viewing list members. $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; }
/** * Remove a user from a list (untag someone) * * @return boolean success */ function handleDelete() { if ($this->auth_user->id != $this->list->tagger) { $this->clientError(_('You are not allowed to remove members from this list.'), 401, $this->format); return false; } if ($this->user === false) { $this->clientError(_('You must specify a member.'), 400, $this->format); return false; } $args = array('tagger' => $this->auth_user->id, 'tagged' => $this->user->id, 'tag' => $this->list->tag); $ptag = Profile_tag::pkeyGet($args); if (empty($ptag)) { $this->clientError(_('The user you are trying to remove from the list is not a member.'), 400, $this->format); return false; } $result = $ptag->delete(); 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; }
/** * Handle the request * * @return boolean success flag */ function handle($args) { parent::handle($args); $arr = array('tagger' => $this->list->tagger, 'tag' => $this->list->tag, 'tagged' => $this->user->id); $ptag = Profile_tag::pkeyGet($arr); if (empty($ptag)) { $this->clientError(_('The specified user is not a member of this list.'), 400, $this->format); } $user = $this->twitterUserArray($this->user->getProfile(), true); switch ($this->format) { case 'xml': $this->showTwitterXmlUser($user, 'user', true); break; case 'json': $this->showSingleJsonUser($user); break; default: $this->clientError(_('API method not found.'), 404, $this->format); break; } return true; }
/** * Handle the request * * @return boolean success flag */ protected function handle() { parent::handle(); $arr = array('tagger' => $this->list->tagger, 'tag' => $this->list->tag, 'tagged' => $this->target->id); $ptag = Profile_tag::pkeyGet($arr); if (empty($ptag)) { // TRANS: Client error displayed when referring to a non-list member. $this->clientError(_('The specified user is not a member of this list.')); } $user = $this->twitterUserArray($this->target, true); switch ($this->format) { case 'xml': $this->showTwitterXmlUser($user, 'user', true); break; case 'json': $this->showSingleJsonUser($user); break; default: // TRANS: Client error displayed when coming across a non-supported API method. $this->clientError(_('API method not found.'), 404); } return true; }
static function unTag($tagger, $tagged, $tag) { $ptag = Profile_tag::pkeyGet(array('tagger' => $tagger, 'tagged' => $tagged, 'tag' => $tag)); if (!$ptag) { return true; } if (Event::handle('StartUntagProfile', array($ptag))) { $orig = clone $ptag; $result = $ptag->delete(); if (!$result) { common_log_db_error($this, 'DELETE', __FILE__); return false; } Event::handle('EndUntagProfile', array($orig)); if ($result) { $profile_list = Profile_list::pkeyGet(array('tag' => $tag, 'tagger' => $tagger)); if (!empty($profile_list)) { $profile_list->taggedCount(true); } self::blowCaches($tagger, $tagged); return true; } return false; } }
function isTagged($peopletag) { $tag = Profile_tag::pkeyGet(array('tagger' => $peopletag->tagger, 'tagged' => $this->id, 'tag' => $peopletag->tag)); return !empty($tag); }