summaryrefslogtreecommitdiffstats
path: root/external
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-05-02 18:45:10 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-05-02 18:45:10 +0200
commite9878cb5b583bc993a9f3a482d0b371bbeea5bd2 (patch)
tree203a174ac6a4427cd17c9cbfa35ab926f49607db /external
parent3d405e0541d6c109d8c0824807f56262fe290266 (diff)
added api method for getting items
Diffstat (limited to 'external')
-rw-r--r--external/itemapi.php27
1 files changed, 25 insertions, 2 deletions
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);
}