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>