function tripal_get_user_collections
3.x tripal.collections.api.inc | tripal_get_user_collections($uid) |
Retrieves an array of collections for a user.
Parameters
$uid: The User ID
Return value
An array of TripalEntityCollection objects.
Related topics
File
- tripal/
api/ tripal.collections.api.inc, line 84 - Provides the API for working with Data collections. This includes creation, experiation, and retreival.
Code
function tripal_get_user_collections($uid) {
if (!$uid) {
throw new Exception('tripal_get_user_collections: Missing the $uid argument.');
}
$user = user_load($uid);
if (!$user) {
throw new Exception('tripal_get_user_collections: Invalid $uid provided.');
}
$collections = array();
$results = db_select('tripal_collection', 'tc')
->fields('tc', array('collection_id'))
->condition('uid', $uid)
->execute();
while ($collection_id = $results->fetchField()) {
$collection = new TripalEntityCollection();
$collection->load($collection_id);
$collections[] = $collection;
}
return $collections;
}