We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    Does anyone know what the SQL would be to determine if a user ID has access to a given resource [i.e. the relations between which tables]

    I know this can be done with a couple of functions/snippets [hasAccess] but I need to do this with sql for performance reasons.
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
      • 3749
      • 24,544 Posts
      You can look at the checkPolicy() method in core\model\modx\modaccessibleobject.class.php. If you can figure it out, you're way ahead of me. wink


      If I had to know, I think I'd write an external snippet that instantiated MODX, with code something like this, then trace through it in a debugger:

      $userId = 12; // set to a real user
      $resource = $modx->getObject('modResource', 12); // set to a real resource
      $hasPermission = $resource->checkPolicy('save');


        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