We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20546
    • 74 Posts
    Wow, this many-to-many relationship works fine. smiley
    Now, I wanted to secure the document in which I call the snippet that shows me the hotels. After login it doesn’t show me the hotels. The twAccessHotel-array is empty now.

    The same happens when I have two public documents with the hotel-snippet and the old test-snippet. When I login and go to the Test-page it shows me the correct data when I change to the Hotel-page the twAccessHotel-array is empty. It occurs also at the Test-page when I first get to the Hotel-page.

    If I could get this working that would be great.
    • Your twAccessHotel class has nothing to do with MODx Resources; protecting those would still be done with Resource Groups. Or am I misunderstanding your question?
        • 20546
        • 74 Posts
        Sorry, my question was rather vague. I protected a Resource (document) in manager with the access permissions. The protection has nothing to do with my twAccessHotel.

        Within this protected Resource I’ve my Snippet which contains the getCollection(). When I login (frontend) and go to this Resource, the Snippet doesn’t return any Hotels. But when the Resource is unprotected I get all the Hotels.

        I hope you understand my problem.
        • Quote from: mt85 at May 27, 2010, 12:20 PM

          Sorry, my question was rather vague. I protected a Resource (document) in manager with the access permissions. The protection has nothing to do with my twAccessHotel.

          Within this protected Resource I’ve my Snippet which contains the getCollection(). When I login (frontend) and go to this Resource, the Snippet doesn’t return any Hotels. But when the Resource is unprotected I get all the Hotels.

          I hope you understand my problem.
          I’m afraid it is just not clicking with me. You have two separate sets of policies being assigned to your user, those for accessing Resources via Resource Groups and those for accessing Hotels via Hotel Groups. I don’t understand why logging in to front-end would change that, unless you are viewing it while logged into the manager in the first place and changing users by logging into the front-end directly. When developing pages that change content based on security-access, it’s best to log out of the manager or use a different browser, unless you need to view something unpublished. Keep in mind that when viewing the front-end while logged into the manager in the same browser session means that you will inherit that user’s access controls. Once you log in to the front-end in that session, then you get the access policies of the user you login to that specific context with.
            • 20546
            • 74 Posts
            That’s the funny thing. I always use a different browser for front-end viewing.

            That’s what I have:
            – A resource (hotel list) which is accessible for Resource Group: Clients
            – A user which is allowed to access the Resource Group: Clients
            – The twHotel-thing which shows the database-records based on the user that is logged in (is called within a snippet that is placed in resource (hotel list))

            Now, when I log in and go to the resource (hotel list) I don’t get any hotels. When I take a look at the session information, the twAccessHotel-session is empty... I don’t have an idea why. Because when I make the resource (hotel list) public I get the hotel entries assigned to my user-login.

            Why is twAccessHotel empty? Is it because the attributes were already loaded without twAccessHotel and it doesn’t reload it properly?
            If I add $modx->user->getAttributes(’twHotel’, ’web’, true) at the top of the snippet again, it works...
              • 3749
              • 24,544 Posts
              Quote from: mt85 at May 27, 2010, 01:34 PM



              That’s what I have:
              – A resource (hotel list) which is accessible for Resource Group: Clients
              – A user which is allowed to access the Resource Group: Clients
              – The twHotel-thing which shows the database-records based on the user that is logged in (is called within a snippet that is placed in resource (hotel list))

              Now, when I log in and go to the resource (hotel list) I don’t get any hotels. When I take a look at the session information, the twAccessHotel-session is empty... I don’t have an idea why. Because when I make the resource (hotel list) public I get the hotel entries assigned to my user-login.

              Why is twAccessHotel empty? Is it because the attributes were already loaded without twAccessHotel and it doesn’t reload it properly?
              If I add $modx->user->getAttributes(’twHotel’, ’web’, true) at the top of the snippet again, it works...

              It’s really hard to say without more information.

              Did you change any policies?
              Did you use the "administrator" policy for your Context Access ACL entries and the "resource" policy for your Resource Group Access ACL entries?
              Does your snippet perform any manager actions?

                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
                • 20546
                • 74 Posts
                Did you change any policies?
                Did you use the "administrator" policy for your Context Access ACL entries and the "resource" policy for your Resource Group Access ACL entries?
                Does your snippet perform any manager actions?

                No, I haven’t changed any policies. That’s what I have:
                – User Group > Context Access > Access Policy: Resource
                – User Group > Resource Group Access > Access Policy: Resource

                I’ve found this in the log after logging in as a webuser:
                [2010-05-28 10:52:12] (ERROR @ /index.php) Could not load class: twAccessHotel from mysql.twaccesshotel.
                [2010-05-28 10:52:12] (ERROR @ /index.php) Could not get table name for class:
                • Quote from: mt85 at May 28, 2010, 08:53 AM

                  I’ve found this in the log after logging in as a webuser:
                  [2010-05-28 10:52:12] (ERROR @ /index.php) Could not load class: twAccessHotel from mysql.twaccesshotel.
                  [2010-05-28 10:52:12] (ERROR @ /index.php) Could not get table name for class:
                  Well, that’s definitely a problem if the class cannot even be loaded. How are you adding your custom package?
                    • 20546
                    • 74 Posts
                    Quote from: OpenGeek at May 28, 2010, 12:46 PM

                    Well, that’s definitely a problem if the class cannot even be loaded. How are you adding your custom package?

                    I add the package within the snippet, that calls the database records:
                    $model_path = $modx->getOption('core_path').'components/hotels/model/';
                    $modx->addPackage('hotels',$model_path);
                    
                    $stores = $modx->getCollection('twHotel');
                    foreach ($stores as $store) {
                    echo $store->get('name')."<br />";
                    }
                    

                    Where do I have to load the package exactly?
                    • Quote from: mt85 at May 28, 2010, 01:06 PM

                      Quote from: OpenGeek at May 28, 2010, 12:46 PM

                      Well, that’s definitely a problem if the class cannot even be loaded. How are you adding your custom package?

                      I add the package within the snippet, that calls the database records:
                      $model_path = $modx->getOption('core_path').'components/hotels/model/';
                      $modx->addPackage('hotels',$model_path);
                      
                      $stores = $modx->getCollection('twHotel');
                      foreach ($stores as $store) {
                      echo $store->get('name')."<br />";
                      }
                      

                      Where do I have to load the package exactly?
                      To extension_packages; since this data has to be loaded when a user session is started, it must be available on every request.