does this work?
<?php
if ($resourcegroups = $modx->resource->getGroupsList()) {
foreach ($resourcegroups as $resourcegroup) {
if ($resourcegroup->get('access') === '1') {
if ($usergroups = $resourcegroup->getUserGroups())
foreach ($usergroups as $usergroup) {
var_dump($usergroup->toArray());
}
}
}
}
As far as I can tell getUserGroups returns an array of id => string where the second is a modUserGroup name (I don't have any user group ACLs in my local install so I can't be sure).
Calling toArray() on it shouldn't work. echo $userGroup should.
This might be another way to go:
$resource->getMany('ResourceGroupResources')
[ed. note: BobRay last edited this post 13 years, 7 months ago.]
@Bruno: Unfortunately no. getGroupsList() returns an array with two entries: the first is the resourceGroup Collection, the second the total of resourceGroups. What's a bit strange to me, it seems to return all the resourcegroups available in the system, with access ==='1' in the resourceGroups actually linked to.
@Bob: This could be (the hard) way. Via 'ResourceGroup' I come to 'modResourceGroup'. But out of the schema I don't find the linkage from 'modResourceGroup' to 'modUserGroup'.
modResourceGroup->getMany('Acls') will get you all the modAccessResourceGroup objects, but you're right, it's obscure and your original method should be better since they would, in theory, be organized.