Revision: 2342
http://mrbs.svn.sourceforge.net/mrbs/?rev=2342&view=rev
Author: cimorrison
Date: 2012-07-20 11:31:37 +0000 (Fri, 20 Jul 2012)
Log Message:
-----------
Added a new config setting, $max_booking_date, to prevent bookings after a
certain date, eg the end of term. Thanks to a suggestion by Matthew Hilling.
Modified Paths:
--------------
mrbs/trunk/web/lang/lang.en
mrbs/trunk/web/mrbs_sql.inc
mrbs/trunk/web/systemdefaults.inc.php
Modified: mrbs/trunk/web/lang/lang.en
===================================================================
--- mrbs/trunk/web/lang/lang.en 2012-07-19 08:13:23 UTC (rev 2341)
+++ mrbs/trunk/web/lang/lang.en 2012-07-20 11:31:37 UTC (rev 2342)
@@ -176,6 +176,7 @@
$vocab["info_requested"] = "Information requested";
$vocab["min_time_before"] = "The minimum interval between now and the
start of a booking is";
$vocab["max_time_before"] = "The maximum interval between now and the
end of a booking is";
+$vocab["latest_booking_date"] = "The latest booking date is";
$vocab["max_booking_duration"] = "The maximum duration of a booking is";
$vocab["max_per_day_global"] = "The maximum number of bookings per day
per user across the whole system is";
$vocab["max_per_week_global"] = "The maximum number of bookings per week
per user across the whole system is";
Modified: mrbs/trunk/web/mrbs_sql.inc
===================================================================
--- mrbs/trunk/web/mrbs_sql.inc 2012-07-19 08:13:23 UTC (rev 2341)
+++ mrbs/trunk/web/mrbs_sql.inc 2012-07-20 11:31:37 UTC (rev 2342)
@@ -246,9 +246,10 @@
global $periods, $enable_periods;
global $min_book_ahead_enabled, $min_book_ahead_secs;
global $max_book_ahead_enabled, $max_book_ahead_secs;
+ global $max_booking_date_enabled, $max_booking_date;
global $max_duration_enabled, $max_duration_secs, $max_duration_periods;
global $max_per_interval_global_enabled, $max_per_interval_area_enabled;
- global $interval_types;
+ global $interval_types, $strftime_format;
$errors = array();
$secs_in_day = 60*60*24;
@@ -293,6 +294,23 @@
}
}
+ // Check max_booking_date
+ if ($max_booking_date_enabled && !$delete)
+ {
+ list($y, $m, $d) = explode('-', $max_booking_date);
+ if (isset($y) && isset($m) && isset($d) && checkdate($m, $d, $y))
+ {
+ if ($booking['end_time'] > mktime(0, 0, 0, $m, $d+1, $y))
+ {
+ $errors[] = get_vocab("latest_booking_date") . " " .
strftime($strftime_format['date'], mktime(0, 0, 0, $m, $d, $y));
+ }
+ }
+ else
+ {
+ trigger_error("Invalid max_book_ahead_date", E_USER_NOTICE);
+ }
+ }
+
// Check max_duration (but not if we're deleting a booking)
if ($max_duration_enabled && !$delete)
{
Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php 2012-07-19 08:13:23 UTC (rev
2341)
+++ mrbs/trunk/web/systemdefaults.inc.php 2012-07-20 11:31:37 UTC (rev
2342)
@@ -258,6 +258,14 @@
$max_per_interval_global_enabled['future'] = FALSE;
$max_per_interval_global['future'] = 100; // max 100 bookings in the future in
total
+// Set the latest date for which you can make a booking. This can be useful
if you
+// want to set an absolute date, eg the end of term, beyond which bookings
cannot be made.
+// If you want to set a relative date, eg no more than a week away, then this
can be done
+// using the area settings. Note that it is possible to have both a relative
and absolute
+// date, eg "no more than a week away and in any casae not past the end of
term".
+// Note that bookings are allowed on the $max_booking_date, but not after it.
+$max_booking_date_enabled = FALSE;
+$max_booking_date = "2012-07-23"; // Must be a string in the format
"yyyy-mm-dd"
/******************
* Display settings
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits