// if the current user is an administrator or manager of the current object
     if (isset($_REQUEST["validated"])) {
         $validated = 1;
     } else {
         $validated = 0;
     }
 } else {
     if (isset($_REQUEST["validated"])) {
         $validated = 1;
     } else {
         if (getObjectInfos($_REQUEST["object_id"], "is_managed")) {
             // checks if any date of the current booking was changed
             $sql = "SELECT book_start, book_end, validated FROM rs_data_bookings WHERE book_id = " . $_REQUEST["book_id"] . ";";
             $temp = db_query($database_name, $sql, "no", "no");
             $temp_ = fetch_array($temp);
             if ($temp_["book_start"] != DateAndHour(dateFormat($_REQUEST["start_date"], "", "Y-m-d"), $_REQUEST["start_hour"]) || $temp_["book_end"] != DateAndHour(DateReformat($_REQUEST["end_date"]), $_REQUEST["end_hour"])) {
                 // at least one date was changed, booking must be re-validated if the object is managed by someone
                 $validated = 0;
             } else {
                 // no date changes, the booking validation remains in its previous state
                 $validated = $temp_["validated"];
             }
         } else {
             // no manager, the booking is always validated
             $validated = 1;
         }
     }
     // if
 }
 // if
 insertBooking("update", $_REQUEST["book_id"], $_REQUEST["booker_id"], $_REQUEST["object_id"], $booking_start, $booking_end, $_REQUEST["misc_info"], $validated);
		</head>

		<body>

		<?php 
    echo $error_message;
    ?>

		</body>

		</html>
<?php 
} else {
    $start = DateAndHour(dateFormat($start_date, "", "Y-m-d"), $start_hour);
    $end = DateAndHour(dateFormat($end_date, "", "Y-m-d"), $end_hour);
    $start_ = date("Y-m-d H:i", strtotime($start));
    $end_ = date("Y-m-d H:i", strtotime($end));
    $family_id = checkVar("sql", $_POST["family_id"], "int", "", "", "", "", 0, 1);
    // extracts family name using family_id as parameter
    $sql = "SELECT family_name FROM rs_param_families WHERE family_id = " . $family_id . ";";
    $temp = db_query($database_name, $sql, "no", "no");
    $temp_ = fetch_array($temp);
    $family_name = $temp_["family_name"];
    // lists objects which are booked within the specified time range
    $sql = "SELECT DISTINCT rs_data_objects.object_id ";
    $sql .= "FROM rs_data_bookings INNER JOIN rs_data_objects ON rs_data_bookings.object_id = rs_data_objects.object_id ";
    $sql .= "WHERE rs_data_objects.family_id = " . $family_id . " ";
    $sql .= "AND ((rs_data_bookings.book_end > '" . $start . "' ";
    $sql .= "AND rs_data_bookings.book_end <= '" . $end . "') ";
    $sql .= "OR (rs_data_bookings.book_start < '" . $end . "' ";