Changeset:
435480e0e6ef
https://sourceforge.net/p/mrbs/hg-code/ci/435480e0e6ef42e0e509f7409e3042db6b1e7206
Author:
Campbell Morrison <[email protected]>
Date:
Sun Jan 03 10:28:44 2016 +0000
Log message:
Moved some SQL into mebs_sql.inc
diffstat:
web/edit_area_room.php | 18 +++++++++---------
web/mrbs_sql.inc | 36 +++++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 10 deletions(-)
diffs (118 lines):
diff -r 08a2efc7a634 -r 435480e0e6ef web/edit_area_room.php
--- a/web/edit_area_room.php Sun Jan 03 09:23:18 2016 +0000
+++ b/web/edit_area_room.php Sun Jan 03 10:28:44 2016 +0000
@@ -1072,14 +1072,14 @@
showAccessDenied($day, $month, $year, $area, "");
exit();
}
+
// Get the details for this area
- $res = sql_query("SELECT * FROM $tbl_area WHERE id=$area LIMIT 1");
- if (! $res)
+ $area_data = get_area_details($area);
+ if (empty($area_data))
{
fatal_error(0, get_vocab("error_area") . $area . get_vocab("not_found"));
}
- $row = sql_row_keyed($res, 0);
- sql_free($res);
+
// Get the settings for this area, from the database if they are there,
otherwise from
// the config file. A little bit inefficient repeating the SQL query
// we've just done, but it makes the code simpler and this page is not used
very often.
@@ -1108,13 +1108,13 @@
echo "<fieldset>\n";
echo "<legend>" . get_vocab("general_settings") . "</legend>\n";
- echo "<input type=\"hidden\" name=\"area\" value=\"" . $row["id"] . "\">\n";
+ echo "<input type=\"hidden\" name=\"area\" value=\"" . $area_data["id"] .
"\">\n";
// Area name
echo "<div>\n";
$params = array('label' => get_vocab("name") . ":",
'name' => 'area_name',
- 'value' => $row['area_name']);
+ 'value' => $area_data['area_name']);
generate_input($params);
echo "</div>\n";
@@ -1125,7 +1125,7 @@
$params = array('label' => get_vocab("status") . ":",
'label_title' => get_vocab("disabled_area_note"),
'name' => 'area_disabled',
- 'value' => ($row['disabled']) ? '1' : '0',
+ 'value' => ($area_data['disabled']) ? '1' : '0',
'options' => $options,
'force_assoc' => TRUE);
generate_radio_group($params);
@@ -1139,7 +1139,7 @@
$params = array('label' => get_vocab("area_admin_email") . ":",
'label_title' => get_vocab("email_list_note"),
'name' => 'area_admin_email',
- 'value' => $row['area_admin_email'],
+ 'value' => $area_data['area_admin_email'],
'attributes' => array('rows="4"', 'cols="40"'));
generate_textarea($params);
echo "</div>\n";
@@ -1149,7 +1149,7 @@
$params = array('label' => get_vocab("custom_html") . ":",
'label_title' => get_vocab("custom_html_note"),
'name' => 'custom_html',
- 'value' => $row['custom_html'],
+ 'value' => $area_data['custom_html'],
'attributes' => array('rows="4"', 'cols="40"'));
generate_textarea($params);
echo "</div>\n";
diff -r 08a2efc7a634 -r 435480e0e6ef web/mrbs_sql.inc
--- a/web/mrbs_sql.inc Sun Jan 03 09:23:18 2016 +0000
+++ b/web/mrbs_sql.inc Sun Jan 03 10:28:44 2016 +0000
@@ -1493,6 +1493,37 @@
}
+// Get all the area details for $area_id.
+// Returns FALSE on error, NULL if $area_id does not exist.
+function get_area_details($area_id)
+{
+ global $tbl_area;
+
+ $sql = "SELECT *
+ FROM $tbl_area
+ WHERE id=$area_id
+ LIMIT 1";
+
+ $res = sql_query($sql);
+
+ if ($res === FALSE)
+ {
+ trigger_error(sql_error(), E_USER_WARNING);
+ return FALSE;
+ }
+
+ if (sql_count($res) == 0)
+ {
+ return NULL;
+ }
+
+ $result = sql_row_keyed($res, 0);
+ sql_free($res);
+
+ return $result;
+}
+
+
// 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
@@ -1554,7 +1585,10 @@
return NULL;
}
- return sql_row_keyed($res, 0);
+ $result = sql_row_keyed($res, 0);
+ sql_free($res);
+
+ return $result;
}
------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits