mrbs_auth.inc (mrbs-1.9.4) | : | mrbs_auth.inc (mrbs-1.10.0) | ||
---|---|---|---|---|
skipping to change at line 386 | skipping to change at line 386 | |||
// value for $rooms is all rooms. (At the moment $room is ignored, but is passe d here | // value for $rooms is all rooms. (At the moment $room is ignored, but is passe d here | |||
// so that later MRBS can be enhanced to provide fine-grained permissions.) | // so that later MRBS can be enhanced to provide fine-grained permissions.) | |||
// | // | |||
// $all specifies whether the user must be a booking for all $rooms, or just som e of | // $all specifies whether the user must be a booking for all $rooms, or just som e of | |||
// them, ie at least one. | // them, ie at least one. | |||
// | // | |||
// Returns: TRUE if the user is allowed has booking admin rights for | // Returns: TRUE if the user is allowed has booking admin rights for | |||
// the room(s); otherwise FALSE | // the room(s); otherwise FALSE | |||
function is_book_admin($rooms=null, $all=true) | function is_book_admin($rooms=null, $all=true) | |||
{ | { | |||
global $min_booking_admin_level; | ||||
if (is_array($rooms) && (count($rooms) > 0)) | if (is_array($rooms) && (count($rooms) > 0)) | |||
{ | { | |||
if ($all) | if ($all) | |||
{ | { | |||
// We want the user to be a booking admin for all the rooms, | // We want the user to be a booking admin for all the rooms, | |||
// so if for any one room they are not, then return false. | // so if for any one room they are not, then return false. | |||
foreach ($rooms as $room) | foreach ($rooms as $room) | |||
{ | { | |||
if (!is_book_admin($room)) | if (!is_book_admin($room)) | |||
{ | { | |||
skipping to change at line 425 | skipping to change at line 427 | |||
if (is_null($rooms) && !$all) | if (is_null($rooms) && !$all) | |||
{ | { | |||
// Not yet supported. Could support it but need to decide what $rooms=null means. | // Not yet supported. Could support it but need to decide what $rooms=null means. | |||
// Does it mean all rooms in the system or just all rooms in the current are a? | // Does it mean all rooms in the system or just all rooms in the current are a? | |||
throw new \Exception('$rooms===null and $all===false not yet supported.'); | throw new \Exception('$rooms===null and $all===false not yet supported.'); | |||
} | } | |||
$mrbs_user = session()->getCurrentUser(); | $mrbs_user = session()->getCurrentUser(); | |||
return (isset($mrbs_user) && ($mrbs_user->level >= 2)); | return (isset($mrbs_user) && ($mrbs_user->level >= $min_booking_admin_level)); | |||
} | } | |||
// Checks whether the current user has user editing rights | // Checks whether the current user has user editing rights | |||
function is_user_admin() | function is_user_admin() | |||
{ | { | |||
global $min_user_editing_level; | global $min_user_editing_level; | |||
$mrbs_user = session()->getCurrentUser(); | $mrbs_user = session()->getCurrentUser(); | |||
return (isset($mrbs_user) && ($mrbs_user->level >= $min_user_editing_level)); | return (isset($mrbs_user) && ($mrbs_user->level >= $min_user_editing_level)); | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 3 lines changed or added |