diff options
author | Evan Prodromou <evan@status.net> | 2010-11-15 11:57:19 -0500 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-11-15 11:57:19 -0500 |
commit | c1cee3b27ffa1529009195604c5495bef4f83bc2 (patch) | |
tree | 42ae51f86b085978c9f1a28820ec4a69af1589b9 /actions/apistatusesshow.php | |
parent | fdf3a23da7769586a818ca2219ec6bc1b46587de (diff) | |
parent | cb371d65c18771f8fcdcbeb450c063b844c000df (diff) |
Merge branch 'atompub' into 0.9.x
Conflicts:
actions/apistatusesshow.php
actions/apitimelineuser.php
Diffstat (limited to 'actions/apistatusesshow.php')
-rw-r--r-- | actions/apistatusesshow.php | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/actions/apistatusesshow.php b/actions/apistatusesshow.php index a98e45f79..f4a79ddbc 100644 --- a/actions/apistatusesshow.php +++ b/actions/apistatusesshow.php @@ -100,13 +100,23 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction { parent::handle($args); - if (!in_array($this->format, array('xml', 'json'))) { + if (!in_array($this->format, array('xml', 'json', 'atom'))) { // TRANS: Client error displayed when trying to handle an unknown API method. - $this->clientError(_('API method not found.'), $code = 404); + $this->clientError(_('API method not found.'), 404); return; } - $this->showNotice(); + switch ($_SERVER['REQUEST_METHOD']) { + case 'GET': + $this->showNotice(); + break; + case 'DELETE': + $this->deleteNotice(); + break; + default: + $this->clientError(_('HTTP method not supported.'), 405); + return; + } } /** @@ -117,10 +127,18 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction function showNotice() { if (!empty($this->notice)) { - if ($this->format == 'xml') { + switch ($this->format) { + case 'xml': $this->showSingleXmlStatus($this->notice); - } elseif ($this->format == 'json') { + break; + case 'json': $this->show_single_json_status($this->notice); + break; + case 'atom': + $this->showSingleAtomStatus($this->notice); + break; + default: + throw new Exception(sprintf(_("Unsupported format: %s"), $this->format)); } } else { // XXX: Twitter just sets a 404 header and doens't bother @@ -197,4 +215,31 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction return null; } + + function deleteNotice() + { + if ($this->format != 'atom') { + $this->clientError(_("Can only delete using the Atom format.")); + return; + } + + if (empty($this->auth_user) || + ($this->notice->profile_id != $this->auth_user->id && + !$this->auth_user->hasRight(Right::DELETEOTHERSNOTICE))) { + $this->clientError(_('Can\'t delete this notice.'), 403); + return; + } + + if (Event::handle('StartDeleteOwnNotice', array($this->auth_user, $this->notice))) { + $this->notice->delete(); + Event::handle('EndDeleteOwnNotice', array($this->auth_user, $this->notice)); + } + + // @fixme is there better output we could do here? + + header('HTTP/1.1 200 OK'); + header('Content-Type: text/plain'); + print(sprintf(_('Deleted notice %d'), $this->notice->id)); + print("\n"); + } } |