We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20546
    • 74 Posts
    To extension_packages

    Do I have to create a new System Setting in Manager with the key extension_packages?
    • Quote from: mt85 at May 28, 2010, 02:24 PM

      To extension_packages

      Do I have to create a new System Setting in Manager with the key extension_packages?
      Correct; refer to this thread: http://modxcms.com/forums/index.php/topic,47758.msg280528.html#msg280528
        • 20546
        • 74 Posts
        Again, thank you so much. It works great!

        I hope that’s the last question. I have the table: hotels which is secured and a related table: hotel_rooms which is a xPDOSimpleObject.
        I pass the ID of the hotel_room-record to delete the row. Before doing this I want to check if the user has permission to the related hotel.

        Is this the right way to do that?
        $id = $_GET['id'];
        $room = $modx->getObject('twHotelRoom',$id);
        $hotelid = $room->get('hotel');
        
        $hotel = $modx->getObject('twHotel',$hotelid);
        
        if(!$hotel) {
        $modx->sendUnauthorizedPage();
        }
        else {
        //delete script
        }


        When I have a model like the following, isn’t it possible to use the getOne()-method?
        $hotelroom = $modx->getObject('twHotelRoom',$id);  
        $hotel = $hotelroom->getOne('twHotel');  
        


            <object class="twHotel" table="hotels" extends="modAccessibleSimpleObject">
        	...
                <composite alias="Rooms" class="twHotelRoom" local="id" foreign="hotel" owner="local" cardinality="many" />
            </object>
        
            <object class="twHotelRoom" table="hotel_rooms" extends="modAccess">
                <aggregate alias="Hotel" class="twHotel" local="hotel" foreign="id" owner="foreign" cardinality="one" />
            </object>
        • Quote from: mt85 at May 28, 2010, 03:30 PM

          I hope that’s the last question. I have the table: hotels which is secured and a related table: hotel_rooms which is a xPDOSimpleObject.
          I pass the ID of the hotel_room-record to delete the row. Before doing this I want to check if the user has permission to the related hotel.

          Is this the right way to do that?
          $id = $_GET['id'];
          $room = $modx->getObject('twHotelRoom',$id);
          $hotelid = $room->get('hotel');
          
          $hotel = $modx->getObject('twHotel',$hotelid);
          
          if(!$hotel) {
          $modx->sendUnauthorizedPage();
          }
          else {
          //delete script
          }

          That would be one way to do it.

          Quote from: mt85 at May 28, 2010, 03:30 PM

          When I have a model like the following, isn’t it possible to use the getOne()-method?
          $hotelroom = $modx->getObject('twHotelRoom',$id);  
          $hotel = $hotelroom->getOne('twHotel');  
          

          Yes, but always use the alias of the related object; the class may not be unique for the specific aggregate or composite, i.e.
          $hotel = $hotelroom->getOne('Hotel');