summaryrefslogtreecommitdiffstats
path: root/external
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-06-10 19:02:36 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-06-11 00:25:00 +0200
commit653b9f82ab2c397543c9f7da23ad79444ef41e45 (patch)
treedb50655eb89907c435bc5929a69f53079a81ad81 /external
parent8bffbedcd8fe1a8e7f40e27fdd44b8bd329b75ff (diff)
implement starring and marking as read for multiple items
Diffstat (limited to 'external')
-rw-r--r--external/itemapi.php57
1 files changed, 50 insertions, 7 deletions
diff --git a/external/itemapi.php b/external/itemapi.php
index a67d5a171..6b4aeb80c 100644
--- a/external/itemapi.php
+++ b/external/itemapi.php
@@ -107,7 +107,7 @@ class ItemAPI extends Controller {
$this->itemBusinessLayer->read($itemId, $isRead, $userId);
return new NewsAPIResult();
} catch(BusinessLayerException $ex){
- return new NewsAPIResult(null, NewsAPIResult::NOT_FOUND_ERROR,
+ return new NewsAPIResult(null, NewsAPIResult::NOT_FOUND_ERROR,
$ex->getMessage());
}
}
@@ -121,7 +121,7 @@ class ItemAPI extends Controller {
$this->itemBusinessLayer->star($feedId, $guidHash, $isStarred, $userId);
return new NewsAPIResult();
} catch(BusinessLayerException $ex){
- return new NewsAPIResult(null, NewsAPIResult::NOT_FOUND_ERROR,
+ return new NewsAPIResult(null, NewsAPIResult::NOT_FOUND_ERROR,
$ex->getMessage());
}
}
@@ -156,13 +156,56 @@ class ItemAPI extends Controller {
}
+ private function setMultipleRead($isRead) {
+ $userId = $this->api->getUserId();
+ $items = $this->params('items');
+
+ foreach($items as $id) {
+ try {
+ $this->itemBusinessLayer->read($id, $isRead, $userId);
+ } catch(BusinessLayerException $ex) {
+ continue;
+ }
+ }
+
+ return new NewsAPIResult();
+ }
+
+
public function readMultiple() {
+ return $this->setMultipleRead(true);
+ }
+
+
+ public function unreadMultiple() {
+ return $this->setMultipleRead(false);
+ }
+
+
+ private function setMultipleStarred($isStarred) {
$userId = $this->api->getUserId();
- //$ids = $this->params('_put');
- //print_r(json_decode(file_get_contents('php://input'), true));
-
- exit();
- //return new NewsAPIResult();
+ $items = $this->params('items');
+
+ foreach($items as $item) {
+ try {
+ $this->itemBusinessLayer->star($item['feedId'],
+ $item['guidHash'], $isStarred, $userId);
+ } catch(BusinessLayerException $ex) {
+ continue;
+ }
+ }
+
+ return new NewsAPIResult();
+ }
+
+
+ public function starMultiple() {
+ return $this->setMultipleStarred(true);
+ }
+
+
+ public function unstarMultiple() {
+ return $this->setMultipleStarred(false);
}
}