Skip to content

Commit

Permalink
endpoints to fetch children of an item
Browse files Browse the repository at this point in the history
  • Loading branch information
abaevbog committed Jun 13, 2023
1 parent 2cf66c3 commit 3cf94c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ public function init($extra) {

$this->scopeObject = !empty($extra['scopeObject']) ? $extra['scopeObject'] : $this->scopeObject;
$this->subset = !empty($extra['subset']) ? $extra['subset'] : $this->subset;
$this->getOnly = !empty($extra['getOnly']) ? $extra['getOnly'] : $this->getOnly;

$this->fileMode = !empty($extra['file'])
? (!empty($_GET['info']) ? 'info' : 'download')
Expand Down
3 changes: 3 additions & 0 deletions controllers/ItemsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ public function items() {
);
}
else if ($this->subset == 'children') {
if ($this->getOnly) {
$this->allowMethods(array('GET'));
}
$item = Zotero_Items::getByLibraryAndKey($this->objectLibraryID, $this->objectKey);
if (!$item) {
$this->e404("Item not found");
Expand Down
2 changes: 2 additions & 0 deletions include/config/routes.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
$router->map('/groups/i:objectGroupID/items/:objectKey/file', array('controller' => 'Items', 'extra' => array('allowHTTP' => true, 'file' => true)));
$router->map('/groups/i:objectGroupID/items/:objectKey/file/view', array('controller' => 'Items', 'extra' => array('allowHTTP' => true, 'file' => true, 'view' => true)));
$router->map('/groups/i:objectGroupID/items/:objectKey/file/view/url', ['controller' => 'Items', 'extra' => ['file' => true, 'viewurl' => true]]);
$router->map('/users/i:objectUserID/items/:objectKey/children', ['controller' => 'Items', 'extra' => ['subset' => 'children', 'getOnly' => true]]);
$router->map('/groups/i:objectGroupID/items/:objectKey/children', ['controller' => 'Items', 'extra' => ['subset' => 'children', 'getOnly' => true]]);

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

0 comments on commit 3cf94c5

Please sign in to comment.