Revision: 2011
http://mrbs.svn.sourceforge.net/mrbs/?rev=2011&view=rev
Author: cimorrison
Date: 2011-09-25 06:26:56 +0000 (Sun, 25 Sep 2011)
Log Message:
-----------
Merged in latest changes from the trunk
Modified Paths:
--------------
mrbs/branches/datatables/web/Themes/default/header.inc
mrbs/branches/datatables/web/edit_entry.php
mrbs/branches/datatables/web/edit_entry_handler.php
Property Changed:
----------------
mrbs/branches/datatables/
mrbs/branches/datatables/web/upgrade/5/pgsql.sql
Property changes on: mrbs/branches/datatables
___________________________________________________________________
Modified: svn:mergeinfo
- /mrbs/branches/custom_entry_fields:1374-1396
/mrbs/branches/datepicker:1409-1416
/mrbs/branches/disabled_rooms:1601-1634
/mrbs/branches/from_to_bookings:1491-1587
/mrbs/branches/ics_attachments:1652-1741
/mrbs/branches/improve_css_2008_06:804-872
/mrbs/branches/only_unicode:1747-1749
/mrbs/branches/provisional_bookings:1242-1280
/mrbs/branches/provisional_bookings_new_style:1407-1570
/mrbs/trunk:1863-2006
+ /mrbs/branches/custom_entry_fields:1374-1396
/mrbs/branches/datepicker:1409-1416
/mrbs/branches/disabled_rooms:1601-1634
/mrbs/branches/from_to_bookings:1491-1587
/mrbs/branches/ics_attachments:1652-1741
/mrbs/branches/improve_css_2008_06:804-872
/mrbs/branches/only_unicode:1747-1749
/mrbs/branches/provisional_bookings:1242-1280
/mrbs/branches/provisional_bookings_new_style:1407-1570
/mrbs/trunk:1863-2010
Modified: mrbs/branches/datatables/web/Themes/default/header.inc
===================================================================
--- mrbs/branches/datatables/web/Themes/default/header.inc 2011-09-25
06:21:48 UTC (rev 2010)
+++ mrbs/branches/datatables/web/Themes/default/header.inc 2011-09-25
06:26:56 UTC (rev 2011)
@@ -382,10 +382,10 @@
<?php
if (function_exists('json_encode'))
{
- // If we're doing Ajax checking of the form then we have to validate
- // the form when the datepicker is closed
+ // If we're doing Ajax checking of the form then we have to check
+ // for conflicts the form when the datepicker is closed
?>
- checkValidBooking();
+ checkConflicts();
<?php
}
}
@@ -461,69 +461,52 @@
// Add Ajax capabilities (but only if we can return the result as a JSON
object)
if (function_exists('json_encode'))
{
- // Form an array of all the form parameters that could affect whether a
booking can be made, ie
- // whether it will conflict with another booking or break a policy rule.
(So for example 'name'
- // and 'description' won't make any difference, but 'type' could be used
in policy checking).
- $params = array('area', 'rooms[]', 'create_by', 'type', 'all_day', 'id',
'rep_id', 'edit_type',
- 'start_seconds', 'start_day', 'start_month', 'start_year',
- 'end_seconds', 'end_day', 'end_month', 'end_year',
- 'rep_type', 'rep_end_day', 'rep_end_month',
'rep_end_year', 'rep_day[]', 'rep_num_weeks');
- // Fills the params object with a value from the form
- // (Note: params is an object, so passed by reference)
+ // Get the value of the field in the form
?>
- function fillParamFromForm(form, params, value)
+ function getFormValue(form, field)
{
<?php
// We need to exclude the disabled elements, because otherwise jQuery
// will pick them all up
?>
- form.find('[name="' + value + '"]:not(:disabled)').each(function() {
- <?php // Scalar parameters (two types - checkboxes and the rest) ?>
- var formInput = $(this);
- if (value.indexOf('[]') == -1)
+ var value;
+ var formInput = form.find('[name="' + field + '"]');
+ <?php // Scalar parameters (two types - checkboxes and the rest) ?>
+ if (field.indexOf('[]') == -1)
+ {
+ if (formInput.filter(':checkbox').length > 0)
{
- if (formInput.filter(':checkbox').length > 0)
- {
- params[value] = formInput.is(':checked') ? '1' : '';
- }
- else if (formInput.filter(':radio').length > 0)
- {
- params[value] = formInput.filter(':checked').val();
- }
- else
- {
- params[value] = formInput.val();
- }
+ value = formInput.is(':checked') ? '1' : '';
}
- <?php // Array parameters (two types - checkboxes and the rest) ?>
+ else if (formInput.filter(':radio').length > 0)
+ {
+ value = formInput.filter(':checked').val();
+ }
else
{
- params[value] = [];
- if (formInput.filter(':checkbox').length > 0)
- {
- formInput.each(function(index) {
- if ($(this).is(':checked'))
- {
- params[value].push($(this).val());
- }
- });
- }
- else
- {
- params[value] = formInput.val();
- }
- <?php
- // For some reason I don't understand, posting an empty array will
- // give you a PHP array of ('') at the other end. So to avoid
- // that problem, delete the property if the array is empty
- ?>
- if (params[value].length == 0)
- {
- delete params[value];
- }
+ value = formInput.val();
}
- });
+ }
+ <?php // Array parameters (two types - checkboxes and the rest) ?>
+ else
+ {
+ value = [];
+ if (formInput.filter(':checkbox').length > 0)
+ {
+ formInput.each(function(index) {
+ if ($(this).is(':checked'))
+ {
+ value.push($(this).val());
+ }
+ });
+ }
+ else
+ {
+ value = formInput.val();
+ }
+ }
+ return value;
}
<?php
@@ -531,57 +514,90 @@
// and (b) conforms to the booking policies. Makes an Ajax call to
edit_entry_handler but does
// not actually make the booking.
?>
- function checkValidBooking()
+ function checkConflicts()
{
- var params = {'ajax': 1}; <?php // This is an Ajax request ?>
- var form = $('form#main');
<?php
- foreach ($params as $param)
- {
- echo "fillParamFromForm(form, params, '$param');\n";
- }
+ // We set a small timeout on checking the booking in order to allow time
for
+ // the click handler on the Submit buttons to set the data in the form.
We then
+ // test the data and if it is set we don't validate the booking because
we're going off
+ // somewhere else. [This isn't an ideal way of doing this. The
problem is that
+ // the change event for a text input can be fired when the user clicks
the submit
+ // button - but how can you tell that it was the clicking of the submit
button that
+ // caused the change event?]
?>
- $.post('edit_entry_handler.php', params, function(result) {
- var conflictDiv = $('#conflict_check');
- var checkMark = "\u2714";
- var cross = "\u2718";
- var titleText;
- var patternSpan = /<span[\s\S]*span>/gi;
- var patternTags = /<\S[^><]*>/g;
- if (result.conflicts.length == 0)
- {
- conflictDiv.text(checkMark).attr('class', 'good').attr;
- titleText = '<?php echo
mrbs_entity_decode(get_vocab("no_conflicts")) ?>';
- }
- else
- {
- conflictDiv.text(cross).attr('class', 'bad');
- titleText = '<?php echo mrbs_entity_decode(get_vocab("conflict"))
?>' + ": \n\n";
- for (var i=0; i<result.conflicts.length; i++)
+ var timeout = 200; <?php // ms ?>
+ window.setTimeout(function() {
+ var params = {'ajax': 1}; <?php // This is an Ajax request ?>
+ var form = $('form#main');
+ if (form.data('submit'))
+ {
+ return;
+ }
+
+ // Load the params object with the values of all the form fields that
are not
+ // disabled and are not submit buttons of one kind or another
+ form.find('[name]').not(':disabled, [type="submit"], [type="button"],
[type="image"]').each(function() {
+ var fieldName = $(this).attr('name');
+ if (params[fieldName] === undefined)
{
- titleText += '(' + (i+1).toString() + ') ';
- <?php // strip out the <span> and its contents and then all
other tags ?>
- titleText += result.conflicts[i].replace(patternSpan,
'').replace(patternTags, '') + " \n";
+ params[fieldName] = getFormValue(form, fieldName);
}
- }
- conflictDiv.attr('title', titleText);
- var policyDiv = $('#policy_check');
- if (result.rules_broken.length == 0)
- {
- policyDiv.text(checkMark).attr('class', 'good');
- titleText = '<?php echo
mrbs_entity_decode(get_vocab("no_rules_broken")) ?>';
- }
- else
- {
- policyDiv.text(cross).attr('class', 'bad');
- titleText = '<?php echo
mrbs_entity_decode(get_vocab("rules_broken")) ?>' + ": \n\n";
- for (var i=0; i<result.rules_broken.length; i++)
+ });
+
+ <?php
+ // For some reason I don't understand, posting an empty array will
+ // give you a PHP array of ('') at the other end. So to avoid
+ // that problem, delete the property if the array (really an object)
is empty
+ ?>
+ $.each(params, function(i, val) {
+ if ((typeof(val) == 'object') && (val.length == 0))
{
- titleText += '(' + (i+1).toString() + ') ' +
result.rules_broken[i] + " \n";
+ delete params[i];
}
- }
- policyDiv.attr('title', titleText);
- }, 'json');
+ });
+
+ $.post('edit_entry_handler.php', params, function(result) {
+ var conflictDiv = $('#conflict_check');
+ var checkMark = "\u2714";
+ var cross = "\u2718";
+ var titleText;
+ var patternSpan = /<span[\s\S]*span>/gi;
+ var patternTags = /<\S[^><]*>/g;
+ if (result.conflicts.length == 0)
+ {
+ conflictDiv.text(checkMark).attr('class', 'good').attr;
+ titleText = '<?php echo
mrbs_entity_decode(get_vocab("no_conflicts")) ?>';
+ }
+ else
+ {
+ conflictDiv.text(cross).attr('class', 'bad');
+ titleText = '<?php echo
mrbs_entity_decode(get_vocab("conflict")) ?>' + ": \n\n";
+ for (var i=0; i<result.conflicts.length; i++)
+ {
+ titleText += '(' + (i+1).toString() + ') ';
+ <?php // strip out the <span> and its contents and then all
other tags ?>
+ titleText += result.conflicts[i].replace(patternSpan,
'').replace(patternTags, '') + " \n";
+ }
+ }
+ conflictDiv.attr('title', titleText);
+ var policyDiv = $('#policy_check');
+ if (result.rules_broken.length == 0)
+ {
+ policyDiv.text(checkMark).attr('class', 'good');
+ titleText = '<?php echo
mrbs_entity_decode(get_vocab("no_rules_broken")) ?>';
+ }
+ else
+ {
+ policyDiv.text(cross).attr('class', 'bad');
+ titleText = '<?php echo
mrbs_entity_decode(get_vocab("rules_broken")) ?>' + ": \n\n";
+ for (var i=0; i<result.rules_broken.length; i++)
+ {
+ titleText += '(' + (i+1).toString() + ') ' +
result.rules_broken[i] + " \n";
+ }
+ }
+ policyDiv.attr('title', titleText);
+ }, 'json');
+ }, timeout); <?php // setTimeout() ?>
}
<?php
}
@@ -791,7 +807,7 @@
// If we've changed areas and the modes are the same, we can try and
match times/periods.
// We will try and be conservative and find a start time that includes
the previous start time
// and an end time that includes the previous end time. This means
that by default the
- // booking period will include the old boioking period (unless we've hit
the start or
+ // booking period will include the old booking period (unless we've hit
the start or
// end of day). But it does mean that as you switch between areas the
booking period
// tends to get bigger: if you switch fromn Area 1 to Area 2 and then
bavk again it's
// possible that the booking period for Area 1 is longer than it was
originally.
@@ -1165,51 +1181,68 @@
<?php
}
+ // Set up handlers if anything like a submit button is pressed. If it's
the Save
+ // button we need to validate the form first. In addition, for all the
buttons, if
+ // we are going to submit something we set some data in the form. This
allows
+ // the function that checks for a valid booking to see if the change was
triggered
+ // by a Submit button being pressed, and if so, not to send an Ajax request.
+ ?>
+ $('form#main').find('[type="submit"], [type="button"],
[type="image"]').click(function() {
+ var trigger = $(this).attr('name');
+ var thisForm = $(this).parents('form').eq(0);
+ thisForm.data('submit', trigger);
+ if (trigger == 'save_button')
+ {
+ if (validate('main'))
+ {
+ thisForm.submit();
+ }
+ thisForm.removeData('submit');
+ return false;
+ }
+ return true;
+ });
+
+ <?php
// Add Ajax capabilities (but only if we can return the result as a JSON
object)
if (function_exists('json_encode'))
{
- // Add a change event handler to each of the form fields so that when they
change
- // the validity of the booking is re-checked. Use a click event for
checkboxes
- // as it seems that in some browsers the event fires before the value is
changed.
-
+ // Add a change event handler to each of the form fields - except for
those that
+ // are disabled and anything that might be a submit button - so that when
they change
+ // the validity of the booking is re-checked. (This probably causes more
checking
+ // than is really necessary, eg when the brief description is changed, but
on the other
+ // hand it (a) removes the need to know the names of the fields you want
and (b) keeps
+ // the data available for policy checking as complete as possible just in
case somebody
+ // decides to set a policy based on for example the brief description, for
some reason).
+ //
+ // Use a click event for checkboxes as it seems that in some browsers the
event fires
+ // before the value is changed.
+ //
// Note that we also need to add change event handlers to the start and end
- // datepicker input fields, but we have to that in datepicker_close()
+ // datepicker input fields, but we have to do that in datepicker_close()
?>
- var form = $('form#main');
- var formInput;
- <?php
- foreach ($params as $param)
- {
- ?>
- formInput = form.find('[name="<?php echo $param ?>"]');
- if (formInput.filter(':checkbox').length > 0)
- {
- formInput.click(function() {
- checkValidBooking();
- });
- }
- else
- {
- formInput.change(function() {
- checkValidBooking();
- });
- }
- <?php
- } // foreach
- ?>
-
- checkValidBooking();
+ var formFields = $('form#main [name]').not(':disabled, [type="submit"],
[type="button"], [type="image"]');
+ formFields.filter(':checkbox')
+ .click(function() {
+ checkConflicts();
+ });
+ formFields.not(':checkbox')
+ .change(function(event) {
+ checkConflicts();
+ });
+
+ checkConflicts();
<?php
- // Finally set a timer so that the validity of the booking is periodically
- // checked, in case someone else books that slot before you press Save
+ // Finally set a timer so that conflicts are periodically checked for,
+ // in case someone else books that slot before you press Save.
// (Note the config variable is in seconds, but the setInterval() function
// uses milliseconds)
if (!empty($ajax_refresh_rate))
{
?>
window.setInterval(function() {
- checkValidBooking();
+ checkConflicts();
}, <?php echo $ajax_refresh_rate * 1000 ?>);
<?php
}
Modified: mrbs/branches/datatables/web/edit_entry.php
===================================================================
--- mrbs/branches/datatables/web/edit_entry.php 2011-09-25 06:21:48 UTC (rev
2010)
+++ mrbs/branches/datatables/web/edit_entry.php 2011-09-25 06:26:56 UTC (rev
2011)
@@ -1256,7 +1256,7 @@
// The Submit button
echo "<div id=\"edit_entry_submit_save\">\n";
echo "<input class=\"submit\" type=\"submit\" name=\"save_button\"
value=\"" .
- get_vocab("save") . "\" onclick=\"if (validate('main'))
this.form.submit(); return false\">\n";
+ get_vocab("save") . "\">\n";
echo "</div>\n";
// divs to hold the results of the Ajax checking of the booking
Modified: mrbs/branches/datatables/web/edit_entry_handler.php
===================================================================
--- mrbs/branches/datatables/web/edit_entry_handler.php 2011-09-25 06:21:48 UTC
(rev 2010)
+++ mrbs/branches/datatables/web/edit_entry_handler.php 2011-09-25 06:26:56 UTC
(rev 2011)
@@ -62,6 +62,17 @@
$$var = get_form_var($var, $var_type);
}
+// BACK: we didn't really want to be here - send them to the returl
+if (!empty($back_button))
+{
+ if (empty($returl))
+ {
+ $returl = "index.php";
+ }
+ header("Location: $returl");
+ exit();
+}
+
// Get custom form variables
$custom_fields = array();
@@ -160,13 +171,6 @@
$returl = $returl_base[0];
}
-// BACK: we didn't really want to be here - send them to the returl
-if (!empty($back_button))
-{
- header("Location: $returl");
- exit();
-}
-
// If we haven't been given a sensible date then get out of here and don't
trey and make a booking
if (!isset($day) || !isset($month) || !isset($year) || !checkdate($month,
$day, $year))
{
Property changes on: mrbs/branches/datatables/web/upgrade/5/pgsql.sql
___________________________________________________________________
Modified: svn:mergeinfo
- /mrbs/branches/custom_entry_fields/web/upgrade/5/pgsql.sql:1374-1396
/mrbs/branches/datepicker/web/upgrade/5/pgsql.sql:1409-1416
/mrbs/branches/disabled_rooms/web/upgrade/5/pgsql.sql:1601-1634
/mrbs/branches/from_to_bookings/web/upgrade/5/pgsql.sql:1491-1587
/mrbs/branches/ics_attachments/web/upgrade/5/pgsql.sql:1652-1741
/mrbs/branches/only_unicode/web/upgrade/5/pgsql.sql:1747-1749
/mrbs/branches/provisional_bookings/web/upgrade/5/pgsql.sql:1242-1280
/mrbs/branches/provisional_bookings_new_style/web/upgrade/5/pgsql.sql:1407-1570
/mrbs/trunk/web/upgrade/5/pgsql.sql:1863-2006
+ /mrbs/branches/custom_entry_fields/web/upgrade/5/pgsql.sql:1374-1396
/mrbs/branches/datepicker/web/upgrade/5/pgsql.sql:1409-1416
/mrbs/branches/disabled_rooms/web/upgrade/5/pgsql.sql:1601-1634
/mrbs/branches/from_to_bookings/web/upgrade/5/pgsql.sql:1491-1587
/mrbs/branches/ics_attachments/web/upgrade/5/pgsql.sql:1652-1741
/mrbs/branches/only_unicode/web/upgrade/5/pgsql.sql:1747-1749
/mrbs/branches/provisional_bookings/web/upgrade/5/pgsql.sql:1242-1280
/mrbs/branches/provisional_bookings_new_style/web/upgrade/5/pgsql.sql:1407-1570
/mrbs/trunk/web/upgrade/5/pgsql.sql:1863-2010
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits