/**
  * Handle the request
  *
  * Delete the notice and all related replies
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (!in_array($this->format, array('xml', 'json'))) {
         $this->clientError(_('API method not found.'), $code = 404);
         return;
     }
     if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
         $this->clientError(_('This method requires a POST or DELETE.'), 400, $this->format);
         return;
     }
     if (empty($this->notice)) {
         $this->clientError(_('No status found with that ID.'), 404, $this->format);
         return;
     }
     if ($this->user->id == $this->notice->profile_id) {
         $replies = new Reply();
         $replies->get('notice_id', $this->notice_id);
         $replies->delete();
         $this->notice->delete();
         if ($this->format == 'xml') {
             $this->showSingleXmlStatus($this->notice);
         } elseif ($this->format == 'json') {
             $this->show_single_json_status($this->notice);
         }
     } else {
         $this->clientError(_('You may not delete another user\'s status.'), 403, $this->format);
     }
     $this->showNotice();
 }
示例#2
0
 function destroy($args, $apidata)
 {
     parent::handle($args);
     if (!in_array($apidata['content-type'], array('xml', 'json'))) {
         $this->clientError(_('API method not found!'), $code = 404);
         return;
     }
     // Check for RESTfulness
     if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
         // XXX: Twitter just prints the err msg, no XML / JSON.
         $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
         return;
     }
     $this->auth_user = $apidata['user'];
     $user = $this->auth_user;
     $notice_id = $apidata['api_arg'];
     $notice = Notice::staticGet($notice_id);
     if (!$notice) {
         $this->clientError(_('No status found with that ID.'), 404, $apidata['content-type']);
         return;
     }
     if ($user->id == $notice->profile_id) {
         $replies = new Reply();
         $replies->get('notice_id', $notice_id);
         $replies->delete();
         $notice->delete();
         if ($apidata['content-type'] == 'xml') {
             $this->show_single_xml_status($notice);
         } elseif ($apidata['content-type'] == 'json') {
             $this->show_single_json_status($notice);
         }
     } else {
         $this->clientError(_('You may not delete another user\'s status.'), 403, $apidata['content-type']);
     }
 }