Changeset:
ebf568ed6bd4
https://sourceforge.net/p/mrbs/hg-code/ci/ebf568ed6bd4b28fc75ccd5176190c535f59b3b0
Author:
Campbell Morrison <[email protected]>
Date:
Fri Dec 18 17:54:24 2015 +0000
Log message:
Removed some more SQL from functions_table.inc
diffstat:
web/functions_table.inc | 19 ++++---------------
web/mrbs_sql.inc | 16 +++++++++-------
2 files changed, 13 insertions(+), 22 deletions(-)
diffs (74 lines):
diff -r 2e45eb4c1568 -r ebf568ed6bd4 web/functions_table.inc
--- a/web/functions_table.inc Fri Dec 18 16:42:13 2015 +0000
+++ b/web/functions_table.inc Fri Dec 18 17:54:24 2015 +0000
@@ -957,7 +957,6 @@
function week_table_innerhtml($day, $month, $year, $room_id, $area_id,
$timetohighlight=NULL)
{
- global $tbl_room, $tbl_area;
global $enable_periods, $periods;
global $times_along_top, $row_labels_both_sides, $column_labels_both_ends;
global $resolution, $morningstarts, $morningstarts_minutes, $eveningends,
$eveningends_minutes;
@@ -965,24 +964,14 @@
global $first_last_width, $column_hidden_width, $hidden_days;
// Check that we've got a valid, enabled room
- $sql = "SELECT COUNT(*)
- FROM $tbl_room R, $tbl_area A
- WHERE R.id=$room_id
- AND R.area_id=A.id
- AND R.disabled=0
- AND A.disabled = 0";
+ $room_name = get_room_name($room_id);
- $n_rooms = sql_query1($sql);
- if (($n_rooms < 0) || ($n_rooms > 1))
+ if ($room_name === FALSE)
{
- if ($n_rooms > 1)
- {
- // Should never happen
- trigger_error("Internal error: multiple rooms with same id",
E_USER_WARNING);
- }
+ // Should never happen
fatal_error(FALSE, get_vocab("fatal_db_error"));
}
- if ($n_rooms == 0)
+ if (is_null($room_name))
{
// No rooms have been created yet, or else they are all disabled
// Add an 'empty' data flag so that the JavaScript knows whether this is a
real table or not
diff -r 2e45eb4c1568 -r ebf568ed6bd4 web/mrbs_sql.inc
--- a/web/mrbs_sql.inc Fri Dec 18 16:42:13 2015 +0000
+++ b/web/mrbs_sql.inc Fri Dec 18 17:54:24 2015 +0000
@@ -1461,21 +1461,23 @@
}
-// Get the name of the room with id $id. If $all is set to TRUE then all
rooms
+// Get the name of the room with id $room_id. If $all is set to TRUE then
all rooms
// are searched, otherwise just those which have not been disabled
// Returns FALSE if there is an error, NULL if the id does not exist
-function get_room_name($id, $all=FALSE)
+function get_room_name($room_id, $all=FALSE)
{
- global $tbl_room;
+ global $tbl_room, $tbl_area;
- $id = (int)$id;
+ $room_id = (int)$room_id;
$sql = "SELECT room_name
- FROM $tbl_room
- WHERE id=$id";
+ FROM $tbl_room R, $tbl_area A
+ WHERE R.id=$room_id
+ AND R.area_id=A.id";
+
if (empty($all))
{
- $sql .= " AND disabled=0";
+ $sql .= " AND R.disabled=0 AND A.disabled=0";
}
$sql .= " LIMIT 1";
------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits