Revision: 1381
http://mrbs.svn.sourceforge.net/mrbs/?rev=1381&view=rev
Author: cimorrison
Date: 2010-07-25 16:53:24 +0000 (Sun, 25 Jul 2010)
Log Message:
-----------
Edit_entry will now process new bookings with custom fields (but not yet repeat
entries)
Modified Paths:
--------------
mrbs/branches/custom_entry_fields/tables.my.sql
mrbs/branches/custom_entry_fields/tables.pg.pre73.sql
mrbs/branches/custom_entry_fields/tables.pg.sql
mrbs/branches/custom_entry_fields/web/edit_entry.php
mrbs/branches/custom_entry_fields/web/edit_entry_handler.php
mrbs/branches/custom_entry_fields/web/mrbs_sql.inc
mrbs/branches/custom_entry_fields/web/systemdefaults.inc.php
Modified: mrbs/branches/custom_entry_fields/tables.my.sql
===================================================================
--- mrbs/branches/custom_entry_fields/tables.my.sql 2010-07-23 22:12:28 UTC
(rev 1380)
+++ mrbs/branches/custom_entry_fields/tables.my.sql 2010-07-25 16:53:24 UTC
(rev 1381)
@@ -5,12 +5,17 @@
#
# Notes:
# (1) 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' and 'INSERT INTO' line below to replace 'mrbs_' with
-# your new table prefix.
+# to something else using $db_tbl_prefix then you must edit each
+# 'CREATE TABLE' and 'INSERT INTO' line below to replace 'mrbs_' with
+# your new table prefix.
+#
# (2) 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.
+# to see whether a corresponding length has been defined in the config file
+# in the array $maxlength.
+#
+# (3) If you add new 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.
CREATE TABLE mrbs_area
(
Modified: mrbs/branches/custom_entry_fields/tables.pg.pre73.sql
===================================================================
--- mrbs/branches/custom_entry_fields/tables.pg.pre73.sql 2010-07-23
22:12:28 UTC (rev 1380)
+++ mrbs/branches/custom_entry_fields/tables.pg.pre73.sql 2010-07-25
16:53:24 UTC (rev 1381)
@@ -3,18 +3,22 @@
-- MRBS table creation script - for PostgreSQL
--
-- Notes:
--- 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.
+-- (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.
--
--- 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.
+-- (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.
--
--- 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.
+-- (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.
+--
+-- (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.
CREATE TABLE mrbs_area
(
Modified: mrbs/branches/custom_entry_fields/tables.pg.sql
===================================================================
--- mrbs/branches/custom_entry_fields/tables.pg.sql 2010-07-23 22:12:28 UTC
(rev 1380)
+++ mrbs/branches/custom_entry_fields/tables.pg.sql 2010-07-25 16:53:24 UTC
(rev 1381)
@@ -3,29 +3,34 @@
-- MRBS table creation script - for PostgreSQL 7.3 and above
--
-- Notes:
--- 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.
--- 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)
+-- (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)
--
--- 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.
+-- (3) 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.
--
--- 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.
+-- (4) 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
+-- $standard_fields. Note that if you are just adding custom fields for
+-- a single site then this is not necessary.
CREATE TABLE mrbs_area
Modified: mrbs/branches/custom_entry_fields/web/edit_entry.php
===================================================================
--- mrbs/branches/custom_entry_fields/web/edit_entry.php 2010-07-23
22:12:28 UTC (rev 1380)
+++ mrbs/branches/custom_entry_fields/web/edit_entry.php 2010-07-25
16:53:24 UTC (rev 1381)
@@ -51,10 +51,12 @@
// Duration
// Internal/External
+$fields = sql_field_info($tbl_entry);
+$custom_fields = array();
+
// Firstly we need to know if this is a new booking or modifying an old one
// and if it's a modification we need to get all the old data from the db.
// If we had $id passed in then it's a modification.
-$custom_fields = array();
if (isset($id))
{
@@ -248,6 +250,14 @@
$rep_end_year = $year;
$rep_day = array(0, 0, 0, 0, 0, 0, 0);
$private = $private_default;
+ // now initialise the custom fields
+ foreach ($fields as $field)
+ {
+ if (!in_array($field['name'], $standard_fields['entry']))
+ {
+ $custom_fields[$field['name']] = '';
+ }
+ }
}
// These next 4 if statements handle the situation where
@@ -782,7 +792,6 @@
// CUSTOM FIELDS
if (count($custom_fields))
{
- $fields = sql_field_info($tbl_entry);
$field_natures = array();
$field_lengths = array();
foreach ($fields as $field)
Modified: mrbs/branches/custom_entry_fields/web/edit_entry_handler.php
===================================================================
--- mrbs/branches/custom_entry_fields/web/edit_entry_handler.php
2010-07-23 22:12:28 UTC (rev 1380)
+++ mrbs/branches/custom_entry_fields/web/edit_entry_handler.php
2010-07-25 16:53:24 UTC (rev 1381)
@@ -34,28 +34,11 @@
$fields = sql_field_info($tbl_entry);
// Get custom form variables
-$standard_fields = array('id',
- 'start_time',
- 'end_time',
- 'entry_type',
- 'repeat_id',
- 'room_id',
- 'timestamp',
- 'create_by',
- 'name',
- 'type',
- 'description',
- 'private',
- 'status',
- 'reminded',
- 'info_time',
- 'info_user',
- 'info_text');
$custom_fields = array();
foreach($fields as $field)
{
- if (!in_array($field['name'], $standard_fields))
+ if (!in_array($field['name'], $standard_fields['entry']))
{
switch($field['nature'])
{
@@ -522,7 +505,8 @@
$description,
isset($rep_num_weeks) ?
$rep_num_weeks : 0,
$isprivate,
- $status);
+ $status,
+ $custom_fields);
$new_id = $booking['id'];
// Send a mail to the Administrator
Modified: mrbs/branches/custom_entry_fields/web/mrbs_sql.inc
===================================================================
--- mrbs/branches/custom_entry_fields/web/mrbs_sql.inc 2010-07-23 22:12:28 UTC
(rev 1380)
+++ mrbs/branches/custom_entry_fields/web/mrbs_sql.inc 2010-07-25 16:53:24 UTC
(rev 1381)
@@ -584,6 +584,7 @@
* $description - Description
* $private - Private Booking (bool)
* $status - Status code
+ * $custom_fields - an array of any custom fields
*
* Returns:
* an array
@@ -595,11 +596,10 @@
function mrbsCreateRepeatingEntrys($starttime, $endtime, $rep_type,
$rep_enddate, $rep_opt, $room_id, $owner,
$name, $type, $description, $rep_num_weeks,
- $private, $status)
+ $private, $status, $custom_fields)
{
global $max_rep_entrys;
- $custom_fields = array();
$result = array('id' => 0, 'series' => FALSE);
$private = $private ? 1 : 0 ;
Modified: mrbs/branches/custom_entry_fields/web/systemdefaults.inc.php
===================================================================
--- mrbs/branches/custom_entry_fields/web/systemdefaults.inc.php
2010-07-23 22:12:28 UTC (rev 1380)
+++ mrbs/branches/custom_entry_fields/web/systemdefaults.inc.php
2010-07-25 16:53:24 UTC (rev 1381)
@@ -868,7 +868,32 @@
define('REP_YEARLY', 4);
define('REP_MONTHLY_SAMEDAY', 5);
define('REP_N_WEEKLY', 6);
-
+
+ /****************************************************************
+ * DATABASE TABLES - STANDARD FIELDS - internal use, do not change
+ *****************************************************************/
+
+// These are the standard fields in the database tables. If you add more
+// standard (not user defined, custom) fields, then you need to change these
+
+$standard_fields['entry'] = array('id',
+ 'start_time',
+ 'end_time',
+ 'entry_type',
+ 'repeat_id',
+ 'room_id',
+ 'timestamp',
+ 'create_by',
+ 'name',
+ 'type',
+ 'description',
+ 'private',
+ 'status',
+ 'reminded',
+ 'info_time',
+ 'info_user',
+ 'info_text');
+
/********************************************************
* PHP System Configuration - internal use, do not change
********************************************************/
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits