Exemplo n.º 1
0
        $area = sql_insert_id("{$tbl_area}", "id");
    }
    // Release the mutex
    sql_mutex_unlock("{$tbl_area}");
} elseif ($type == "room") {
    // Truncate the name and description fields to the maximum length as a precaution.
    $name = substr($name, 0, $maxlength['room.room_name']);
    $description = substr($description, 0, $maxlength['room.description']);
    // Add SQL escaping
    $room_name_q = addslashes($name);
    $description_q = addslashes($description);
    if (empty($capacity)) {
        $capacity = 0;
    }
    // Acquire a mutex to lock out others who might be editing rooms
    if (!sql_mutex_lock("{$tbl_room}")) {
        fatal_error(TRUE, get_vocab("failed_to_acquire"));
    }
    // Check that the room name is unique within the area
    if (sql_query1("SELECT COUNT(*) FROM {$tbl_room} WHERE room_name='{$room_name_q}' AND area_id={$area} LIMIT 1") > 0) {
        $error = "invalid_room_name";
    } else {
        $sql = "INSERT INTO {$tbl_room} (room_name, sort_key, area_id, description, capacity)\n            VALUES ('{$room_name_q}', '{$room_name_q}', {$area}, '{$description_q}',{$capacity})";
        if (sql_command($sql) < 0) {
            trigger_error(sql_error(), E_USER_WARNING);
            fatal_error(TRUE, get_vocab("fatal_db_error"));
        }
    }
    // Release the mutex
    sql_mutex_unlock("{$tbl_room}");
}
 require_once "functions_mail.inc";
 // PHASE 2 (ROOM) - UPDATE THE DATABASE
 // ------------------------------------
 if (isset($change_room) && !empty($room)) {
     // clean up the address list replacing newlines by commas and removing duplicates
     $room_admin_email = clean_address_list($room_admin_email);
     // put a space after each comma so that the list displays better
     $room_admin_email = str_replace(',', ', ', $room_admin_email);
     // validate the email addresses
     $valid_email = validate_email_list($room_admin_email);
     if (FALSE != $valid_email) {
         if (empty($capacity)) {
             $capacity = 0;
         }
         // Acquire a mutex to lock out others who might be deleting the new area
         if (!sql_mutex_lock("{$tbl_area}")) {
             fatal_error(TRUE, get_vocab("failed_to_acquire"));
         }
         // Check the new area still exists
         if (sql_query1("SELECT COUNT(*) FROM {$tbl_area} WHERE id={$new_area} LIMIT 1") < 1) {
             $valid_area = FALSE;
         } elseif (($new_area != $old_area || $room_name != $old_room_name) && sql_query1("SELECT COUNT(*)\n                               FROM {$tbl_room}\n                              WHERE" . sql_syntax_casesensitive_equals("room_name", $room_name) . "\n                                AND area_id={$new_area}\n                              LIMIT 1") > 0) {
             $valid_room_name = FALSE;
         } else {
             // Convert booleans into 0/1 (necessary for PostgreSQL)
             $room_disabled = !empty($room_disabled) ? 1 : 0;
             $sql = "UPDATE {$tbl_room} SET ";
             $n_fields = count($fields);
             $assign_array = array();
             foreach ($fields as $field) {
                 if ($field['name'] != 'id') {
Exemplo n.º 3
0
if ($rep_type != 0) {
    $reps = mrbsGetRepeatEntryList($starttime, isset($rep_enddate) ? $rep_enddate : 0, $rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks);
}
# When checking for overlaps, for Edit (not New), ignore this entry and series:
$repeat_id = 0;
if (isset($id)) {
    $ignore_id = $id;
    $repeat_id = sql_query1("SELECT repeat_id FROM {$tbl_entry} WHERE id={$id}");
    if ($repeat_id < 0) {
        $repeat_id = 0;
    }
} else {
    $ignore_id = 0;
}
# Acquire mutex to lock out others trying to book the same slot(s).
if (!sql_mutex_lock("{$tbl_entry}")) {
    fatal_error(1, get_vocab("failed_to_acquire"));
}
# Check for any schedule conflicts in each room we're going to try and
# book in
$err = "";
foreach ($rooms as $room_id) {
    if ($rep_type != 0 && !empty($reps)) {
        if (count($reps) < $max_rep_entrys) {
            for ($i = 0; $i < count($reps); $i++) {
                # calculate diff each time and correct where events
                # cross DST
                $diff = $endtime - $starttime;
                $diff += cross_dst($reps[$i], $reps[$i] + $diff);
                $tmp = mrbsCheckFree($room_id, $reps[$i], $reps[$i] + $diff, $ignore_id, $repeat_id);
                if (!empty($tmp)) {
Exemplo n.º 4
0
if ($rep_type != 0) {
    $reps = mrbsGetRepeatEntryList($starttime, isset($rep_enddate) ? $rep_enddate : 0, $rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks);
}
# When checking for overlaps, for Edit (not New), ignore this entry and series:
$repeat_id = 0;
if (isset($id)) {
    $ignore_id = $id;
    $repeat_id = sql_query1("SELECT repeat_id FROM mrbs_entry WHERE id={$id}");
    if ($repeat_id < 0) {
        $repeat_id = 0;
    }
} else {
    $ignore_id = 0;
}
# Acquire mutex to lock out others trying to book the same slot(s).
if (!sql_mutex_lock('mrbs_entry')) {
    fatal_error(1, $vocab['failed_to_acquire']);
}
# Check for any schedule conflicts in each room we're going to try and
# book in
$err = "";
foreach ($rooms as $room_id) {
    if ($rep_type != 0 && !empty($reps)) {
        if (count($reps) < $max_rep_entrys) {
            $diff = $endtime - $starttime;
            for ($i = 0; $i < count($reps); $i++) {
                $tmp = mrbsCheckFree($room_id, $reps[$i], $reps[$i] + $diff, $ignore_id, $repeat_id);
                if (!empty($tmp)) {
                    $err = $err . $tmp;
                }
            }
Exemplo n.º 5
0
    //$area = mrbsAddArea($name, $error);
    $sql = "INSERT INTO users (name, code, team, role, disabled)\n          VALUES ('{$name}', '{$code}', '{$team}', '{$role}', 0)";
    if (!sql_mutex_lock("users")) {
        fatal_error(TRUE, get_vocab("failed_to_acquire"));
    }
    if (sql_command($sql) < 0) {
        trigger_error(sql_error(), E_USER_WARNING);
        fatal_error(TRUE, get_vocab("fatal_db_error"));
    }
    $area = sql_insert_id('users', 'id');
    sql_mutex_unlock("users");
} elseif ($type == "room") {
    //$room = mrbsAddRoom($name, $area, $error, $description, $capacity);
    $f2f = $_POST['f2f'];
    $available = $_POST['available'];
    $dnka = $_POST['dnka'];
    $outreach = $_POST['outreach'];
    $nocount = $_POST['nocount'];
    $sql = "INSERT INTO codes (code, description, f2f, available, dnka, outreach, nocount, disabled)\n          VALUES ('{$code}', '{$description}', {$f2f}, {$available}, {$dnka}, {$outreach}, {$nocount}, 0)";
    if (!sql_mutex_lock("users")) {
        fatal_error(TRUE, get_vocab("failed_to_acquire"));
    }
    if (sql_command($sql) < 0) {
        trigger_error(sql_error(), E_USER_WARNING);
        fatal_error(TRUE, get_vocab("fatal_db_error"));
    }
    $area = sql_insert_id('users', 'id');
    sql_mutex_unlock("users");
}
$returl = "admin.php?success=" . (isset($area) ? 1 : 0) . (!empty($error) ? "&error={$error}" : "");
header("Location: {$returl}");
Exemplo n.º 6
0
        $rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks);

# When checking for overlaps, for Edit (not New), ignore this entry and series:
$repeat_id = 0;
if (isset($id))
{
    $ignore_id = $id;
    $repeat_id = sql_query1("SELECT repeat_id FROM $tbl_entry WHERE id=$id");
    if ($repeat_id < 0)
        $repeat_id = 0;
}
else
    $ignore_id = 0;

# Acquire mutex to lock out others trying to book the same slot(s).
if (!sql_mutex_lock("$tbl_entry"))
    fatal_error(1, get_vocab("failed_to_acquire"));
    
# Check for any schedule conflicts in each room we're going to try and
# book in
$err = "";
foreach ( $rooms as $room_id ) {
  if ($rep_type != 0 && !empty($reps))
  {
    if(count($reps) < $max_rep_entrys)
    {
        
        for($i = 0; $i < count($reps); $i++)
        {
	    # calculate diff each time and correct where events
	    # cross DST
Exemplo n.º 7
0
 $disabled = $_POST['disabled'];
 $id = $_POST['id'];
 if (isset($change_room) && !empty($code)) {
     /*    // clean up the address list replacing newlines by commas and removing duplicates
         $room_admin_email = clean_address_list($room_admin_email);
         // put a space after each comma so that the list displays better
         $room_admin_email = str_replace(',', ', ', $room_admin_email);
         // validate the email addresses
         $valid_email = validate_email_list($room_admin_email);*/
     if (FALSE != $valid_email) {
         /*      if (empty($capacity))
               {
                 $capacity = 0;
               }*/
         // Acquire a mutex to lock out others who might be deleting the new area
         if (!sql_mutex_lock("codes")) {
             fatal_error(TRUE, get_vocab("failed_to_acquire"));
         } else {
             // Convert booleans into 0/1 (necessary for PostgreSQL)
             /*        $room_disabled = (!empty($room_disabled)) ? 1 : 0;
                     $sql = "UPDATE $tbl_room SET ";*/
             /*        $n_fields = count($fields);
                     $assign_array = array();
                     foreach ($fields as $field)
                     {
                       if ($field['name'] != 'id')  // don't do anything with the id field
                       {
                         switch ($field['name'])
                         {
                           // first of all deal with the standard MRBS fields
                           case 'area_id':