示例#1
0
/** mrbsCheckFree()
 * 
 * Check to see if the time period specified is free
 * 
 * $room_id   - Which room are we checking
 * $starttime - The start of period
 * $endtime   - The end of the period
 * $ignore    - An entry ID to ignore, 0 to ignore no entries
 * $repignore - A repeat ID to ignore everything in the series, 0 to ignore no series
 * 
 * Returns:
 *   nothing   - The area is free
 *   something - An error occured, the return value is human readable
 */
function mrbsCheckFree($room_id, $starttime, $endtime, $ignore, $repignore)
{
    global $tbl_entry;
    global $enable_periods;
    global $periods;
    # Select any meetings which overlap ($starttime,$endtime) for this room:
    $sql = "SELECT id, name, start_time FROM {$tbl_entry} WHERE\n\t\tstart_time < {$endtime} AND end_time > {$starttime}\n\t\tAND room_id = {$room_id}";
    if ($ignore > 0) {
        $sql .= " AND id <> {$ignore}";
    }
    if ($repignore > 0) {
        $sql .= " AND repeat_id <> {$repignore}";
    }
    $sql .= " ORDER BY start_time";
    $res = sql_query($sql);
    if (!$res) {
        return sql_error();
    }
    if (sql_count($res) == 0) {
        sql_free($res);
        return "";
    }
    # Get the room's area ID for linking to day, week, and month views:
    $area = mrbsGetRoomArea($room_id);
    # Build a string listing all the conflicts:
    $err = "";
    for ($i = 0; $row = sql_row($res, $i); $i++) {
        $starts = getdate($row[2]);
        $param_ym = "area={$area}&year={$starts['year']}&month={$starts['mon']}";
        $param_ymd = $param_ym . "&day={$starts['mday']}";
        if ($enable_periods) {
            $p_num = $starts['minutes'];
            $startstr = userdate($row[2], '%A %d %B %Y, ') . $periods[$p_num];
        } else {
            $startstr = userdate($row[2], '%A %d %B %Y %H:%M:%S');
        }
        $err .= "<LI><A HREF=\"view_entry.php?id={$row['0']}\">{$row['1']}</A>" . " ( " . $startstr . ") " . "(<A HREF=\"day.php?{$param_ymd}\">" . get_string('viewday', 'block_mrbs') . "</a>" . " | <A HREF=\"week.php?room={$room_id}&{$param_ymd}\">" . get_string('viewweek', 'block_mrbs') . "</a>" . " | <A HREF=\"month.php?room={$room_id}&{$param_ym}\">" . get_string('viewmonth', 'block_mrbs') . "</a>)";
    }
    return $err;
}
    $var = VAR_PREFIX . $field['name'];
    ${$var} = get_form_var($var, $type);
    if ($type == 'int' && ${$var} === '') {
        unset(${$var});
    }
}
// Check the user is authorised for this page
checkAuthorised();
// Also need to know whether they have admin rights
$user = getUserName();
$required_level = isset($max_level) ? $max_level : 2;
$is_admin = authGetUserLevel($user) >= $required_level;
// Done changing area or room information?
if (isset($change_done)) {
    if (!empty($room)) {
        $area = mrbsGetRoomArea($room);
    }
    Header("Location: admin.php?day={$day}&month={$month}&year={$year}&area={$area}");
    exit;
}
// Intialise the validation booleans
$valid_email = TRUE;
$valid_resolution = TRUE;
$enough_slots = TRUE;
$valid_area = TRUE;
$valid_room_name = TRUE;
// PHASE 2
// -------
if ($phase == 2) {
    // Unauthorised users shouldn't normally be able to reach Phase 2, but just in case
    // they have, check again that they are allowed to be here
示例#3
0
<?php

// $Id$
// Index is just a stub to redirect to the appropriate view
// as defined in config.inc.php using the variable $default_view
// If $default_room is defined in config.inc.php then this will
// be used to redirect to a particular room.
require_once "grab_globals.inc.php";
require_once "config.inc.php";
require_once "dbsys.inc";
require_once "mrbs_sql.inc";
$day = date("d");
$month = date("m");
$year = date("Y");
switch ($default_view) {
    case "month":
        $redirect_str = "month.php?year={$year}&month={$month}";
        break;
    case "week":
        $redirect_str = "week.php?year={$year}&month={$month}&day={$day}";
        break;
    default:
        $redirect_str = "day.php?day={$day}&month={$month}&year={$year}";
}
if (!empty($default_room)) {
    $area = mrbsGetRoomArea($default_room);
    $room = $default_room;
    $redirect_str .= "&area={$area}&room={$room}";
}
header("Location: {$redirect_str}");
示例#4
0
                    // getPreviousEntryData to prepare entry comparison.
                    if (isset($id)) {
                        $mail_previous = getPreviousEntryData($id, 0);
                    }
                    $result = notifyAdminOnBooking(!isset($id), $new_id);
                }
            }
        }
    }
    # end foreach $rooms
    # Delete the original entry
    if (isset($id)) {
        mrbsDelEntry(getUserName(), $id, $edit_type == "series", 1);
    }
    sql_mutex_unlock("{$tbl_entry}");
    $area = mrbsGetRoomArea($room_id);
    # Now its all done go back to the day view
    Header("Location: day.php?year={$year}&amp;month={$month}&amp;day={$day}&amp;area={$area}");
    exit;
}
# The room was not free.
sql_mutex_unlock("{$tbl_entry}");
if (strlen($err)) {
    print_header($day, $month, $year, $area);
    echo "<H2>" . get_vocab("sched_conflict") . "</H2>";
    if (!isset($hide_title)) {
        echo get_vocab("conflict") . ":";
        echo "<UL>";
    }
    echo $err;
    if (!isset($hide_title)) {
示例#5
0
function showAccessDeniedMaxBookings($day, $month, $year, $id_room, $back)
{
    global $vocab;
    print_header($day, $month, $year, $type = "with_session");
    ?>
	<h1><?php 
    echo get_vocab("accessdenied");
    ?>
</h1>
	<p>
		<?php 
    // Limitation par ressource
    $max_booking_per_room = grr_sql_query1("SELECT max_booking FROM " . TABLE_PREFIX . "_room WHERE id='" . protect_data_sql($id_room) . "'");
    if ($max_booking_per_room >= 0) {
        echo get_vocab("msg_max_booking") . get_vocab("deux_points") . $max_booking_per_room . "<br />";
    }
    // Calcul de l'id de l'area de la ressource.
    $id_area = mrbsGetRoomArea($id_room);
    // Limitation par domaine
    $max_booking_per_area = grr_sql_query1("SELECT max_booking FROM " . TABLE_PREFIX . "_area WHERE id = '" . protect_data_sql($id_area) . "'");
    if ($max_booking_per_area >= 0) {
        echo get_vocab("msg_max_booking_area") . get_vocab("deux_points") . $max_booking_per_area . "<br />";
    }
    // Limitation sur l'ensemble des ressources
    $max_booking_all = Settings::get("UserAllRoomsMaxBooking");
    if ($max_booking_all >= 0) {
        echo get_vocab("msg_max_booking_all") . get_vocab("deux_points") . $max_booking_all . "<br />";
    }
    echo "<br />" . get_vocab("accessdeniedtoomanybooking");
    ?>
	</p>
	<p>
		<a href="<?php 
    echo $back;
    ?>
"><?php 
    echo get_vocab("returnprev");
    ?>
</a>
	</p>
</body>
</html>
<?php 
}
示例#6
0
        case "month":
            $returl = "month.php";
            break;
        case "week":
            $returl = "week.php";
            break;
        default:
            $returl = "day.php";
    }
    $returl .= "?year={$year}&month={$month}&day={$day}&area={$area}";
}
if (getAuthorised(1) && ($info = mrbsGetEntryInfo($id))) {
    $day = strftime("%d", $info["start_time"]);
    $month = strftime("%m", $info["start_time"]);
    $year = strftime("%Y", $info["start_time"]);
    $area = mrbsGetRoomArea($info["room_id"]);
    if (MAIL_ADMIN_ON_DELETE) {
        require_once "functions_mail.inc";
        // Gather all fields values for use in emails.
        $mail_previous = getPreviousEntryData($id, $series);
    }
    sql_begin();
    $result = mrbsDelEntry(getUserName(), $id, $series, 1);
    sql_commit();
    if ($result) {
        // Send a mail to the Administrator
        MAIL_ADMIN_ON_DELETE ? $result = notifyAdminOnDelete($mail_previous) : '';
        Header("Location: {$returl}");
        exit;
    }
}
示例#7
0
    if ($minute < 10) {
        $minute = '0' . $minute;
    }
} else {
    $minute = null;
}
$rep_num_weeks = '';
global $twentyfourhour_format;
if (!isset($day) || !isset($month) || !isset($year)) {
    $day = date('d');
    $month = date('m');
    $year = date('Y');
}
if (isset($id)) {
    if ($info = mrbsGetEntryInfo($id)) {
        $area = mrbsGetRoomArea($info['room_id']);
        $room = $info['room_id'];
        $id_site = mrbsGetAreaSite($area);
    } else {
        $area = -1;
        $room = -1;
    }
} else {
    Definition_ressource_domaine_site();
}
if (@file_exists('language/lang_subst_' . $area . '.' . $locale)) {
    include 'language/lang_subst_' . $area . '.' . $locale;
}
get_planning_area_values($area);
$affiche_mess_asterisque = false;
$type_affichage_reser = grr_sql_query1('SELECT type_affichage_reser FROM ' . TABLE_PREFIX . "_room WHERE id='" . $room . "'");
示例#8
0
    $type_session = "with_session";
}
if (authGetUserLevel(getUserName(), -1) < 1 && Settings::get("authentification_obli") == 1 || !verif_acces_ressource(getUserName(), $id_room)) {
    showAccessDenied('');
    exit;
}
echo begin_page(get_vocab("mrbs") . get_vocab("deux_points") . Settings::get("company"));
$res = grr_sql_query("SELECT * FROM " . TABLE_PREFIX . "_room WHERE id={$id_room}");
if (!$res) {
    fatal_error(0, get_vocab('error_room') . $id_room . get_vocab('not_found'));
}
$row = grr_sql_row_keyed($res, 0);
grr_sql_free($res);
echo "<h3 style=\"text-align:center;\">";
echo get_vocab("room") . get_vocab("deux_points") . " " . htmlspecialchars($row["room_name"]);
$id_area = mrbsGetRoomArea($id_room);
$area_name = grr_sql_query1("select area_name from " . TABLE_PREFIX . "_area where id='" . $id_area . "'");
$area_access = grr_sql_query1("select access from " . TABLE_PREFIX . "_area where id='" . $id_area . "'");
echo "<br />(" . $area_name;
if ($area_access == 'r') {
    echo " - " . get_vocab("access");
}
echo ")";
echo "</h3>";
if ($row['statut_room'] == "0") {
    //
    echo "<h2 style=\"text-align:center;\"><span class=\"avertissement\">" . get_vocab("ressource_temporairement_indisponible") . "</span></h2>";
}
// Description
if (authGetUserLevel($getUserName(), -1) >= Settings::get("visu_fiche_description")) {
    echo "<h3>" . get_vocab("description") . "</h3>\n";
示例#9
0
if (defined("CHEMIN_COMPLET_GRR")){
  chdir(CHEMIN_COMPLET_GRR);
}
include $lang_file;


// Fichiers de personnalisation de langue
if (@file_exists("language/lang_subst." . $locale))
    include "language/lang_subst." . $locale;


// Fichiers de personnalisation de langue par domaine
if (isset($_GET['area'])) { // Si l'id du domaine est passé en paramètre, on le récupère
    $subst_id_area = $_GET['area'];
} else if (isset($_GET['room'])) { // sinon, on essaye avec l'id de la ressource
    $subst_id_area = mrbsGetRoomArea($_GET['room']);
}
if (isset($subst_id_area))
  if (@file_exists("language/lang_subst_".$subst_id_area.".".$locale))
    include "language/lang_subst_".$subst_id_area.".".$locale;


// Pour l'affichage de la pendule javascript
$clock_file = "clock_".$locale.".js";

// Sélection du fichier d'aide.
$faqfilelang = "_".$locale;

# Format de la date : 0 pour afficher des dates sous la forme "Jul 10", 1 pour afficher des dates sous la forme "10 Jul"
if ($locale == 'en') {
    $dateformat = 'en';
示例#10
0
    toTimeString($duration, $dur_units);
}
if (strstr($back, 'view_entry.php')) {
    $sql = "SELECT start_time, room_id FROM " . TABLE_PREFIX . "_entry WHERE id=" . $id;
    $res = grr_sql_query($sql);
    if (!$res) {
        fatal_error(0, grr_sql_error());
    }
    if (grr_sql_count($res) >= 1) {
        $row1 = grr_sql_row($res, 0);
        $year = date('Y', $row1['0']);
        $month = date('m', $row1['0']);
        $day = date('d', $row1['0']);
        $back = $page . '.php?year=' . $year . '&amp;month=' . $month . '&amp;day=' . $day;
        if (isset($_GET["page"]) && ($_GET["page"] == "week" || $_GET["page"] == "month" || $_GET["page"] == "week_all" || $_GET["page"] == "month_all")) {
            $back .= "&amp;area=" . mrbsGetRoomArea($row1['1']);
        }
        if (isset($_GET["page"]) && ($_GET["page"] == "week" || $_GET["page"] == "month")) {
            $back .= "&amp;room=" . $row1['1'];
        }
    } else {
        $back = "";
    }
}
if (Settings::get("display_level_view_entry") == '1') {
    print_header($day, $month, $year, $type_session);
    if ($back != "") {
        echo '<div><a href="', $back, '">', get_vocab("returnprev"), '</a></div>', PHP_EOL;
    }
}
echo '<fieldset><legend style="font-size:12pt;font-weight:bold">' . get_vocab('entry') . get_vocab('deux_points') . affichage_lien_resa_planning($breve_description, $id) . '</legend>' . "\n";
示例#11
0
    toTimeString($duration, $dur_units);
}
if (strstr($back, 'view_entry.php')) {
    $sql = 'SELECT start_time, room_id FROM ' . TABLE_PREFIX . '_entry WHERE id=' . $id;
    $res = grr_sql_query($sql);
    if (!$res) {
        fatal_error(0, grr_sql_error());
    }
    if (grr_sql_count($res) >= 1) {
        $row1 = grr_sql_row($res, 0);
        $year = date('Y', $row1['0']);
        $month = date('m', $row1['0']);
        $day = date('d', $row1['0']);
        $back = $page . '.php?year=' . $year . '&amp;month=' . $month . '&amp;day=' . $day;
        if (isset($_GET['page']) && ($_GET['page'] == 'week' || $_GET['page'] == 'month' || $_GET['page'] == 'week_all' || $_GET['page'] == 'month_all')) {
            $back .= '&amp;area=' . mrbsGetRoomArea($row1['1']);
        }
        if (isset($_GET['page']) && ($_GET['page'] == 'week' || $_GET['page'] == 'month')) {
            $back .= '&amp;room=' . $row1['1'];
        }
    } else {
        $back = '';
    }
}
if (Settings::get('display_level_view_entry') == '1') {
    print_header($day, $month, $year, $type_session);
    if ($back != '') {
        echo '<div><a href="', $back, '">', get_vocab('returnprev'), '</a></div>', PHP_EOL;
    }
}
$tplArray['vocab']['entry'] = get_vocab('entry');
示例#12
0
/** mrbsCreateRepeatingEntrys()
 *
 * Creates a repeat entry in the data base + all the repeating entrys
 *
 * $starttime   - Start time of entry
 * $endtime     - End time of entry
 * $rep_type    - The repeat type
 * $rep_enddate - When the repeating ends
 * $rep_opt     - Any options associated with the entry
 * $room_id     - Room ID
 * $beneficiaire       - beneficiaire
 * $beneficiaire_ext - bénéficiaire extérieur
 * $name        - Name
 * $type        - Type (Internal/External)
 * $description - Description
  *$rep_jour_c - Le jour cycle d'une réservation, si aucun 0
 *
 * Returns:
 *   0        - An error occured while inserting the entry
 *   non-zero - The entry's ID
 */
