Revision: 2963
https://sourceforge.net/p/mrbs/code/2963/
Author: cimorrison
Date: 2015-01-20 09:37:36 +0000 (Tue, 20 Jan 2015)
Log Message:
-----------
Made max_duration a per-area setting
Modified Paths:
--------------
mrbs/trunk/tables.my.sql
mrbs/trunk/tables.pg.sql
mrbs/trunk/web/areadefaults.inc.php
mrbs/trunk/web/dbsys.inc
mrbs/trunk/web/edit_area_room.php
mrbs/trunk/web/functions.inc
mrbs/trunk/web/internalconfig.inc.php
mrbs/trunk/web/js/edit_area_room.js.php
mrbs/trunk/web/lang/lang.en
mrbs/trunk/web/systemdefaults.inc.php
Added Paths:
-----------
mrbs/trunk/web/upgrade/43/
mrbs/trunk/web/upgrade/43/mysql.sql
mrbs/trunk/web/upgrade/43/pgsql.sql
mrbs/trunk/web/upgrade/43/post.inc
Modified: mrbs/trunk/tables.my.sql
===================================================================
--- mrbs/trunk/tables.my.sql 2015-01-19 12:31:21 UTC (rev 2962)
+++ mrbs/trunk/tables.my.sql 2015-01-20 09:37:36 UTC (rev 2963)
@@ -53,6 +53,9 @@
max_per_year int DEFAULT 0 NOT NULL,
max_per_future_enabled tinyint(1) DEFAULT 0 NOT NULL,
max_per_future int DEFAULT 0 NOT NULL,
+ max_duration_enabled tinyint(1) DEFAULT 0 NOT NULL,
+ max_duration_secs int DEFAULT 0 NOT NULL,
+ max_duration_periods int DEFAULT 0 NOT NULL,
custom_html text CHARACTER SET utf8 COLLATE utf8_general_ci,
approval_enabled tinyint(1),
reminders_enabled tinyint(1),
@@ -185,6 +188,6 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ( 'db_version', '42');
+ VALUES ( 'db_version', '43');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ( 'local_db_version', '1');
Modified: mrbs/trunk/tables.pg.sql
===================================================================
--- mrbs/trunk/tables.pg.sql 2015-01-19 12:31:21 UTC (rev 2962)
+++ mrbs/trunk/tables.pg.sql 2015-01-20 09:37:36 UTC (rev 2963)
@@ -6,29 +6,17 @@
-- (1) MySQL inserts the current date/time into any timestamp field which is
not
-- specified on insert. To get the same effect, use PostgreSQL default
-- value current_timestamp.
---
--- (2) This script is EXPERIMENTAL. PostGreSQL folks have changed some
features
--- with 7.3 version which breaks many application, including mrbs :
--- - An empty string ('') is no longer allowed as the input into an
--- integer field. Formerly, it was silently interpreted as 0. If you
want
--- a field to be 0 then explicitly use 0, if you want it to be undefined
--- then use NULL.
--- - "INSERT" statements with column lists must specify all values;
--- e.g., INSERT INTO tab (col1, col2) VALUES ('val1') is now invalid
--- This tables creation script now works with 7.3, but the second issue
above
--- is already there, so currently mrbs does NOT work with pgsql 7.3 and
above
--- (thierry_bo 2003-12-03)
--
--- (3) If you have decided to change the prefix of your tables from 'mrbs_'
+-- (2) If you have decided to change the prefix of your tables from 'mrbs_'
-- to something else using $db_tbl_prefix then you must edit each
-- 'CREATE TABLE', 'create index' and 'INSERT INTO' line below to replace
-- 'mrbs_' with your new table prefix.
--
--- (4) If you change the varchar lengths here, then you should check
+-- (3) If you change the varchar lengths here, then you should check
-- to see whether a corresponding length has been defined in the config
file
-- in the array $maxlength.
--
--- (5) If you add new (standard) fields then you should also change the global
variable
+-- (4) If you add new (standard) fields then you should also change the global
variable
-- $standard_fields. Note that if you are just adding custom fields for
-- a single site then this is not necessary.
@@ -69,6 +57,9 @@
max_per_year int DEFAULT 0 NOT NULL,
max_per_future_enabled smallint DEFAULT 0 NOT NULL,
max_per_future int DEFAULT 0 NOT NULL,
+ max_duration_enabled smallint DEFAULT 0 NOT NULL,
+ max_duration_secs int DEFAULT 0 NOT NULL,
+ max_duration_periods int DEFAULT 0 NOT NULL,
custom_html text,
approval_enabled smallint,
reminders_enabled smallint,
Modified: mrbs/trunk/web/areadefaults.inc.php
===================================================================
--- mrbs/trunk/web/areadefaults.inc.php 2015-01-19 12:31:21 UTC (rev 2962)
+++ mrbs/trunk/web/areadefaults.inc.php 2015-01-20 09:37:36 UTC (rev 2963)
@@ -156,6 +156,14 @@
// will allow somebody to make a booking at 11:59 pm for the first period the
next day, which
// which may occur at 8.00 am.
+
+// Set a maximum duration for bookings
+$max_duration_enabled = FALSE; // Set to TRUE if you want to enforce a maximum
duration
+$max_duration_secs = 60*60*2; // (seconds) - when using "times"
+$max_duration_periods = 2; // (periods) - when using "periods"
+
+
+
// DEFAULT VALUES FOR NEW AREAS
// Set the maximum number of bookings that can be made in an area by any one
user, in an
// interval, which can be a day, week, month or year, or else in the future.
(A week is
Modified: mrbs/trunk/web/dbsys.inc
===================================================================
--- mrbs/trunk/web/dbsys.inc 2015-01-19 12:31:21 UTC (rev 2962)
+++ mrbs/trunk/web/dbsys.inc 2015-01-20 09:37:36 UTC (rev 2963)
@@ -24,7 +24,7 @@
}
-$db_schema_version = 42;
+$db_schema_version = 43;
$local_db_schema_version = 1;
// Include the abstraction configured to be used for the default MRBS
Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php 2015-01-19 12:31:21 UTC (rev 2962)
+++ mrbs/trunk/web/edit_area_room.php 2015-01-20 09:37:36 UTC (rev 2963)
@@ -252,7 +252,7 @@
}
-function create_field_entry_limits()
+function create_field_entry_max_number()
{
global $interval_types,
$max_per_interval_area_enabled, $max_per_interval_global_enabled,
@@ -295,6 +295,63 @@
}
+function create_field_entry_max_duration()
+{
+ global $max_duration_enabled, $max_duration_secs, $max_duration_periods;
+
+ // The max duration policies
+ echo "<fieldset>\n";
+ echo "<legend>" . get_vocab("booking_durations") . "</legend>\n";
+
+ echo "<div>\n";
+ $params = array('label' => get_vocab("max_duration") . ":",
+ 'name' => 'area_max_duration_enabled',
+ 'value' => $max_duration_enabled,
+ 'class' => 'enabler');
+ generate_checkbox($params);
+ echo "</div>\n";
+
+ echo "<div>\n";
+ $attributes = array('class="text"',
+ 'type="number"',
+ 'min="0"',
+ 'step="1"');
+ $params = array('name' => 'area_max_duration_periods',
+ 'label' => get_vocab("mode_periods") . ':',
+ 'value' => $max_duration_periods,
+ 'attributes' => $attributes);
+ generate_input($params);
+ echo "</div>\n";
+
+ echo "<div>\n";
+ $max_duration_value = $max_duration_secs;
+ toTimeString($max_duration_value, $max_duration_units);
+ $attributes = array('class="text"',
+ 'type="number"',
+ 'min="0"',
+ 'step="1"');
+ $params = array('name' => 'area_max_duration_value',
+ 'label' => get_vocab("mode_times") . ':',
+ 'value' => $max_duration_value,
+ 'attributes' => $attributes);
+ generate_input($params);
+
+ $units = array("seconds", "minutes", "hours", "days", "weeks");
+ $options = array();
+ foreach ($units as $unit)
+ {
+ $options[$unit] = get_vocab($unit);
+ }
+ $params = array('name' => 'area_max_duration_units',
+ 'value' => array_search($max_duration_units, $options),
+ 'options' => $options);
+ generate_select($params);
+ echo "</div>\n";
+
+ echo "</fieldset>\n";
+}
+
+
// Get non-standard form variables
$phase = get_form_var('phase', 'int');
$new_area = get_form_var('new_area', 'int');
@@ -332,6 +389,10 @@
$area_max_delete_ahead_enabled = get_form_var('area_max_delete_ahead_enabled',
'string');
$area_max_delete_ahead_value = get_form_var('area_max_delete_ahead_value',
'int');
$area_max_delete_ahead_units = get_form_var('area_max_delete_ahead_units',
'string');
+$area_max_duration_enabled = get_form_var('area_max_duration_enabled',
'string');
+$area_max_duration_periods = get_form_var('area_max_duration_periods', 'int');
+$area_max_duration_value = get_form_var('area_max_duration_value', 'int');
+$area_max_duration_units = get_form_var('area_max_duration_units', 'string');
$area_private_enabled = get_form_var('area_private_enabled', 'string');
$area_private_default = get_form_var('area_private_default', 'int');
$area_private_mandatory = get_form_var('area_private_mandatory', 'string');
@@ -602,6 +663,8 @@
fromTimeString($area_min_delete_ahead_value, $area_min_delete_ahead_units);
fromTimeString($area_max_delete_ahead_value, $area_max_delete_ahead_units);
+ fromTimeString($area_max_duration_value, $area_max_duration_units);
+
// If we are using periods, round these down to the nearest whole day
// (anything less than a day is meaningless when using periods)
if ($area_enable_periods)
@@ -627,6 +690,7 @@
'area_max_create_ahead_enabled',
'area_min_delete_ahead_enabled',
'area_max_delete_ahead_enabled',
+ 'area_max_duration_enabled',
'area_private_enabled',
'area_private_default',
'area_private_mandatory',
@@ -709,6 +773,7 @@
$assign_array[] = "max_create_ahead_enabled=" .
$area_max_create_ahead_enabled;
$assign_array[] = "min_delete_ahead_enabled=" .
$area_min_delete_ahead_enabled;
$assign_array[] = "max_delete_ahead_enabled=" .
$area_max_delete_ahead_enabled;
+ $assign_array[] = "max_duration_enabled=" . $area_max_duration_enabled;
if (isset($area_min_create_ahead_value))
{
@@ -726,6 +791,11 @@
{
$assign_array[] = "max_delete_ahead_secs=" .
$area_max_delete_ahead_value;
}
+ if (isset($area_max_duration_value))
+ {
+ $assign_array[] = "max_duration_secs=" . $area_max_duration_value;
+ $assign_array[] = "max_duration_periods=" . $area_max_duration_periods;
+ }
foreach($interval_types as $interval_type)
{
@@ -1233,7 +1303,8 @@
echo "<fieldset id=\"booking_policies\">\n";
echo "<legend>" . get_vocab("booking_policies") . "</legend>\n";
create_field_entry_advance_booking();
- create_field_entry_limits();
+ create_field_entry_max_number();
+ create_field_entry_max_duration();
echo "</fieldset>\n";
Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc 2015-01-19 12:31:21 UTC (rev 2962)
+++ mrbs/trunk/web/functions.inc 2015-01-20 09:37:36 UTC (rev 2963)
@@ -1686,6 +1686,7 @@
global $private_enabled, $private_default, $private_mandatory,
$private_override;
global $min_create_ahead_enabled, $max_create_ahead_enabled,
$min_create_ahead_secs, $max_create_ahead_secs;
global $min_delete_ahead_enabled, $max_delete_ahead_enabled,
$min_delete_ahead_secs, $max_delete_ahead_secs;
+ global $max_duration_enabled, $max_duration_secs, $max_duration_periods;
global $approval_enabled, $reminders_enabled, $enable_periods;
global $confirmation_enabled, $confirmed_default, $timezone;
global $max_per_interval_area_enabled, $max_per_interval_area;
@@ -1705,6 +1706,7 @@
'min_create_ahead_secs', 'max_create_ahead_secs',
'min_delete_ahead_enabled', 'max_delete_ahead_enabled',
'min_delete_ahead_secs', 'max_delete_ahead_secs',
+ 'max_duration_enabled', 'max_duration_secs',
'max_duration_periods',
'max_per_day_enabled', 'max_per_day',
'max_per_week_enabled', 'max_per_week',
'max_per_month_enabled', 'max_per_month',
Modified: mrbs/trunk/web/internalconfig.inc.php
===================================================================
--- mrbs/trunk/web/internalconfig.inc.php 2015-01-19 12:31:21 UTC (rev
2962)
+++ mrbs/trunk/web/internalconfig.inc.php 2015-01-20 09:37:36 UTC (rev
2963)
@@ -373,7 +373,7 @@
'max_per_month_enabled',
'max_per_year_enabled',
'max_per_future_enabled',
- 'max_duration_enabled', // not yet a per-area
setting, but will be sometime
+ 'max_duration_enabled',
'approval_enabled',
'reminders_enabled',
'enable_periods',
@@ -412,6 +412,9 @@
'max_delete_ahead_enabled',
'min_delete_ahead_secs',
'max_delete_ahead_secs',
+ 'max_duration_enabled',
+ 'max_duration_secs',
+ 'max_duration_periods',
'approval_enabled',
'reminders_enabled',
'enable_periods',
Modified: mrbs/trunk/web/js/edit_area_room.js.php
===================================================================
--- mrbs/trunk/web/js/edit_area_room.js.php 2015-01-19 12:31:21 UTC (rev
2962)
+++ mrbs/trunk/web/js/edit_area_room.js.php 2015-01-20 09:37:36 UTC (rev
2963)
@@ -249,7 +249,16 @@
// so that the inputs are enabled/disabled correctly initially.
?>
$('.enabler').change(function(){
- $(this).nextAll('input, select').attr('disabled',
!$(this).is(':checked'));
+ var enablerChecked = $(this).is(':checked');
+ if ($(this).attr('id') === 'area_max_duration_enabled')
+ {
+ <?php // This is structured slightly differently ?>
+ $('#area_max_duration_periods, #area_max_duration_value,
#area_max_duration_units').prop('disabled', !enablerChecked);
+ }
+ else
+ {
+ $(this).nextAll('input, select').prop('disabled', !enablerChecked);
+ }
})
.change();
Modified: mrbs/trunk/web/lang/lang.en
===================================================================
--- mrbs/trunk/web/lang/lang.en 2015-01-19 12:31:21 UTC (rev 2962)
+++ mrbs/trunk/web/lang/lang.en 2015-01-20 09:37:36 UTC (rev 2963)
@@ -406,6 +406,8 @@
$vocab["booking_creation"] = "Booking creation";
$vocab["booking_deletion"] = "Booking deletion";
$vocab["booking_limits"] = "Limits on the number of bookings";
+$vocab["booking_durations"] = "Limits on the duration of bookings";
+$vocab["max_duration"] = "Maximum duration";
$vocab["min_book_ahead"] = "Advance booking - minimum";
$vocab["max_book_ahead"] = "Advance booking - maximum";
$vocab["this_area"] = "This area";
Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php 2015-01-19 12:31:21 UTC (rev
2962)
+++ mrbs/trunk/web/systemdefaults.inc.php 2015-01-20 09:37:36 UTC (rev
2963)
@@ -248,11 +248,6 @@
// The settings below are global policy settings
-// Set a maximum duration for bookings
-$max_duration_enabled = FALSE; // Set to TRUE if you want to enforce a maximum
duration
-$max_duration_secs = 60*60*2; // (seconds) - when using "times"
-$max_duration_periods = 2; // (periods) - when using "periods"
-
// Set the maximum number of bookings that can be made by any one user, in an
interval,
// which can be a day, week, month or year, or else in the future. (A week is
defined
// by the $weekstarts setting). These are global settings, but you can
additionally
Added: mrbs/trunk/web/upgrade/43/mysql.sql
===================================================================
--- mrbs/trunk/web/upgrade/43/mysql.sql (rev 0)
+++ mrbs/trunk/web/upgrade/43/mysql.sql 2015-01-20 09:37:36 UTC (rev 2963)
@@ -0,0 +1,8 @@
+-- $Id$
+
+-- Make max_duration a per-area setting
+
+ALTER TABLE %DB_TBL_PREFIX%area
+ ADD COLUMN max_duration_enabled tinyint(1) DEFAULT 0 NOT NULL,
+ ADD COLUMN max_duration_secs int DEFAULT 0 NOT NULL,
+ ADD COLUMN max_duration_periods int DEFAULT 0 NOT NULL;
Property changes on: mrbs/trunk/web/upgrade/43/mysql.sql
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: mrbs/trunk/web/upgrade/43/pgsql.sql
===================================================================
--- mrbs/trunk/web/upgrade/43/pgsql.sql (rev 0)
+++ mrbs/trunk/web/upgrade/43/pgsql.sql 2015-01-20 09:37:36 UTC (rev 2963)
@@ -0,0 +1,8 @@
+-- $Id$
+
+-- Make max_duration a per-area setting
+
+ALTER TABLE %DB_TBL_PREFIX%area
+ ADD COLUMN max_duration_enabled smallint DEFAULT 0 NOT NULL,
+ ADD COLUMN max_duration_secs int DEFAULT 0 NOT NULL,
+ ADD COLUMN max_duration_periods int DEFAULT 0 NOT NULL;
Property changes on: mrbs/trunk/web/upgrade/43/pgsql.sql
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: mrbs/trunk/web/upgrade/43/post.inc
===================================================================
--- mrbs/trunk/web/upgrade/43/post.inc (rev 0)
+++ mrbs/trunk/web/upgrade/43/post.inc 2015-01-20 09:37:36 UTC (rev 2963)
@@ -0,0 +1,23 @@
+<?php
+
+// $Id$
+
+// Populate the new columns in the area table with the default values taken
+// from the config file.
+
+global $tbl_area;
+global $max_duration_enabled, $max_duration_secs, $max_duration_periods;
+
+$sql = "UPDATE $tbl_area
+ SET max_duration_enabled = " . ((empty($max_duration_enabled)) ? 0
: 1) . ",
+ max_duration_secs = " . ((empty($max_duration_secs)) ? 0 :
(int)$max_duration_secs) . ",
+ max_duration_periods = " . ((empty($max_duration_periods)) ? 0
: (int)$max_duration_periods);
+
+$res = sql_command($sql);
+if ($res == -1)
+{
+ echo sql_error();
+ // No need to localise, should never happen
+ print "<span class=\"error\">Failed to set default values for new columns in
area table.</span>";
+}
+
Property changes on: mrbs/trunk/web/upgrade/43/post.inc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits