Revision: 1535
http://mrbs.svn.sourceforge.net/mrbs/?rev=1535&view=rev
Author: cimorrison
Date: 2010-10-22 15:43:45 +0000 (Fri, 22 Oct 2010)
Log Message:
-----------
Added the ability to prevent ordinary users from making multi-day bookings.
Controlled by $auth['only_admin_can_book_multiday']
Modified Paths:
--------------
mrbs/branches/from_to_bookings/web/Themes/default/header.inc
mrbs/branches/from_to_bookings/web/edit_entry.php
mrbs/branches/from_to_bookings/web/edit_entry_handler.php
mrbs/branches/from_to_bookings/web/systemdefaults.inc.php
Modified: mrbs/branches/from_to_bookings/web/Themes/default/header.inc
===================================================================
--- mrbs/branches/from_to_bookings/web/Themes/default/header.inc
2010-10-22 14:27:07 UTC (rev 1534)
+++ mrbs/branches/from_to_bookings/web/Themes/default/header.inc
2010-10-22 15:43:45 UTC (rev 1535)
@@ -9,11 +9,12 @@
$search_str, $locale_warning, $area_defaults;
global $tbl_entry, $tbl_room, $tbl_area;
global $PHP_SELF, $view_week_number, $weekstarts;
- global $enable_periods;
+ global $enable_periods, $auth;
global $default_language_tokens, $disable_automatic_language_changing,
$override_locale;
global $lang_map_windows, $langs;
$page = basename($PHP_SELF, ".php" );
+ $is_admin = (authGetUserLevel($user) >= 2);
// If we dont know the right date then make it up
if (!$day)
@@ -347,15 +348,29 @@
?>
function getDateDifference(form)
{
+ var diff;
var startDay = parseInt(form.start_datepicker_alt_day.value);
var startMonth = parseInt(form.start_datepicker_alt_month.value);
var startYear = parseInt(form.start_datepicker_alt_year.value);
- var endDay = parseInt(form.end_datepicker_alt_day.value);
- var endMonth = parseInt(form.end_datepicker_alt_month.value);
- var endYear = parseInt(form.end_datepicker_alt_year.value);
- var startDate = new Date(startYear, startMonth - 1, startDay, 12);
- var endDate = new Date(endYear, endMonth - 1, endDay, 12);
- var diff = (endDate - startDate)/(24 * 60 * 60 * 1000);
+ <?php
+ if (!$is_admin && $auth['only_admin_can_book_multiday'])
+ {
+ ?>
+ diff = 0;
+ <?php
+ }
+ else
+ {
+ ?>
+ var endDay = parseInt(form.end_datepicker_alt_day.value);
+ var endMonth = parseInt(form.end_datepicker_alt_month.value);
+ var endYear = parseInt(form.end_datepicker_alt_year.value);
+ var startDate = new Date(startYear, startMonth - 1, startDay, 12);
+ var endDate = new Date(endYear, endMonth - 1, endDay, 12);
+ diff = (endDate - startDate)/(24 * 60 * 60 * 1000);
+ <?php
+ }
+ ?>
return diff;
}
@@ -612,9 +627,9 @@
// PENDING.PHP
if ($page == 'pending')
{
- ?>
+ ?>
activate_sub_tables();
- <?php
+ <?php
}
// SEARCH.PHP
@@ -726,7 +741,6 @@
$provisional_somewhere = (sql_query1($sql) > 0);
if ($provisional_somewhere && (authGetUserLevel($user) >= 1))
{
- $is_admin = (authGetUserLevel($user) >= 2);
// Find out how many provisional bookings there are
// (but only for areas where provisional bookings are enabled)
$sql = "SELECT COUNT(*)
Modified: mrbs/branches/from_to_bookings/web/edit_entry.php
===================================================================
--- mrbs/branches/from_to_bookings/web/edit_entry.php 2010-10-22 14:27:07 UTC
(rev 1534)
+++ mrbs/branches/from_to_bookings/web/edit_entry.php 2010-10-22 15:43:45 UTC
(rev 1535)
@@ -115,6 +115,8 @@
// You're only allowed to make repeat bookings if you're an admin
// or else if $auth['only_admin_can_book_repeat'] is not set
$repeats_allowed = $is_admin || empty($auth['only_admin_can_book_repeat']);
+// Similarly for multi-day
+$multiday_allowed = $is_admin || empty($auth['only_admin_can_book_multiday']);
// This page will either add or modify a booking
@@ -642,7 +644,10 @@
echo "<div id=\"div_end_date\">\n";
echo "<label for=\"start_datepicker\">" . get_vocab("end") . ":</label>\n";
$date = getdate($end_time);
+ // Don't show the end date selector if multiday is not allowed
+ echo "<div" . (($multiday_allowed) ? '' : " style=\"visibility: hidden\"")
. ">\n";
gendateselector("end_", $date['mday'], $date['mon'], $date['year']);
+ echo "</div>\n";
// If we're using periods the booking model is slightly different,
// so subtract one period because the "end" period is actually the
beginning
// of the last period booked
Modified: mrbs/branches/from_to_bookings/web/edit_entry_handler.php
===================================================================
--- mrbs/branches/from_to_bookings/web/edit_entry_handler.php 2010-10-22
14:27:07 UTC (rev 1534)
+++ mrbs/branches/from_to_bookings/web/edit_entry_handler.php 2010-10-22
15:43:45 UTC (rev 1535)
@@ -158,6 +158,15 @@
$user = getUserName();
$is_admin = (authGetUserLevel($user) >= 2);
+// If they're not an admin and multi-day bookings are not allowed, then
+// set the end date to the start date
+if (!$is_admin && $auth['only_admin_can_book_multiday'])
+{
+ $end_day = $day;
+ $end_month = $month;
+ $end_year = $year;
+}
+
// Check to see whether this is a repeat booking and if so, whether the user
// is allowed to make/edit repeat bookings. (The edit_entry form should
// prevent you ever getting here, but this check is here as a safeguard in
Modified: mrbs/branches/from_to_bookings/web/systemdefaults.inc.php
===================================================================
--- mrbs/branches/from_to_bookings/web/systemdefaults.inc.php 2010-10-22
14:27:07 UTC (rev 1534)
+++ mrbs/branches/from_to_bookings/web/systemdefaults.inc.php 2010-10-22
15:43:45 UTC (rev 1535)
@@ -679,6 +679,9 @@
// If you want only administrators to be able to make repeat bookings,
// set this variable to TRUE
$auth['only_admin_can_book_repeat'] = FALSE;
+// If you want only administrators to be able to make bookings spanning
+// more than one day, set this variable to TRUE
+$auth['only_admin_can_book_multiday'] = FALSE;
// If you want to prevent the public (ie un-logged in users) from
// being able to view bookings, set this variable to TRUE
$auth['deny_public_access'] = FALSE;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits