Revision: 1516
http://mrbs.svn.sourceforge.net/mrbs/?rev=1516&view=rev
Author: cimorrison
Date: 2010-10-19 10:51:13 +0000 (Tue, 19 Oct 2010)
Log Message:
-----------
Merged in latest changes from the trunk
Modified Paths:
--------------
mrbs/branches/provisional_bookings_new_style/INSTALL
mrbs/branches/provisional_bookings_new_style/web/edit_entry.php
mrbs/branches/provisional_bookings_new_style/web/edit_entry_handler.php
mrbs/branches/provisional_bookings_new_style/web/functions.inc
mrbs/branches/provisional_bookings_new_style/web/lang.en
mrbs/branches/provisional_bookings_new_style/web/session_cookie.inc
mrbs/branches/provisional_bookings_new_style/web/session_php.inc
mrbs/branches/provisional_bookings_new_style/web/systemdefaults.inc.php
Property Changed:
----------------
mrbs/branches/provisional_bookings_new_style/
mrbs/branches/provisional_bookings_new_style/web/upgrade/5/pgsql.sql
Property changes on: mrbs/branches/provisional_bookings_new_style
___________________________________________________________________
Modified: svn:mergeinfo
- /mrbs/branches/custom_entry_fields:1374-1396
/mrbs/branches/datepicker:1409-1416
/mrbs/branches/improve_css_2008_06:804-872
/mrbs/branches/provisional_bookings:1242-1280
/mrbs/trunk:1407-1504
+ /mrbs/branches/custom_entry_fields:1374-1396
/mrbs/branches/datepicker:1409-1416
/mrbs/branches/improve_css_2008_06:804-872
/mrbs/branches/provisional_bookings:1242-1280
/mrbs/trunk:1407-1515
Modified: mrbs/branches/provisional_bookings_new_style/INSTALL
===================================================================
--- mrbs/branches/provisional_bookings_new_style/INSTALL 2010-10-19
10:40:33 UTC (rev 1515)
+++ mrbs/branches/provisional_bookings_new_style/INSTALL 2010-10-19
10:51:13 UTC (rev 1516)
@@ -206,6 +206,44 @@
should then do the rest and display your coffee machine field on the room
pages.
+Extra options for custom fields:
+
+1)
+
+You can create dropdown boxes for a custom field by defining an
+entry in the configuration array $select_options. For example:
+
+$select_options['entry.conference_facilities'] = array('Video',
+ 'Telephone',
+ 'None');
+
+would define the 'conference_facilities' custom field to have three
+possible values.
+
+2)
+
+You can specify that a field is mandatory. This will ensure that the
+user specifies a value for a field that may be empty, like a text box
+or a selection, as in 1) above. For example:
+
+$is_mandatory_field['entry.conference_facilities'] = true;
+
+would define the 'conference_facilities' custom field to be mandatory.
+In the case of a select field, this adds an empty value to the dropdown
+list.
+
+3)
+
+You can also specify that a field is private, ensuring that the contents
+are only visible to yourself and the administrators. For example:
+
+$is_private_field['entry.refreshments'] = true;
+
+would prevent the details of your refreshments being visible to other
+users - provided that private bookings are enabled. See the section
+on private bookings in systemdefaults.inc.php for more information.
+
+
Technical explanation of the restriction on column names for custom fields
--------------------------------------------------------------------------
// Column names for custom fields are used by MRBS in a number of ways:
Modified: mrbs/branches/provisional_bookings_new_style/web/edit_entry.php
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/edit_entry.php
2010-10-19 10:40:33 UTC (rev 1515)
+++ mrbs/branches/provisional_bookings_new_style/web/edit_entry.php
2010-10-19 10:51:13 UTC (rev 1516)
@@ -426,6 +426,40 @@
alert("<?php echo get_vocab("you_have_not_selected") . '\n' .
get_vocab("valid_room") ?>");
return false;
}
+
+ <?php
+ if (count($is_mandatory_field))
+ {
+ $m_fields = array();
+ foreach ($is_mandatory_field as $field => $value)
+ {
+ if ($value)
+ {
+ $field = preg_replace('/^entry\./', 'f_', $field);
+ $m_fields[] = "'".str_replace("'", "\\'", $field)."'";
+ }
+ }
+ echo "var mandatory_fields = [".implode(', ', $m_fields)."];\n";
+ ?>
+ for (i = 0; i < mandatory_fields.length; i++)
+ {
+ if (form[mandatory_fields[i]].value == '')
+ {
+ label = $("label[for="+mandatory_fields[i]+"]").html();
+ label = label.replace(/:$/, '');
+ alert('"' + label + '" ' +
+ <?php echo '"'.
+ str_replace('"', '\\"',
+ get_vocab("is_mandatory_field")
+ ).
+ '"'; ?>);
+ return false;
+ }
+ }
+ <?php
+
+ }
+ ?>
// Form submit can take some times, especially if mails are enabled and
// there are more than one recipient. To avoid users doing weird things
@@ -908,7 +942,10 @@
// Output a select box if they want one
elseif (count($select_options["entry.$key"]) > 0)
{
- generate_select($label_text, $var_name, $value,
$select_options["entry.$key"]);
+ $mandatory = (array_key_exists("entry.$key", $is_mandatory_field) &&
+ $is_mandatory_field["entry.$key"]) ? true : false;
+ generate_select($label_text, $var_name, $value,
+ $select_options["entry.$key"], $mandatory);
}
// Output a textarea if it's a character string longer than the limit
for a
// text input
Modified:
mrbs/branches/provisional_bookings_new_style/web/edit_entry_handler.php
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/edit_entry_handler.php
2010-10-19 10:40:33 UTC (rev 1515)
+++ mrbs/branches/provisional_bookings_new_style/web/edit_entry_handler.php
2010-10-19 10:51:13 UTC (rev 1516)
@@ -250,6 +250,27 @@
print_footer(TRUE);
}
+if (count($is_mandatory_field))
+{
+ foreach ($is_mandatory_field as $field => $value)
+ {
+ $field = preg_replace('/^entry\./', '', $field);
+ if ($value && ($custom_fields[$field] == ''))
+ {
+ print_header($day, $month, $year, $area, isset($room) ? $room : "");
+?>
+ <h1><?php echo get_vocab('invalid_booking'); ?></h1>
+ <p>
+ <?php echo get_vocab('missing_mandatory_field')." \"".
+ get_loc_field_name($tbl_entry, $field)."\""; ?>
+ </p>
+<?php
+ // Print footer and exit
+ print_footer(TRUE);
+ }
+ }
+}
+
// Support locales where ',' is used as the decimal point
$duration = preg_replace('/,/', '.', $duration);
Modified: mrbs/branches/provisional_bookings_new_style/web/functions.inc
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/functions.inc
2010-10-19 10:40:33 UTC (rev 1515)
+++ mrbs/branches/provisional_bookings_new_style/web/functions.inc
2010-10-19 10:51:13 UTC (rev 1516)
@@ -323,13 +323,18 @@
// Generates a select box from $options, an array of options
// If $disabled is TRUE, then the select box is disabled and a hidden
// input is generated to pass through $value
-function generate_select($label_text, $name, $value, $options, $disabled=FALSE)
+function generate_select($label_text, $name, $value, $options,
+ $mandatory = FALSE, $disabled=FALSE)
{
// generate the HTML
$html = "<label for=\"$name\">$label_text</label>\n";
$html .= "<select id=\"$name\" name=\"$name\"";
$html .= ($disabled) ? " disabled=\"disabled\"" : '';
$html .= ">\n";
+ if ($mandatory)
+ {
+ $options = array_merge(array(""),$options);
+ }
foreach ($options as $option)
{
$html .= "<option";
Modified: mrbs/branches/provisional_bookings_new_style/web/lang.en
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/lang.en 2010-10-19
10:40:33 UTC (rev 1515)
+++ mrbs/branches/provisional_bookings_new_style/web/lang.en 2010-10-19
10:51:13 UTC (rev 1516)
@@ -95,6 +95,8 @@
$vocab["status"] = "Status";
$vocab["private"] = "Private";
$vocab["unavailable"] = "Private";
+$vocab["is_mandatory_field"] = "is a mandatory field, please supply a value";
+$vocab["missing_mandatory_field"] = "You have not supplied a value for the
mandatory field";
$vocab["confirmed"] = "Confirmed";
// Used in view_entry.php
Modified: mrbs/branches/provisional_bookings_new_style/web/session_cookie.inc
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/session_cookie.inc
2010-10-19 10:40:33 UTC (rev 1515)
+++ mrbs/branches/provisional_bookings_new_style/web/session_cookie.inc
2010-10-19 10:51:13 UTC (rev 1516)
@@ -41,7 +41,7 @@
{
$cookie_path = $PHP_SELF;
// Strip off everything after the last '/' in $PHP_SELF
- $cookie_path = preg_replace('/[^/]*$/', '', $cookie_path);
+ $cookie_path = preg_replace('/[^\/]*$/', '', $cookie_path);
}
/* Delete old-style cookies */
@@ -82,7 +82,14 @@
$UserPassword = $NewUserPassword;
}
- $expiry_time = time()+$auth['session_cookie']['session_expire_time'];
+ if ($auth['session_cookie']['session_expire_time'] == 0)
+ {
+ $expiry_time = 0;
+ }
+ else
+ {
+ $expiry_time = time()+$auth['session_cookie']['session_expire_time'];
+ }
$token = "AUTH".$UserName."|".$expiry_time;
if ($auth['session_cookie']['include_ip'])
{
@@ -196,7 +203,7 @@
function getUserName()
{
- global $blowfish, $REMOTE_ADDR;
+ global $blowfish, $REMOTE_ADDR, $auth;
$encrypted_token = NULL;
$username = NULL;
@@ -227,9 +234,11 @@
/* Check for a valid token */
if (isset($parts[0]) &&
- isset($parts[1]) && ($parts[1] > time()) &&
+ isset($parts[1]) &&
+ ((($auth["session_cookie"]["session_expire_time"] == 0) &&
+ ($parts[1] == 0)) || ($parts[1] > time())) &&
(!isset($parts[2]) ||
- (isset($parts[2]) && ($parts[2] == $REMOTE_ADDR))))
+ (isset($parts[2]) && ($parts[2] == $REMOTE_ADDR))))
{
$username = $parts[0];
}
Modified: mrbs/branches/provisional_bookings_new_style/web/session_php.inc
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/session_php.inc
2010-10-19 10:40:33 UTC (rev 1515)
+++ mrbs/branches/provisional_bookings_new_style/web/session_php.inc
2010-10-19 10:51:13 UTC (rev 1516)
@@ -35,7 +35,7 @@
{
$cookie_path = $PHP_SELF;
// Strip off everything after the last '/' in $PHP_SELF
- $cookie_path = preg_replace('/[^/]*$/', '', $cookie_path);
+ $cookie_path = preg_replace('/[^\/]*$/', '', $cookie_path);
}
global $auth;
@@ -47,9 +47,9 @@
$auth["session_php"]["session_expire_time"] = 0;
}
+session_name("MRBS_SESSID"); // call before session_set_cookie_params() - see
PHP manual
session_set_cookie_params($auth["session_php"]["session_expire_time"],
$cookie_path);
-session_name("MRBS_SESSID");
session_start();
/*
Modified:
mrbs/branches/provisional_bookings_new_style/web/systemdefaults.inc.php
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/systemdefaults.inc.php
2010-10-19 10:40:33 UTC (rev 1515)
+++ mrbs/branches/provisional_bookings_new_style/web/systemdefaults.inc.php
2010-10-19 10:51:13 UTC (rev 1516)
@@ -508,7 +508,11 @@
// - Entry table: name, description and custom fields
// - Users table: custom fields
+// You can define custom entry fields to be mandatory by setting
+// items in the array $is_mandatory_field. For example:
+// $is_mandatory_field['entry.coffee_required'] = true;
+
/***********************************************
* Authentication settings - read AUTHENTICATION
@@ -527,7 +531,7 @@
// The encryption secret key for the session tokens. You are strongly
// advised to change this if you use this session scheme
$auth["session_cookie"]["secret"] = "This isn't a very good secret!";
-// The expiry time of a session, in seconds
+// The expiry time of a session, in seconds. Set to 0 to use session cookies
$auth["session_cookie"]["session_expire_time"] = (60*60*24*30); // 30 days
// Whether to include the user's IP address in their session cookie.
// Increases security, but could cause problems with proxies/dynamic IP
@@ -547,7 +551,7 @@
// Cookie path override. If this value is set it will be used by the
// 'php' and 'cookie' session schemes to override the default behaviour
// of automatically determining the cookie path to use
-$cookie_path_override = '';
+//$cookie_path_override = '/mrbs/';
// The list of administrators (can modify other peoples settings).
//
Property changes on:
mrbs/branches/provisional_bookings_new_style/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/provisional_bookings/web/upgrade/5/pgsql.sql:1242-1280
/mrbs/trunk/web/upgrade/5/pgsql.sql:1407-1504
+ /mrbs/branches/custom_entry_fields/web/upgrade/5/pgsql.sql:1374-1396
/mrbs/branches/datepicker/web/upgrade/5/pgsql.sql:1409-1416
/mrbs/branches/provisional_bookings/web/upgrade/5/pgsql.sql:1242-1280
/mrbs/trunk/web/upgrade/5/pgsql.sql:1407-1515
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits