Skip to content

Commit 3cf94c5

Browse files
committed
endpoints to fetch children of an item
1 parent 2cf66c3 commit 3cf94c5

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

controllers/ApiController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ public function init($extra) {
446446

447447
$this->scopeObject = !empty($extra['scopeObject']) ? $extra['scopeObject'] : $this->scopeObject;
448448
$this->subset = !empty($extra['subset']) ? $extra['subset'] : $this->subset;
449+
$this->getOnly = !empty($extra['getOnly']) ? $extra['getOnly'] : $this->getOnly;
449450

450451
$this->fileMode = !empty($extra['file'])
451452
? (!empty($_GET['info']) ? 'info' : 'download')

controllers/ItemsController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ public function items() {
425425
);
426426
}
427427
else if ($this->subset == 'children') {
428+
if ($this->getOnly) {
429+
$this->allowMethods(array('GET'));
430+
}
428431
$item = Zotero_Items::getByLibraryAndKey($this->objectLibraryID, $this->objectKey);
429432
if (!$item) {
430433
$this->e404("Item not found");

include/config/routes.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
$router->map('/groups/i:objectGroupID/items/:objectKey/file', array('controller' => 'Items', 'extra' => array('allowHTTP' => true, 'file' => true)));
3535
$router->map('/groups/i:objectGroupID/items/:objectKey/file/view', array('controller' => 'Items', 'extra' => array('allowHTTP' => true, 'file' => true, 'view' => true)));
3636
$router->map('/groups/i:objectGroupID/items/:objectKey/file/view/url', ['controller' => 'Items', 'extra' => ['file' => true, 'viewurl' => true]]);
37+
$router->map('/users/i:objectUserID/items/:objectKey/children', ['controller' => 'Items', 'extra' => ['subset' => 'children', 'getOnly' => true]]);
38+
$router->map('/groups/i:objectGroupID/items/:objectKey/children', ['controller' => 'Items', 'extra' => ['subset' => 'children', 'getOnly' => true]]);
3739

3840
// Full-text content
3941
$router->map('/users/i:objectUserID/items/:objectKey/fulltext', array('controller' => 'FullText', 'action' => 'itemContent'));

0 commit comments

Comments
 (0)