diff options
-rw-r--r-- | README.rst | 1 | ||||
-rw-r--r-- | bl/itembl.php | 6 | ||||
-rw-r--r-- | controller/itemcontroller.php | 9 | ||||
-rw-r--r-- | tests/controller/ItemControllerTest.php | 14 |
4 files changed, 22 insertions, 8 deletions
diff --git a/README.rst b/README.rst index b6deee949..39367b96e 100644 --- a/README.rst +++ b/README.rst @@ -10,7 +10,6 @@ TODO * Port coffeescript * make export work -> generate xml with template * implement findAll methods in itemBl and itemMapper -* also pass in show all in itemcontroller * make feed update work * fix search plugin * fix background job
\ No newline at end of file diff --git a/bl/itembl.php b/bl/itembl.php index c5b422d06..6f3e5d002 100644 --- a/bl/itembl.php +++ b/bl/itembl.php @@ -36,12 +36,14 @@ class ItemBl extends Bl { } - public function findAllNew($id, $type, $updatedSince, $userId){ + public function findAllNew($id, $type, $updatedSince, + $showAll, $userId){ // TODO all the crazy finding of items } - public function findAll($id, $type, $limit, $offset, $userId){ + public function findAll($id, $type, $limit, $offset, + $showAll, $userId){ // TODO all the crazy finding of items } diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php index e6358ce0e..ef7276eba 100644 --- a/controller/itemcontroller.php +++ b/controller/itemcontroller.php @@ -49,17 +49,20 @@ class ItemController extends Controller { */ public function items(){ $userId = $this->api->getUserId(); + $showAll = $this->api->getUserValue($userId, 'showAll') === 'true'; + $limit = $this->params('limit'); $type = $this->params('type'); $id = $this->params('id'); - // TODO: pass in showAll value if($limit !== null){ $offset = $this->params('offset', 0); - $items = $this->itemBl->findAll($id, $type, $limit, $offset, $userId); + $items = $this->itemBl->findAll($id, $type, $limit, $offset, + $showAll, $userId); } else { $updatedSince = $this->params('updatedSince'); - $items = $this->itemBl->findAllNew($id, $type, $updatedSince, $userId); + $items = $this->itemBl->findAllNew($id, $type, $updatedSince, + $showAll, $userId); } $params = array( diff --git a/tests/controller/ItemControllerTest.php b/tests/controller/ItemControllerTest.php index 2b389adad..1c3ed44f0 100644 --- a/tests/controller/ItemControllerTest.php +++ b/tests/controller/ItemControllerTest.php @@ -228,12 +228,17 @@ class ItemControllerTest extends ControllerTestUtility { $this->controller = $this->getPostController($post); $this->api->expects($this->once()) + ->method('getUserValue') + ->with($this->equalTo($this->user), + $this->equalTo('showAll')) + ->will($this->returnValue('true')); + $this->api->expects($this->once()) ->method('getUserId') ->will($this->returnValue($this->user)); $this->bl->expects($this->once()) ->method('findAll') ->with($post['id'], $post['type'], $post['limit'], - $post['offset'], $this->user) + $post['offset'], true, $this->user) ->will($this->returnValue($result['items'])); $response = $this->controller->items(); @@ -254,12 +259,17 @@ class ItemControllerTest extends ControllerTestUtility { $this->controller = $this->getPostController($post); $this->api->expects($this->once()) + ->method('getUserValue') + ->with($this->equalTo($this->user), + $this->equalTo('showAll')) + ->will($this->returnValue('true')); + $this->api->expects($this->once()) ->method('getUserId') ->will($this->returnValue($this->user)); $this->bl->expects($this->once()) ->method('findAllNew') ->with($post['id'], $post['type'], $post['updatedSince'], - $this->user) + true, $this->user) ->will($this->returnValue($result['items'])); $response = $this->controller->items(); |