From e9878cb5b583bc993a9f3a482d0b371bbeea5bd2 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 2 May 2013 18:45:10 +0200 Subject: added api method for getting items --- external/itemapi.php | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'external/itemapi.php') diff --git a/external/itemapi.php b/external/itemapi.php index 53b88f4e4..e4d8ab904 100644 --- a/external/itemapi.php +++ b/external/itemapi.php @@ -36,7 +36,6 @@ use \OCA\News\BusinessLayer\BusinessLayerException; class ItemAPI extends Controller { private $itemBusinessLayer; - parent::__construct($api, $request); public function __construct(API $api, Request $request, @@ -47,7 +46,31 @@ class ItemAPI extends Controller { public function getAll() { - + $result = array( + 'items' => array() + ); + + $userId = $this->api->getUserId(); + $batchSize = (int) $this->params('batchSize'); + $offset = (int) $this->params('offset', 0); + $type = (int) $this->params('type'); + $id = (int) $this->params('id'); + $showAll = $this->params('getRead') === 'true'; + + $items = $this->itemBusinessLayer->findAll( + $id, + $type, + $batchSize, + $offset, + $showAll, + $userId + ); + + foreach ($items as $item) { + array_push($result['items'], $item->toAPI()); + } + + return new NewsAPIResult($result); } -- cgit v1.2.3