Hi all,
I've been setting up MRBS as well, and used Chris' code to implement the 'book ahead' restriction.
We wanted to make it so that the restriction didn't apply to administrators - turned out to be quite easy.
We changed Chris' code in edit_entry_handler - add the underlined code:
If (check_allowed($_GET["month"], $_GET["day"], $_GET["year"], $max_days_ahead)[u] or getAuthorised(2)[/u]){
}
else{
$err = "You cannot book more than ".$max_days_ahead." days ahead";
$hide_title = 1;
}
I also made it so that the same 'book ahead' restriction applied to the delete code (for why we needed to do this, read on) - in del_entry.php, add the underlined code:
if(getAuthorised(1) && ($info = mrbsGetEntryInfo($id)) && ($series != 1 || getAuthorised(2)))
{
$day = strftime("%d", $info["start_time"]);
$month = strftime("%m", $info["start_time"]);
$year = strftime("%Y", $info["start_time"]);
$area = mrbsGetRoomArea($info["room_id"]);
[u]if (check_allowed($month, $day, $year, $max_days_ahead) or getAuthorised(2)){
}
else{
showAccessDenied($day, $month, $year, $area);
exit();
}[/u]
if (MAIL_ADMIN_ON_DELETE)
{
include_once "functions_mail.inc";
// Gather all fields values for use in emails.
$mail_previous = getPreviousEntryData($id, $series);
}
Finally, we also made it so that any logged in user was able to edit existing bookings, not just the owner and administrators. (This was why it was important for us to make the Book Ahead restriction apply to deleting entries as well as adding). Edit mrbs_auth.inc and change the GetWritable function:
function getWritable($creator, $user)
{
global $auth;
// Always allowed to modify your own stuff
if(strcasecmp($creator, $user) == 0)
return 1;
[u]// if(authGetUserLevel($user, $auth["admin"]) >= 2)
if(authGetUserLevel($user, $auth["admin"]) >= 1)[/u]
return 1;
// Unathorised access
return 0;
}
Hope these code changes help anyone else trying to do the same thing!