Revision: 1621
http://mrbs.svn.sourceforge.net/mrbs/?rev=1621&view=rev
Author: cimorrison
Date: 2010-11-19 16:59:23 +0000 (Fri, 19 Nov 2010)
Log Message:
-----------
Completed support for disabled rooms and areas. Rooms and areas can now be
disabled, meaning that they will not appear in the day/week/month views and
bookings cannot be made for them. Any existing bookings will be preserved in
the system, will be returned in Search and Report results and can be viewed in
view_entry.php - but they will be read only.
Modified Paths:
--------------
mrbs/branches/disabled_rooms/web/Themes/default/header.inc
mrbs/branches/disabled_rooms/web/admin.php
mrbs/branches/disabled_rooms/web/day.php
mrbs/branches/disabled_rooms/web/edit_entry.php
mrbs/branches/disabled_rooms/web/functions.inc
mrbs/branches/disabled_rooms/web/month.php
mrbs/branches/disabled_rooms/web/mrbs.css.php
mrbs/branches/disabled_rooms/web/mrbs_sql.inc
mrbs/branches/disabled_rooms/web/pending.php
mrbs/branches/disabled_rooms/web/view_entry.php
mrbs/branches/disabled_rooms/web/week.php
Modified: mrbs/branches/disabled_rooms/web/Themes/default/header.inc
===================================================================
--- mrbs/branches/disabled_rooms/web/Themes/default/header.inc 2010-11-18
21:59:13 UTC (rev 1620)
+++ mrbs/branches/disabled_rooms/web/Themes/default/header.inc 2010-11-19
16:59:23 UTC (rev 1621)
@@ -925,10 +925,9 @@
</form>
<?php
// Provide a link to the list of bookings awaiting approval
- // (if there are any areas where we require bookings to be approved)
+ // (if there are any enabled areas where we require bookings to be
approved)
-
- $approval_somewhere = some_area('approval_enabled');
+ $approval_somewhere = some_area('approval_enabled', TRUE);
if ($approval_somewhere && (authGetUserLevel($user) >= 1))
{
$sql_approval_enabled = some_area_predicate('approval_enabled');
@@ -939,6 +938,8 @@
WHERE (status&" . STATUS_AWAITING_APPROVAL . " != 0)
AND E.room_id = R.id
AND R.area_id = A.id
+ AND R.disabled = 0
+ AND A.disabled = 0
AND $sql_approval_enabled";
if (!$is_admin)
{
Modified: mrbs/branches/disabled_rooms/web/admin.php
===================================================================
--- mrbs/branches/disabled_rooms/web/admin.php 2010-11-18 21:59:13 UTC (rev
1620)
+++ mrbs/branches/disabled_rooms/web/admin.php 2010-11-19 16:59:23 UTC (rev
1621)
@@ -62,7 +62,9 @@
// TOP SECTION: THE FORM FOR SELECTING AN AREA
echo "<div id=\"area_form\">\n";
-$sql = "select id, area_name, disabled from $tbl_area order by area_name";
+$sql = "SELECT id, area_name, disabled
+ FROM $tbl_area
+ ORDER BY disabled, area_name";
$res = sql_query($sql);
$areas_defined = $res && (sql_count($res) > 0);
if (!$areas_defined)
@@ -99,14 +101,37 @@
// The area selector
echo "<label id=\"area_label\" for=\"area_select\">" . get_vocab("area") .
":</label>\n";
echo "<select class=\"room_area_select\" id=\"area_select\" name=\"area\"
onchange=\"this.form.submit()\">";
+ if ($is_admin)
+ {
+ if ($areas[0]['disabled'])
+ {
+ $done_change = TRUE;
+ echo "<optgroup label=\"" . get_vocab("disabled") . "\">\n";
+ }
+ else
+ {
+ $done_change = FALSE;
+ echo "<optgroup label=\"" . get_vocab("enabled") . "\">\n";
+ }
+ }
foreach ($areas as $a)
{
if ($is_admin || !$a['disabled'])
{
+ if ($is_admin && !$done_change && $a['disabled'])
+ {
+ echo "</optgroup>\n";
+ echo "<optgroup label=\"" . get_vocab("disabled") . "\">\n";
+ $done_change = TRUE;
+ }
$selected = ($a['id'] == $area) ? "selected=\"selected\"" : "";
echo "<option $selected value=\"". $a['id']. "\">" .
htmlspecialchars($a['area_name']) . "</option>";
}
}
+ if ($is_admin)
+ {
+ echo "</optgroup>\n";
+ }
echo "</select>\n";
// Some hidden inputs for current day, month, year
Modified: mrbs/branches/disabled_rooms/web/day.php
===================================================================
--- mrbs/branches/disabled_rooms/web/day.php 2010-11-18 21:59:13 UTC (rev
1620)
+++ mrbs/branches/disabled_rooms/web/day.php 2010-11-19 16:59:23 UTC (rev
1621)
@@ -66,7 +66,10 @@
<?php
-$sql = "select id, area_name from $tbl_area order by area_name";
+$sql = "SELECT id, area_name
+ FROM $tbl_area
+ WHERE disabled=0
+ ORDER BY area_name";
$res = sql_query($sql);
// Show all available areas
// but only if there's more than one of them, otherwise there's no point
@@ -132,23 +135,27 @@
$td = date("d",$i);
-//We want to build an array containing all the data we want to show
-//and then spit it out.
+// We want to build an array containing all the data we want to show
+// and then spit it out.
-//Get all appointments for today in the area that we care about
-//Note: The predicate clause 'start_time <= ...' is an equivalent but simpler
-//form of the original which had 3 BETWEEN parts. It selects all entries which
-//occur on or cross the current day.
+// Get all appointments for today in the area that we care about. We
+// only get the data for enabled rooms. (If the whole area is disabled
+// then the main table won't get displayed anyway).
+
+// Note: The predicate clause 'start_time <= ...' is an equivalent but simpler
+// form of the original which had 3 BETWEEN parts. It selects all entries which
+// occur on or cross the current day.
$sql = "SELECT R.id AS room_id, start_time, end_time, name, repeat_id,
E.id AS entry_id, type,
E.description AS entry_description, status,
E.create_by AS entry_create_by
FROM $tbl_entry E, $tbl_room R
WHERE E.room_id = R.id
- AND area_id = $area
+ AND R.area_id = $area
+ AND R.disabled = 0
AND start_time <= $pm7 AND end_time > $am7
ORDER BY start_time"; // necessary so that multiple bookings appear in
the right order
-
+
$res = sql_query($sql);
if (! $res)
{
@@ -201,11 +208,17 @@
echo "</pre><p>\n";
}
-// We need to know what all the rooms area called, so we can show them all
-// pull the data from the db and store it. Convienently we can print the room
+// We need to know what all the rooms are called, so we can show them all.
+// Pull the data from the db and store it. Convienently we can print the room
// headings and capacities at the same time
-$sql = "SELECT room_name, capacity, id, description FROM $tbl_room WHERE
area_id=$area ORDER BY sort_key";
+$sql = "SELECT R.room_name, R.capacity, R.id, R.description
+ FROM $tbl_room R, $tbl_area A
+ WHERE R.area_id=$area
+ AND R.area_id = A.id
+ AND R.disabled = 0
+ AND A.disabled = 0
+ ORDER BY sort_key";
$res = sql_query($sql);
Modified: mrbs/branches/disabled_rooms/web/edit_entry.php
===================================================================
--- mrbs/branches/disabled_rooms/web/edit_entry.php 2010-11-18 21:59:13 UTC
(rev 1620)
+++ mrbs/branches/disabled_rooms/web/edit_entry.php 2010-11-19 16:59:23 UTC
(rev 1621)
@@ -385,12 +385,12 @@
// If we have not been provided with a room_id
if (empty( $room_id ) )
{
- $sql = "SELECT id FROM $tbl_room LIMIT 1";
+ $sql = "SELECT id FROM $tbl_room WHERE disabled=0 LIMIT 1";
$res = sql_query($sql);
$row = sql_row_keyed($res, 0);
$room_id = $row['id'];
+}
-}
// Determine the area id of the room in question first
$area_id = mrbsGetRoomArea($room_id);
@@ -413,11 +413,14 @@
print_header($day, $month, $year, $area, isset($room) ? $room : "");
-// Get the details of all the rooms
+// Get the details of all the enabled rooms
$rooms = array();
-$sql = "SELECT id, room_name, area_id
- FROM $tbl_room
- ORDER BY area_id, sort_key";
+$sql = "SELECT R.id, R.room_name, R.area_id
+ FROM $tbl_room R, $tbl_area A
+ WHERE R.area_id = A.id
+ AND R.disabled=0
+ AND A.disabled=0
+ ORDER BY R.area_id, R.sort_key";
$res = sql_query($sql);
if ($res)
{
@@ -427,11 +430,12 @@
}
}
-// Get the details of all the areas
+// Get the details of all the enabled areas
$areas = array();
$sql = "SELECT id, area_name, resolution, default_duration, enable_periods,
morningstarts, morningstarts_minutes, eveningends ,
eveningends_minutes
FROM $tbl_area
+ WHERE disabled=0
ORDER BY area_name";
$res = sql_query($sql);
if ($res)
Modified: mrbs/branches/disabled_rooms/web/functions.inc
===================================================================
--- mrbs/branches/disabled_rooms/web/functions.inc 2010-11-18 21:59:13 UTC
(rev 1620)
+++ mrbs/branches/disabled_rooms/web/functions.inc 2010-11-19 16:59:23 UTC
(rev 1621)
@@ -519,24 +519,36 @@
}
// Return a default area; used if no area is already known. This returns the
-// area that contains the default room (if it is set and valid) otherwise the
+// area that contains the default room (if it is set, valid and enabled)
otherwise the
// first area in alphabetical order in the database (no guarantee there is an
area 1).
+// The area must be enabled for it to be considered.
// This could be changed to implement something like per-user defaults.
function get_default_area()
{
global $tbl_area, $tbl_room, $default_room;
- // If the $default_room is set and exists, then return the corresponding area
+ // If the $default_room is set and exists and enabled, then return the
+ // corresponding area
if (isset($default_room))
{
- $area = sql_query1("SELECT area_id FROM $tbl_room WHERE id=$default_room
LIMIT 1");
+ $area = sql_query1("SELECT area_id
+ FROM $tbl_room R, $tbl_area A
+ WHERE R.id=$default_room
+ AND R.area_id = A.id
+ AND R.disabled = 0
+ AND A.disabled = 0
+ LIMIT 1");
if ($area >= 0)
{
return $area;
}
}
- // Otherwise return the first area in alphabetical order in the database
- $area = sql_query1("SELECT id FROM $tbl_area ORDER BY area_name LIMIT 1");
+ // Otherwise return the first enabled area in alphabetical order in the
database
+ $area = sql_query1("SELECT id
+ FROM $tbl_area
+ WHERE disabled=0
+ ORDER BY area_name
+ LIMIT 1");
return ((!isset($area) || ($area < 0)) ? 0 : $area);
}
@@ -550,14 +562,24 @@
// Check to see whether this area contains $default_room
if (isset($default_room))
{
- $room = sql_query1("SELECT id FROM $tbl_room WHERE id=$default_room AND
area_id=$area LIMIT 1");
+ $room = sql_query1("SELECT id
+ FROM $tbl_room
+ WHERE id=$default_room
+ AND area_id=$area
+ AND disabled=0
+ LIMIT 1");
if ($room >= 0)
{
return $room;
}
}
// Otherwise just return the first room (in sortkey order) in the area
- $room = sql_query1("SELECT id FROM $tbl_room WHERE area_id=$area ORDER BY
sort_key LIMIT 1");
+ $room = sql_query1("SELECT id
+ FROM $tbl_room
+ WHERE area_id=$area
+ AND disabled=0
+ ORDER BY sort_key
+ LIMIT 1");
return ($room < 0 ? 0 : $room);
}
@@ -633,18 +655,18 @@
}
// Determines whether there is at least one area with the relevant $field
-// set (eg 'approval_enabled' or 'confirmation_enabled')
+// set (eg 'approval_enabled' or 'confirmation_enabled'). If $enabled
+// is TRUE then the search is limited to enabled areas
//
// Returns: boolean
-function some_area($field)
+function some_area($field, $enabled=FALSE)
{
global $tbl_area;
$predicate = some_area_predicate($field);
- $sql = "SELECT COUNT(*)
- FROM $tbl_area
- WHERE $predicate
- LIMIT 1";
+ $sql = "SELECT COUNT(*) FROM $tbl_area WHERE $predicate";
+ $sql .= ($enabled) ? " AND disabled=0" : "";
+ $sql .= " LIMIT 1";
return (sql_query1($sql) > 0);
}
@@ -878,71 +900,113 @@
// generates some html that can be used to select which area should be
// displayed.
-function make_area_select_html( $link, $current, $year, $month, $day )
+function make_area_select_html($link, $current, $year, $month, $day)
{
- global $tbl_area;
- $out_html = "
-<form id=\"areaChangeForm\" method=\"get\" action=\"$link\">
- <div>
- <select class=\"room_area_select\" id=\"area_select\" name=\"area\"
onchange=\"this.form.submit()\">";
+ global $tbl_area, $area_list_format;
- $sql = "select id, area_name from $tbl_area order by area_name";
- $res = sql_query($sql);
- if ($res)
+ $out_html = '';
+ $sql = "SELECT id, area_name
+ FROM $tbl_area
+ WHERE disabled=0
+ ORDER BY area_name";
+ $res = sql_query($sql);
+ // Only show the areas if there's more than one of them, otherwise
+ // there's no point
+ if ($res && (sql_count($res) > 1))
+ {
+ $out_html .= "<div id=\"dwm_areas\">\n";
+ $out_html .= "<h3>" . get_vocab("areas") . "</h3>\n";
+ if ($area_list_format == "select")
{
+ $out_html .= "<form id=\"areaChangeForm\" method=\"get\"
action=\"$link\">\n" .
+ "<div>\n" .
+ "<select class=\"room_area_select\" id=\"area_select\"
name=\"area\" onchange=\"this.form.submit()\">";
for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
{
$selected = ($row['id'] == $current) ? "selected=\"selected\"" : "";
- $out_html .= "
- <option $selected value=\"". $row['id']. "\">" .
htmlspecialchars($row['area_name']) . "</option>";
+ $out_html .= "<option $selected value=\"". $row['id']. "\">" .
htmlspecialchars($row['area_name']) . "</option>\n";
}
+ // Note: the submit button will not be displayed if JavaScript is
enabled
+ $out_html .= "</select>\n" .
+ "<input type=\"hidden\" name=\"day\" value=\"$day\">\n" .
+ "<input type=\"hidden\" name=\"month\" value=\"$month\">\n"
.
+ "<input type=\"hidden\" name=\"year\" value=\"$year\">\n" .
+ "<input type=\"submit\" class=\"js_none\"
value=\"".get_vocab("change")."\">\n" .
+ "</div>\n" .
+ "</form>\n";
}
- // Note: the submit button will not be displayed if JavaScript is enabled
- $out_html .= "
- </select>
-
- <input type=\"hidden\" name=\"day\" value=\"$day\">
- <input type=\"hidden\" name=\"month\" value=\"$month\">
- <input type=\"hidden\" name=\"year\" value=\"$year\">
- <input type=\"submit\" class=\"js_none\" value=\"".get_vocab("change")."\">
- </div>
-</form>\n";
-
+ else // list format
+ {
+ $out_html .= "<ul>\n";
+ for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
+ {
+ $out_html .= "<li><a
href=\"week.php?year=$year&month=$month&day=$day&area=${row['id']}\">";
+ $out_html .= "<span" . (($row['id'] == $current) ? ' class="current"'
: '') . ">";
+ $out_html .= htmlspecialchars($row['area_name']) .
"</span></a></li>\n";
+ }
+ $out_html .= "</ul>\n";
+ }
+ $out_html .= "</div>\n";
+ }
return $out_html;
} // end make_area_select_html
-function make_room_select_html( $link, $area, $current, $year, $month, $day )
+
+function make_room_select_html ($link, $area, $current, $year, $month, $day)
{
- global $tbl_room;
- $out_html = "
-<form id=\"roomChangeForm\" method=\"get\" action=\"$link\">
- <div>
- <select class=\"room_area_select\" name=\"room\"
onchange=\"this.form.submit()\">";
+ global $tbl_room, $tbl_area, $area_list_format;
- $sql = "select id, room_name from $tbl_room where area_id=$area order by
sort_key";
- $res = sql_query($sql);
- if ($res)
+ $out_html = '';
+ $sql = "SELECT R.id, R.room_name
+ FROM $tbl_room R, $tbl_area A
+ WHERE R.area_id=$area
+ AND R.area_id=A.id
+ AND R.disabled=0
+ AND A.disabled=0
+ ORDER BY R.sort_key";
+ $res = sql_query($sql);
+ // Only show the rooms if there's more than one of them, otherwise
+ // there's no point
+ if ($res && (sql_count($res) > 1))
+ {
+ $out_html .= "<div id=\"dwm_rooms\">\n";
+ $out_html .= "<h3>" . get_vocab("rooms") . "</h3>";
+ if ($area_list_format == "select")
{
+ $out_html .= "<form id=\"roomChangeForm\" method=\"get\"
action=\"$link\">\n" .
+ "<div>\n" .
+ "<select class=\"room_area_select\" name=\"room\"
onchange=\"this.form.submit()\">\n";
+
for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
{
$selected = ($row['id'] == $current) ? "selected=\"selected\"" : "";
- $out_html .= "
- <option $selected value=\"". $row['id']. "\">" .
htmlspecialchars($row['room_name']) . "</option>";
+ $out_html .= "<option $selected value=\"". $row['id']. "\">" .
htmlspecialchars($row['room_name']) . "</option>\n";
}
+ // Note: the submit button will not be displayed if JavaScript is
enabled
+ $out_html .= "</select>\n" .
+ "<input type=\"hidden\" name=\"day\" value=\"$day\">\n" .
+ "<input type=\"hidden\" name=\"month\" value=\"$month\">\n"
.
+ "<input type=\"hidden\" name=\"year\" value=\"$year\">\n" .
+ "<input type=\"hidden\" name=\"area\" value=\"$area\">\n" .
+ "<input type=\"submit\" class=\"js_none\"
value=\"".get_vocab("change")."\">\n" .
+ "</div>\n" .
+ "</form>\n";
}
- // Note: the submit button will not be displayed if JavaScript is enabled
- $out_html .= "
- </select>
- <input type=\"hidden\" name=\"day\" value=\"$day\">
- <input type=\"hidden\" name=\"month\" value=\"$month\">
- <input type=\"hidden\" name=\"year\" value=\"$year\">
- <input type=\"hidden\" name=\"area\" value=\"$area\">
- <input type=\"submit\" class=\"js_none\" value=\"".get_vocab("change")."\">
- </div>
-</form>\n";
-
+ else // list format
+ {
+ $out_html .= "<ul>\n";
+ for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
+ {
+ $out_html .= "<li><a
href=\"month.php?year=$year&month=$month&day=$day&area=$area&room=".$row['id']."\">";
+ $out_html .= "<span" . (($row['id'] == $current) ? ' class="current"'
: '') . ">";
+ $out_html .= htmlspecialchars($row['room_name']) .
"</span></a></li>\n";
+ }
+ $out_html .= "</ul>\n";
+ }
+ $out_html .= "</div>\n";
+ }
return $out_html;
-} // end make_area_select_html
+} // end make_room_select_html
// This will return the appropriate value for isdst for mktime().
Modified: mrbs/branches/disabled_rooms/web/month.php
===================================================================
--- mrbs/branches/disabled_rooms/web/month.php 2010-11-18 21:59:13 UTC (rev
1620)
+++ mrbs/branches/disabled_rooms/web/month.php 2010-11-19 16:59:23 UTC (rev
1621)
@@ -91,65 +91,17 @@
// Get the area and room names (we will need them later for the heading)
$this_area_name = "";
$this_room_name = "";
-$this_area_name = htmlspecialchars(sql_query1("SELECT area_name FROM $tbl_area
WHERE id=$area LIMIT 1"));
-$this_room_name = htmlspecialchars(sql_query1("SELECT room_name FROM $tbl_room
WHERE id=$room LIMIT 1"));
-
-$sql = "select id, area_name from $tbl_area order by area_name";
-$res = sql_query($sql);
+$this_area_name = sql_query1("SELECT area_name FROM $tbl_area WHERE id=$area
AND disabled=0 LIMIT 1");
+$this_room_name = sql_query1("SELECT room_name FROM $tbl_room WHERE id=$room
AND disabled=0 LIMIT 1");
+// The room is invalid if it doesn't exist, or else it has been disabled,
either explicitly
+// or implicitly because the area has been disabled
+$room_invalid = ($this_area_name === -1) || ($this_room_name === -1);
+
// Show all available areas
-// but only if there's more than one of them, otherwise there's no point
-if ($res && (sql_count($res)>1))
-{
- echo "<div id=\"dwm_areas\"><h3>".get_vocab("areas")."</h3>";
-
- // show either a select box or the normal html list
- if ($area_list_format == "select")
- {
- echo make_area_select_html('month.php', $area, $year, $month, $day);
- }
- else
- {
- echo "<ul>\n";
- for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
- {
- echo "<li><a
href=\"month.php?year=$year&month=$month&day=$day&area=${row['id']}\">";
- echo "<span" . (($row['id'] == $area) ? ' class="current"' : '') . ">";
- echo htmlspecialchars($row['area_name']) . "</span></a></li>\n";
- }
- echo "</ul>\n";
- } // end select if
-
- echo "</div>\n";
-}
+echo make_area_select_html('month.php', $area, $year, $month, $day);
+// Show all available rooms in the current area:
+echo make_room_select_html('month.php', $area, $room, $year, $month, $day);
-// Show all rooms in the current area:
-echo "<div id=\"dwm_rooms\"><h3>".get_vocab("rooms")."</h3>";
-
-// should we show a drop-down for the room list, or not?
-if ($area_list_format == "select")
-{
- echo make_room_select_html('month.php', $area, $room, $year, $month, $day);
-}
-else
-{
- $sql = "select id, room_name from $tbl_room
- where area_id=$area order by sort_key";
- $res = sql_query($sql);
- if ($res)
- {
- echo "<ul>\n";
- for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
- {
- echo "<li><a
href=\"month.php?year=$year&month=$month&day=$day&area=$area&room=".$row['id']."\">";
- echo "<span" . (($row['id'] == $room) ? ' class="current"' : '') . ">";
- echo htmlspecialchars($row['room_name']) . "</span></a></li>\n";
- }
- echo "</ul>\n";
- }
-} // end select if
-
-echo "</div>\n";
-
// Draw the three month calendars
minicals($year, $month, $day, $area, $room, 'month');
echo "</div>\n";
@@ -157,8 +109,9 @@
// End of "screenonly" div
echo "</div>\n";
-// Don't continue if this area has no rooms:
-if ($room <= 0)
+// Don't continue if this room is invalid, which could be because the area
+// has no rooms, or else the room or area has been disabled
+if ($room_invalid)
{
echo "<h1>".get_vocab("no_rooms_for_area")."</h1>";
require_once "trailer.inc";
@@ -168,7 +121,7 @@
// Show Month, Year, Area, Room header:
echo "<div id=\"dwm\">\n";
echo "<h2>" . utf8_strftime("%B %Y", $month_start)
- . " - $this_area_name - $this_room_name</h2>\n";
+ . " - " . htmlspecialchars("$this_area_name - $this_room_name") . "</h2>\n";
echo "</div>\n";
// Show Go to month before and after links
Modified: mrbs/branches/disabled_rooms/web/mrbs.css.php
===================================================================
--- mrbs/branches/disabled_rooms/web/mrbs.css.php 2010-11-18 21:59:13 UTC
(rev 1620)
+++ mrbs/branches/disabled_rooms/web/mrbs.css.php 2010-11-19 16:59:23 UTC
(rev 1621)
@@ -29,11 +29,11 @@
.current {color: <?php echo $highlight_font_color ?>}
/* used to highlight the current item */
.error {color: <?php echo $highlight_font_color ?>; font-weight: bold}
/* for error messages */
.warning {color: <?php echo $highlight_font_color ?>}
/* for warning messages */
+.note {font-style: italic}
+h1 {font-size: x-large; clear: both}
+h2 {font-size: large; clear: both}
-h1 {font-size: x-large}
-h2 {font-size: large}
-
img {border: 0}
a:link {color: <?php echo $anchor_link_color ?>; text-decoration: none;
font-weight: bold}
Modified: mrbs/branches/disabled_rooms/web/mrbs_sql.inc
===================================================================
--- mrbs/branches/disabled_rooms/web/mrbs_sql.inc 2010-11-18 21:59:13 UTC
(rev 1620)
+++ mrbs/branches/disabled_rooms/web/mrbs_sql.inc 2010-11-19 16:59:23 UTC
(rev 1621)
@@ -767,7 +767,9 @@
"M.room_admin_email",
"M.area_id",
"A.area_name",
- "A.area_admin_email",
+ "A.area_admin_email",
+ "M.disabled AS room_disabled",
+ "A.disabled AS area_disabled",
"(end_time - start_time) AS duration");
foreach ($table_fields as $field)
Modified: mrbs/branches/disabled_rooms/web/pending.php
===================================================================
--- mrbs/branches/disabled_rooms/web/pending.php 2010-11-18 21:59:13 UTC
(rev 1620)
+++ mrbs/branches/disabled_rooms/web/pending.php 2010-11-19 16:59:23 UTC
(rev 1621)
@@ -174,6 +174,8 @@
LEFT JOIN $tbl_repeat AS T ON E.repeat_id=T.id
WHERE E.room_id = M.id
AND M.area_id = A.id
+ AND M.disabled = 0
+ AND A.disabled = 0
AND $sql_approval_enabled
AND (E.status&" . STATUS_AWAITING_APPROVAL . " != 0)";
Modified: mrbs/branches/disabled_rooms/web/view_entry.php
===================================================================
--- mrbs/branches/disabled_rooms/web/view_entry.php 2010-11-18 21:59:13 UTC
(rev 1620)
+++ mrbs/branches/disabled_rooms/web/view_entry.php 2010-11-19 16:59:23 UTC
(rev 1621)
@@ -188,6 +188,11 @@
case 'end_time':
break;
+ case 'room_disabled':
+ case 'area_disabled':
+ $$column = !empty($row[$column]);
+ break;
+
case 'name':
case 'description':
case 'create_by':
@@ -347,9 +352,10 @@
echo "<tr><td> </td><td class=\"error\">" . get_vocab($error) .
"</td></tr>\n";
}
-// If bookings require approval, put the buttons to do with managing
-// the bookings in the footer
-if ($approval_enabled && ($status & STATUS_AWAITING_APPROVAL))
+// If bookings require approval, and the room is enabled, put the buttons
+// to do with managing the bookings in the footer
+if ($approval_enabled && !$room_disabled &&!$area_disabled &&
+ ($status & STATUS_AWAITING_APPROVAL))
{
echo "<tfoot id=\"approve_buttons\">\n";
// PHASE 2 - REJECT
@@ -450,23 +456,31 @@
?>
<tr>
<td><?php echo get_vocab("room") ?>:</td>
- <td><?php echo mrbs_nl2br(htmlspecialchars($area_name . " - " .
$room_name)) ?></td>
+ <?php
+ echo "<td>";
+ echo mrbs_nl2br(htmlspecialchars($area_name . " - " . $room_name));
+ if ($room_disabled || $area_disabled)
+ {
+ echo "<span class=\"note\"> (" . get_vocab("disabled") . ")</span>";
+ }
+ echo "</td>\n";
+ ?>
</tr>
<tr>
<td><?php echo get_vocab("start_date") ?>:</td>
- <td><?php echo $start_date ?></td>
+ <td><?php echo $start_date ?></td>
</tr>
<tr>
<td><?php echo get_vocab("duration") ?>:</td>
- <td><?php echo $duration . " " . $dur_units ?></td>
+ <td><?php echo $duration . " " . $dur_units ?></td>
</tr>
<tr>
<td><?php echo get_vocab("end_date") ?>:</td>
- <td><?php echo $end_date ?></td>
+ <td><?php echo $end_date ?></td>
</tr>
<tr>
<td><?php echo get_vocab("type") ?>:</td>
- <td><?php echo empty($typel[$type]) ? "?$type?" : $typel[$type] ?></td>
+ <td><?php echo empty($typel[$type]) ? "?$type?" : $typel[$type] ?></td>
</tr>
<tr>
<td><?php echo get_vocab("createdby") ?>:</td>
@@ -476,7 +490,7 @@
</tr>
<tr>
<td><?php echo get_vocab("lastupdate") ?>:</td>
- <td><?php echo $updated ?></td>
+ <td><?php echo $updated ?></td>
</tr>
<?php
// The custom fields
@@ -514,7 +528,7 @@
?>
<tr>
<td><?php echo get_vocab("rep_type") ?>:</td>
- <td><?php echo get_vocab($repeat_key) ?></td>
+ <td><?php echo get_vocab($repeat_key) ?></td>
</tr>
<?php
@@ -551,65 +565,61 @@
</table>
<div id="view_entry_nav">
- <div>
- <?php
+ <?php
+ // Only show the links for Edit/Copy/Delete if the room is enabled. We're
+ // allowed to view existing bookings in disabled rooms, but not to modify or
+ // delete them.
+ if (!$room_disabled && !$area_disabled)
+ {
+ // Edit and Edit Series
+ echo "<div>\n";
if (!$series)
{
echo "<a href=\"edit_entry.php?id=$id&returl=$link_returl\">".
get_vocab("editentry") ."</a>";
- }
-
+ }
if (!empty($repeat_id) && !$series && $repeats_allowed)
{
echo " - ";
- }
-
+ }
if ((!empty($repeat_id) || $series) && $repeats_allowed)
{
echo "<a
href=\"edit_entry.php?id=$id&edit_type=series&day=$day&month=$month&year=$year&returl=$link_returl\">".get_vocab("editseries")."</a>";
}
+ echo "</div>\n";
- ?>
- </div>
- <div>
- <?php
-
- // Copy and Copy series
+ // Copy and Copy Series
+ echo "<div>\n";
if (!$series)
{
echo "<a
href=\"edit_entry.php?id=$id&copy=1&returl=$link_returl\">".
get_vocab("copyentry") ."</a>";
- }
-
+ }
if (!empty($repeat_id) && !$series && $repeats_allowed)
{
echo " - ";
- }
-
+ }
if ((!empty($repeat_id) || $series) && $repeats_allowed)
{
echo "<a
href=\"edit_entry.php?id=$id&edit_type=series&day=$day&month=$month&year=$year&copy=1&returl=$link_returl\">".get_vocab("copyseries")."</a>";
}
+ echo "</div>\n";
- ?>
- </div>
- <div>
- <?php
+ // Delete and Delete Series
+ echo "<div>\n";
if (!$series)
{
echo "<a
href=\"del_entry.php?id=$id&series=0&returl=$link_returl\"
onclick=\"return
confirm('".get_vocab("confirmdel")."');\">".get_vocab("deleteentry")."</a>";
}
-
if (!empty($repeat_id) && !$series && $repeats_allowed)
{
echo " - ";
}
-
if ((!empty($repeat_id) || $series) && $repeats_allowed)
{
echo "<a
href=\"del_entry.php?id=$id&series=1&day=$day&month=$month&year=$year&returl=$link_returl\"
onClick=\"return
confirm('".get_vocab("confirmdel")."');\">".get_vocab("deleteseries")."</a>";
}
-
- ?>
- </div>
+ echo "</div>\n";
+ }
+ ?>
<div>
<?php
if (isset($HTTP_REFERER)) //remove the link if displayed from an email
Modified: mrbs/branches/disabled_rooms/web/week.php
===================================================================
--- mrbs/branches/disabled_rooms/web/week.php 2010-11-18 21:59:13 UTC (rev
1620)
+++ mrbs/branches/disabled_rooms/web/week.php 2010-11-19 16:59:23 UTC (rev
1621)
@@ -83,66 +83,17 @@
// Get the area and room names (we will need them later for the heading)
$this_area_name = "";
$this_room_name = "";
-$this_area_name = htmlspecialchars(sql_query1("SELECT area_name FROM $tbl_area
WHERE id=$area LIMIT 1"));
-$this_room_name = htmlspecialchars(sql_query1("SELECT room_name FROM $tbl_room
WHERE id=$room LIMIT 1"));
+$this_area_name = sql_query1("SELECT area_name FROM $tbl_area WHERE id=$area
AND disabled=0 LIMIT 1");
+$this_room_name = sql_query1("SELECT room_name FROM $tbl_room WHERE id=$room
AND disabled=0 LIMIT 1");
+// The room is invalid if it doesn't exist, or else it has been disabled,
either explicitly
+// or implicitly because the area has been disabled
+$room_invalid = ($this_area_name === -1) || ($this_room_name === -1);
-$sql = "select id, area_name from $tbl_area order by area_name";
-$res = sql_query($sql);
// Show all available areas
-// but only if there's more than one of them, otherwise there's no point
-if ($res && (sql_count($res)>1))
-{
- echo "<div id=\"dwm_areas\"><h3>".get_vocab("areas")."</h3>";
-
- // show either a select box or the normal html list
- if ($area_list_format == "select")
- {
- echo make_area_select_html('week.php', $area, $year, $month, $day);
- }
- else
- {
- echo "<ul>\n";
- for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
- {
- echo "<li><a
href=\"week.php?year=$year&month=$month&day=$day&area=${row['id']}\">";
- echo "<span" . (($row['id'] == $area) ? ' class="current"' : '') . ">";
- echo htmlspecialchars($row['area_name']) . "</span></a></li>\n";
- }
- echo "</ul>\n";
- } // end area display if
-
- echo "</div>\n";
-}
+echo make_area_select_html('week.php', $area, $year, $month, $day);
+// Show all available rooms in the current area:
+echo make_room_select_html('week.php', $area, $room, $year, $month, $day);
-// Show all rooms in the current area
-echo "<div id=\"dwm_rooms\"><h3>".get_vocab("rooms")."</h3>";
-
-// should we show a drop-down for the room list, or not?
-if ($area_list_format == "select")
-{
- echo make_room_select_html('week.php', $area, $room,
- $year, $month, $day);
-}
-else
-{
- $sql = "select id, room_name from $tbl_room
- where area_id=$area order by sort_key";
- $res = sql_query($sql);
- if ($res)
- {
- echo "<ul>\n";
- for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
- {
- echo "<li><a
href=\"week.php?year=$year&month=$month&day=$day&area=$area&room=".$row['id']."\">";
- echo "<span" . (($row['id'] == $room) ? ' class="current"' : '') . ">";
- echo htmlspecialchars($row['room_name']) . "</span></a></li>\n";
- }
- echo "</ul>\n";
- }
-} // end select if
-
-echo "</div>\n";
-
// Draw the three month calendars
minicals($year, $month, $day, $area, $room, 'week');
echo "</div>\n";
@@ -150,8 +101,9 @@
// End of "screenonly" div
echo "</div>\n";
-// Don't continue if this area has no rooms:
-if ($room <= 0)
+// Don't continue if this room is invalid, which could be because the area
+// has no rooms, or else the room or area has been disabled
+if ($room_invalid)
{
echo "<h1>".get_vocab("no_rooms_for_area")."</h1>";
require_once "trailer.inc";
@@ -160,7 +112,7 @@
// Show area and room:
echo "<div id=\"dwm\">\n";
-echo "<h2>$this_area_name - $this_room_name</h2>\n";
+echo "<h2>" . htmlspecialchars("$this_area_name - $this_room_name") .
"</h2>\n";
echo "</div>\n";
//y? are year, month and day of the previous week.
@@ -201,7 +153,8 @@
print $before_after_links_html;
-//Get all appointments for this week in the room that we care about
+// Get all appointments for this week in the room that we care about.
+//
// row['room_id'] = Room ID
// row['start_time'] = Start time
// row['end_time'] = End time
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits