Menu

#2286 Room Admin can't edit room bookings

None
closed
nobody
None
1
2021-11-24
2021-01-20
Greg Wilson
No

I've set $mail_settings['room_admin_on_bookings'] = true; on the config file

Room admins are receiving booking notification emails but they're not able to edit bookings others have made in their room.

We previously had some cutsom code in mrbs_auth.inc to allow room admins to edit all bookings for their rooms. I've tried copying it accross to the version we're now using (reports as 1.9.2 but was latest dev version from a couple of weeks ago).

How do I allow Room admins to edit all bookings for their room?

Discussion

  • Campbell Morrison

    Yes, the room_admins are badly named. They just receive notification emails. If you want them to have admin rights for their room then you need to edit the function is_book_admin() in mrbs_auth.inc and change line 436 from

      return (isset($mrbs_user) && ($mrbs_user->level >= 2));
    

    to

      if (!isset($mrbs_user))
      {
        return false;
      }
    
      if ($mrbs_user->level >= 2)
      {
        return true;
      }
    
      $room_details = get_room_details($rooms);
      if (isset($room_details) && isset($room_details['room_admin_email']))
      {
        $room_admins = explode(', ', $room_details['room_admin_email']);
        return (in_array(utf8_strtolower($mrbs_user->email), $room_admins));
      }
    
      return false;
    

    I haven't tested this though.

     
  • Greg Wilson

    Greg Wilson - 2021-01-21

    Thanks Campbell. That fixed it.

    Is that code likely to work with later versions? i.e Should I keep it to paste in after the next upgrade of MRBS?

    Cheers,

    Greg.

     
  • Campbell Morrison

    Yes, you'll need to hang on to that code and apply it to later versions. In due course you won't need it though as we'll be rolling out the ability to create "roles" and "groups" and assign roles to groups and users. So you'll be able to give users and groups admin abilities for a room or an area.

     
  • Anonymous

    Anonymous - 2021-11-15

    I tested it but it seems is ot working. I see for reservation created under room admin pending status and room admin has no action like system admin.

     
  • Anonymous

    Anonymous - 2021-11-16

    Adding picture
    Leos

     
  • Campbell Morrison

    Which release of MRBS are you running?

     
  • Anonymous

    Anonymous - 2021-11-17

    MRBS 1.9.4
    Leos

     
  • Campbell Morrison

    Have they otherwise got admin rights for the room? In other words can they delete another person's booking for that room?

     
  • Anonymous

    Anonymous - 2021-11-18

    Yes, they are defined as the admin of the room in room setup. I did test to create with admin1 of room1 booking in room2, but admin2 of room2 has no pending approval and he can not delete test booking in room2 created by admin1. We are local auth. via email address

     
  • Anonymous

    Anonymous - 2021-11-18

    Modified file attached

     
  • Campbell Morrison

    Have the email addresses of your room_admins got upper case characters in them?

     
  • Anonymous

    Anonymous - 2021-11-23

    Yes, I used some upper case in email address fro better reading. Do you recomend use only lower cases?

     
  • Campbell Morrison

    No, upper case is fine. But it explains why it's not working: there's a bug in the code above. To fix it replace

        return (in_array(utf8_strtolower($mrbs_user->email), $room_admins));
    

    by

        return (in_arrayi($mrbs_user->email, $room_admins));
    
     
  • Anonymous

    Anonymous - 2021-11-23

    I set lower case to emails and log with lowercase email but no change . admin1 of room1 which was used to book room1 and room2 see pending approval but has no action for room1. admin2 do not see any pending approval

     
  • Campbell Morrison

    Here's a version mrbs_auth.inc with some debugging in which will send its output to the browser. Can you let me know what it says when the room admin should be able to have admin powers? You may want to PM me to avoid broadcasting confidential email addresses.

     

    Last edit: Campbell Morrison 2021-11-23
  • Anonymous

    Anonymous - 2021-11-24

    Hi,
    replacement which is mentioned above fixed it. Thank you. It seems that I overlooked it because I wrote my last message in identical time like your advice. It works now with upper cases perfectly.
    Thank you again
    Leos

     
  • Campbell Morrison

    • status: open --> closed
    • Group: -->