1
votes

I'm creating some custom queries and need to figure out the relation between Member Groups and Document Groups.

My ultimate goal is to display the resources belonging to a particular User Group when a user log in. I am able to get their User ID from Sessions and so the relations I have figured out so far are:

User ID -> Member Groups Table -> ??Unknown table that pairs Member Groups with Document Groups?? -> Document Groups Table- > Resources Table

I just cant find that missing table(s)!

If any one can help me out that would be awesome!

Thanks

(ps: using Revo)

EDIT: added image for assitance

enter image description here

2
Maybe it will help you - forums.modx.com/thread/31499/… - Vasis

2 Answers

0
votes

You could use some of the built-in MODX methods to achieve this.

This is not tested and might not work, but this might be a way to do it:

// userGroups = membergroups
$userGroups = $user->getUserGroups();

foreach ($userGroups as $userGroup) {
    $resGroups = $userGroup->getResourceGroups(); 

    foreach ($resGroups as $resGroup) {
        $resources = $resGroup->getResources();
        // merge resources into an array or something

    }
}

Check out moduser.class.php, modusergroup.class.php, and modresourcegroup.class.php to see the queries behind these methods. You might be able to adapt them to one more efficient query.

Also, if I haven't misunderstood what you want to achieve then your results should be similar to what a user would see in the resource tree in the manager when logged in?

That uses the resource/getnodes.class.php processor, which retrieves all possible resources for each context using getCollection, then loops through each and decides whether to display or not by using $resource->checkPolicy('list'). That might be another approach to consider.

I usually work with custom data rather than MODX resources so would be keen to hear how you get on with this.

0
votes

I know this is really, really old, but I came across this question looking for the answer myself. After a bit more digging I've found that it's the access_resource_groups table that links document_groups and member_groups

  • document_groups.id = access_resource_groups.target
  • member_groups.id = access_resource_groups.principal