exit(1);
}
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
/**
* Action handler for Twitter list_memeber methods
*
* @link http://status.net/
* @see ApiBareAuthAction
*/
-
class ApiListsAction extends ApiBareAuthAction
{
var $lists = null;
*
* @return boolean success flag
*/
-
- function prepare($args)
+ protected function prepare(array $args=array())
{
parent::prepare($args);
$this->user = $this->getTargetUser($this->arg('user'));
- if (empty($this->user)) {
- $this->clientError(_('No such user.'), 404, $this->format);
- return false;
+ if (!($user instanceof User)) {
+ // TRANS: Client error displayed trying to perform an action related to a non-existing user.
+ $this->clientError(_('No such user.'), 404);
}
+ $this->target = $user->getProfile();
$this->getLists();
}
* require authentication if it is a write action or user is ambiguous
*
*/
-
function requiresAuth()
{
return parent::requiresAuth() ||
* Show the lists the user has created if the request method is GET
* Create a new list by diferring to handlePost() if it is POST.
*/
-
- function handle($args)
+ protected function handle()
{
- parent::handle($args);
+ parent::handle();
if($this->create) {
return $this->handlePost();
break;
default:
$this->clientError(
+ // TRANS: Client error displayed when coming across a non-supported API method.
_('API method not found.'),
404,
$this->format
*
* @return boolean success
*/
-
function handlePost()
{
$name=$this->arg('name');
if(empty($name)) {
// mimick twitter
- print _("A list's name can't be blank.");
+ // TRANS: Client error displayed when trying to create a list without a name.
+ print _("A list must have a name.");
exit(1);
}
$this->showSingleJsonList($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 true;
}
/**
* Get lists
*/
-
function getLists()
{
$cursor = (int) $this->arg('cursor', -1);
// twitter fixes count at 20
// there is no argument named count
$count = 20;
- $profile = $this->user->getProfile();
- $fn = array($profile, 'getOwnedTags');
+ $fn = array($this->target, 'getLists');
list($this->lists,
$this->next_cursor,
*
* @return string etag
*/
-
function etag()
{
if (!$this->create && !empty($this->lists) && (count($this->lists) > 0)) {
':',
array($this->arg('action'),
common_language(),
- $this->user->id,
+ $this->target->id,
strtotime($this->lists[0]->created),
strtotime($this->lists[$last]->created))
)
return null;
}
-
}