function mrbsCreateRepeatingEntrys($starttime, $endtime, $rep_type, $rep_enddate, $rep_opt,
                                   $room_id, $creator, $beneficiaire, $beneficiaire_ext, $name, $type, $description, $rep_num_weeks, $option_reservation,$overload_data, $moderate, $rep_jour_c)
{
    global $max_rep_entrys, $id_first_resa;
    $area = mrbsGetRoomArea($room_id);
    $reps = mrbsGetRepeatEntryList($starttime, $rep_enddate, $rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks, $rep_jour_c, $area);
    if(count($reps) > $max_rep_entrys)
        return 0;

    if(empty($reps))
    {
        mrbsCreateSingleEntry($starttime, $endtime, 0, 0, $room_id, $creator, $beneficiaire, $beneficiaire_ext, $name, $type, $description, $option_reservation,$overload_data,$moderate, $rep_jour_c,"-");
        $id_first_resa = grr_sql_insert_id("".TABLE_PREFIX."_entry", "id");
        return;
    }

    $ent = mrbsCreateRepeatEntry($starttime, $endtime, $rep_type, $rep_enddate, $rep_opt, $room_id, $creator, $beneficiaire, $beneficiaire_ext, $name, $type, $description, $rep_num_weeks,$overload_data, $rep_jour_c);
    if($ent)
    {
        $diff = $endtime - $starttime;

        for($i = 0; $i < count($reps); $i++) {
            mrbsCreateSingleEntry($reps[$i], $reps[$i] + $diff, 1, $ent,
                 $room_id, $creator, $beneficiaire, $beneficiaire_ext, $name, $type, $description, $option_reservation,$overload_data, $moderate, $rep_jour_c,"-");
            $id_new_resa = grr_sql_insert_id("".TABLE_PREFIX."_entry", "id");
            // s'il s'agit d'une modification d'une ressource déjà modérée et acceptée : on met à jour les infos dans la table ".TABLE_PREFIX."_entry_moderate
            if ($moderate==2) moderate_entry_do($id_new_resa,1,"","no");
            // On récupère l'id de la première réservation de la série et qui sera utilisé pour l'enoi d'un mail
            if ($i == 0) $id_first_resa = $id_new_resa;
            }
    }

    return $ent;
}