We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42928
    • 13 Posts
    I'm currently trying to find the best way of doing this. Basically I have 6 different user groups, some users may be member of multiple groups. Linked to this I have 6 resource groups (labelled the same). I need to figure out a way so that when a new resource is created it is assigned to specific resource groups and this is linked to their counterpart user groups. I then need to check that members of those user groups have accessed that resource. To illustrate this:
    1) I create a resource called "user group A needs to read this!!!"
    2) I assign that document to the resource group "A"
    3) User group "A" are then notified they need to read this
    4) A member of user group "A" has a bit of time on their hands and logs in to read it
    5) modx logs that this member of user group "A" has correctly accessed the resource assigned to resource group "A" and they are not longer required to read it.

    As I said, I'm currently internally throwing around the best ways of doing this but I thought I'd post now before I decide on a path forward in case I've missed something obvious.

    Any input most welcome.

    Jum
    • You would need a plugin using OnHandleRequest that gets the user ID or username from the SESSION and stores it somewhere, a file or a custom table. The plugin would need to have code to check what page is being requested, and only continue in the case of relevant pages being requested.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 42928
        • 13 Posts
        OnHandleRequest... that might just be the link I was looking for. Perhaps combining it with classextender to create a table within the user profile?
        • Yes, that would work.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 42928
            • 13 Posts
            Many thanks for the quick input sottwell.
              • 3749
              • 24,544 Posts
              You might consider a field that you store the array of pages visited in JSON format. If you specify it as a json field, I think MODX will automatically convert it to a PHP array when you get() it and from a PHP array to a JSON string when you set() it.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 42928
                • 13 Posts
                Thanks BobRay, I start tomorrow so I'll feedback based on my tests.
                • If you're going to use a JSON array, you could just use the User extended fields.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 42928
                    • 13 Posts
                    I thought using User extended fields would be pretty slow ?
                      • 3749
                      • 24,544 Posts
                      You have to get the User Profile, but that's not significantly slower than getting the custom class created by ClassExtender, especially if you get it this way:

                      $userId = $modx->user->get('id');
                      $profile = $modx->getObject('modUserProfile', array('internalKey' => $userId));
                      if ($profile) {
                          $extended = $profile->get('extended');
                      }


                      You'll have to do the in_array() and manipulation of the Resource ID array either way.


                      What's very slow is if you have to search and/or sort based on what's in the 'extended' field.
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting