Skip to content

Instantly share code, notes, and snippets.

@BobRay
Created August 15, 2012 21:32
Show Gist options
  • Save BobRay/3363864 to your computer and use it in GitHub Desktop.
Save BobRay/3363864 to your computer and use it in GitHub Desktop.
Get user group's media sources (maybe)
<?php
$output = 'No Media Sources found';
$fields = array(
'principal_class' => 'modUserGroup',
'principal' => $userGroupId,
);
$sources = $modx->getCollection('modAccessMediaSource', $fields);
if ($sources) {
$output = '<p>Media Source IDs:</p>';
foreach ($sources as $source) {
$id = $source->get('target');
$mediaSource = $modx->getObject('modMediaSource', $id);
if ($mediaSource) {
$name = $mediaSource->get('name');
}
$output .= '<p >ID:' . $id . ' -- NAME:' . $name . '</p>';
}
}
return $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment