exit(1);
}
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
class ApiListAction extends ApiBareAuthAction
{
/**
* The list in question in the current request
*/
-
var $list = null;
/**
* Is this an update request?
*/
-
var $update = false;
/**
* Is this a delete request?
*/
-
var $delete = false;
/**
*
* @return boolean success flag
*/
-
- function prepare($args)
+ protected function prepare(array $args=array())
{
parent::prepare($args);
$this->list = $this->getTargetList($this->arg('user'), $this->arg('id'));
if (empty($this->list)) {
- $this->clientError(_('Not found'), 404, $this->format);
- return false;
+ // TRANS: Client error displayed when referring to a non-existing list.
+ $this->clientError(_('List not found.'), 404);
}
return true;
*
* @return boolean success flag
*/
-
- function handle($args)
+ protected function handle()
{
- parent::handle($args);
+ parent::handle();
if($this->delete) {
$this->handleDelete();
$this->showSingleJsonList($this->list);
break;
default:
- $this->clientError(
- _('API method not found.'),
- 404,
- $this->format
- );
- break;
+ // TRANS: Client error displayed when coming across a non-supported API method.
+ $this->clientError(_('API method not found.'), 404);
}
}
* require authentication if it is a write action or user is ambiguous
*
*/
-
function requiresAuth()
{
return parent::requiresAuth() ||
*
* @return boolean success
*/
-
function handlePut()
{
if($this->auth_user->id != $this->list->tagger) {
- $this->clientError(
- _('You can not update lists that don\'t belong to you.'),
- 401,
- $this->format
- );
+ // TRANS: Client error displayed when trying to update another user's list.
+ $this->clientError(_('You cannot update lists that do not belong to you.'), 401);
}
$new_list = clone($this->list);
$result = $new_list->update($this->list);
if(!$result) {
- $this->clientError(
- _('An error occured.'),
- 503,
- $this->format
- );
+ // TRANS: Client error displayed when an unknown error occurs updating a list.
+ $this->clientError(_('An error occured.'), 503);
}
switch($this->format) {
$this->showSingleJsonList($new_list);
break;
default:
- $this->clientError(
- _('API method not found.'),
- 404,
- $this->format
- );
- break;
+ // TRANS: Client error displayed when coming across a non-supported API method.
+ $this->clientError(_('API method not found.'), 404);
}
}
*
* @return boolean success
*/
-
function handleDelete()
{
if($this->auth_user->id != $this->list->tagger) {
- $this->clientError(
- _('You can not delete lists that don\'t belong to you.'),
- 401,
- $this->format
- );
+ // TRANS: Client error displayed when trying to delete another user's list.
+ $this->clientError(_('You cannot delete lists that do not belong to you.'), 401);
}
$record = clone($this->list);
$this->showSingleJsonList($record);
break;
default:
- $this->clientError(
- _('API method not found.'),
- 404,
- $this->format
- );
- break;
+ // TRANS: Client error displayed when coming across a non-supported API method.
+ $this->clientError(_('API method not found.'), 404);
}
}
*
* @return boolean is_read-only=false
*/
-
function isReadOnly($args)
{
return false;
*
* @return String time_last_modified
*/
-
function lastModified()
{
if(!empty($this->list)) {
*
* @return string etag
*/
-
function etag()
{
if (!empty($this->list)) {
return null;
}
-
}