Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 6922389

Browse files
committed
ENH: refs #236. Add midas.community.children method to core web API
1 parent f619b70 commit 6922389

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

modules/api/controllers/components/ApiComponent.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,41 @@ function communityGet($args)
488488
return $community->toArray();
489489
}
490490

491+
/**
492+
* Get the immediate children of a community (non-recursive)
493+
* @param token (Optional) Authentication token
494+
* @param id The id of the community
495+
* @return The folders in the community
496+
*/
497+
function communityChildren($args)
498+
{
499+
$this->_validateParams($args, array('id'));
500+
501+
$id = $args['id'];
502+
503+
$modelLoader = new MIDAS_ModelLoader();
504+
$communityModel = $modelLoader->loadModel('Community');
505+
$folderModel = $modelLoader->loadModel('Folder');
506+
$community = $communityModel->load($id);
507+
if(!$community)
508+
{
509+
throw new Exception('Invalid community id', MIDAS_INVALID_PARAMETER);
510+
}
511+
$folder = $folderModel->load($community->getFolderId());
512+
513+
$userDao = $this->_getUser($args);
514+
try
515+
{
516+
$folders = $folderModel->getChildrenFoldersFiltered($folder, $userDao);
517+
}
518+
catch(Exception $e)
519+
{
520+
throw new Exception($e->getMessage(), MIDAS_INTERNAL_ERROR);
521+
}
522+
523+
return array('folders' => $folders);
524+
}
525+
491526
/**
492527
* Return a list of all communities visible to a user
493528
* @param token (Optional) Authentication token

0 commit comments

Comments
 (0)