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;
 }
 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;
 }
 static function remove($peopletag, $profile)
 {
     $sub = Profile_tag_subscription::pkeyGet(array('profile_tag_id' => $peopletag->id, 'profile_id' => $profile->id));
     if (empty($sub)) {
         // silence is golden?
         return true;
     }
     if (Event::handle('StartUnsubscribePeopletag', array($peopletag, $profile))) {
         $result = $sub->delete();
         if (!$result) {
             common_log_db_error($sub, 'DELETE', __FILE__);
             // TRANS: Exception thrown when deleting a list subscription from the database fails.
             throw new Exception(_('Removing list subscription failed.'));
         }
         $peopletag->subscriberCount(true);
         Event::handle('EndUnsubscribePeopletag', array($peopletag, $profile));
         return true;
     }
 }
Beispiel #4
0
 function handle($args)
 {
     parent::handle($args);
     $arr = array('profile_tag_id' => $this->list->id, 'profile_id' => $this->user->id);
     $sub = Profile_tag_subscription::pkeyGet($arr);
     if (empty($sub)) {
         $this->clientError(_('The specified user is not a subscriber 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;
     }
 }
 function handle($args)
 {
     parent::handle($args);
     $arr = array('profile_tag_id' => $this->list->id, 'profile_id' => $this->target->id);
     $sub = Profile_tag_subscription::pkeyGet($arr);
     if (empty($sub)) {
         // TRANS: Client error displayed when a membership check for a user is nagative.
         $this->clientError(_('The specified user is not a subscriber 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:
             $this->clientError(_('API method not found.'), 404, $this->format);
             break;
     }
 }
 /**
  * Check to see if a given profile has
  * subscribed to this people tag's timeline
  *
  * @param mixed $id User or Profile object or integer id
  *
  * @return boolean subscription status
  */
 function hasSubscriber($id)
 {
     if (!is_numeric($id)) {
         $id = $id->id;
     }
     $sub = Profile_tag_subscription::pkeyGet(array('profile_tag_id' => $this->id, 'profile_id' => $id));
     return !empty($sub);
 }