Revision: 1907
http://mrbs.svn.sourceforge.net/mrbs/?rev=1907&view=rev
Author: cimorrison
Date: 2011-08-30 09:07:08 +0000 (Tue, 30 Aug 2011)
Log Message:
-----------
Restructured code
Modified Paths:
--------------
mrbs/trunk/web/approve_entry_handler.php
mrbs/trunk/web/edit_entry_handler.php
mrbs/trunk/web/functions_ical.inc
mrbs/trunk/web/functions_mail.inc
mrbs/trunk/web/mrbs_sql.inc
Modified: mrbs/trunk/web/approve_entry_handler.php
===================================================================
--- mrbs/trunk/web/approve_entry_handler.php 2011-08-29 18:22:01 UTC (rev
1906)
+++ mrbs/trunk/web/approve_entry_handler.php 2011-08-30 09:07:08 UTC (rev
1907)
@@ -99,8 +99,7 @@
// so that we will kniow whether to include iCalendar information in the
email)
get_area_settings($data['area_id']);
// Send the email
- $skip_list = array();
- $result = notifyAdminOnBooking($data, $skip_list, $mail_previous,
$is_new_entry, $series, $action, $note);
+ $result = notifyAdminOnBooking($data, $mail_previous, $is_new_entry,
$series, $action, $note);
}
}
Modified: mrbs/trunk/web/edit_entry_handler.php
===================================================================
--- mrbs/trunk/web/edit_entry_handler.php 2011-08-29 18:22:01 UTC (rev
1906)
+++ mrbs/trunk/web/edit_entry_handler.php 2011-08-30 09:07:08 UTC (rev
1907)
@@ -430,14 +430,14 @@
$valid_booking = TRUE;
$conflicts = ""; // Holds a list of all the conflicts (ideally this
would be an array)
$rules_broken = array(); // Holds an array of the rules that have been broken
-$skip_list = array(); // Holds a 2D array of bookings to skip past.
Indexed
+$skip_lists = array(); // Holds a 2D array of bookings to skip past.
Indexed
// by room id and start time
// Check for any schedule conflicts in each room we're going to try and
// book in; also check that the booking conforms to the policy
foreach ( $rooms as $room_id )
{
- $skip_list[$room_id] = array();
+ $skip_lists[$room_id] = array();
if ($rep_type != REP_NONE && !empty($reps))
{
if(count($reps) < $max_rep_entrys)
@@ -462,7 +462,7 @@
// Otherwise it's an invalid booking
if ($skip)
{
- $skip_list[$room_id][] = $reps[$i];
+ $skip_lists[$room_id][] = $reps[$i];
}
else
{
@@ -610,13 +610,18 @@
$data['entry_type'] = ($repeat_id > 0) ? ENTRY_RPT_CHANGED :
ENTRY_SINGLE;
$data['repeat_id'] = $repeat_id;
}
+ // Add in the list of bookings to skip
+ if (!empty($skip_lists) && !empty($skip_lists[$room_id]))
+ {
+ $data['skip_list'] = $skip_lists[$room_id];
+ }
// The following elements are needed for email notifications
$data['duration'] = $duration;
$data['dur_units'] = $dur_units;
if ($edit_type == "series")
{
- $booking = mrbsCreateRepeatingEntrys($data, $skip_list);
+ $booking = mrbsCreateRepeatingEntrys($data);
$new_id = $booking['id'];
$is_repeat_table = $booking['series'];
$data['id'] = $new_id; // Add in the id now we know it
@@ -670,7 +675,7 @@
$mail_previous = array();
}
// Send the email
- $result = notifyAdminOnBooking($data, $skip_list, $mail_previous,
!isset($id), $is_repeat_table);
+ $result = notifyAdminOnBooking($data, $mail_previous, !isset($id),
$is_repeat_table);
}
}
} // end foreach $rooms
Modified: mrbs/trunk/web/functions_ical.inc
===================================================================
--- mrbs/trunk/web/functions_ical.inc 2011-08-29 18:22:01 UTC (rev 1906)
+++ mrbs/trunk/web/functions_ical.inc 2011-08-30 09:07:08 UTC (rev 1907)
@@ -439,17 +439,12 @@
// Create an RFC 5545 iCalendar Event component
-//
-// $skip_list an optional 7th parameter containing a 2D array of dates to
-// skip in a series. Indexed by room_id and start_time
function create_ical_event($method, $data, $text_description,
$html_description, $addresses, $series=FALSE)
{
require_once "functions_mail.inc";
global $confirmation_enabled, $mail_settings, $timezone, $vtimezone;
- $skip_list = (func_num_args() > 6) ? func_get_arg(6) : array();
-
$use_html = $mail_settings['html'] && !empty($html_description);
$results = array();
@@ -492,11 +487,11 @@
if ($series)
{
$results[] = "RRULE:" . create_rrule($data);
- if (!empty($skip_list[$data['room_id']]))
+ if (!empty($data['skip_list']))
{
$results[] = "EXDATE" .
(($vtimezone === FALSE) ? ":" : ";TZID=$timezone:") .
- create_exdate_list($skip_list[$data['room_id']]);
+ create_exdate_list($data['skip_list']);
}
}
$results[] = "SUMMARY:" . ical_escape_text($data['name']);
Modified: mrbs/trunk/web/functions_mail.inc
===================================================================
--- mrbs/trunk/web/functions_mail.inc 2011-08-29 18:22:01 UTC (rev 1906)
+++ mrbs/trunk/web/functions_mail.inc 2011-08-30 09:07:08 UTC (rev 1907)
@@ -793,8 +793,6 @@
* Send email to administrator to notify a new/changed entry.
*
* @param array $data contains the data for this entry
- * @param array $skip_list a 2D array containing a list of dates in a
series to skip
- * indexed by room_id and start_time
* @param array $mail_previous contains the data for the previous entry, or
is an empty array
* @param bool $new_entry whether this is a new entry or not
* @param bool $series whether this is a series or not
@@ -802,7 +800,7 @@
* @param string $note a note that is used with "more_info"
* @return bool TRUE or PEAR error object if fails
*/
-function notifyAdminOnBooking($data, &$skip_list, $mail_previous, $new_entry,
$series, $action="book", $note='')
+function notifyAdminOnBooking($data, $mail_previous, $new_entry, $series,
$action="book", $note='')
{
global $mail_settings, $enable_periods;
@@ -885,7 +883,7 @@
{
$attachment['method'] = "REQUEST";
$ical_components = array();
- $ical_components[] = create_ical_event($attachment['method'], $data,
$text_body, $html_body, $addresses, $series, $skip_list);
+ $ical_components[] = create_ical_event($attachment['method'], $data,
$text_body, $html_body, $addresses, $series);
$attachment['content'] = create_icalendar($attachment['method'],
$ical_components);
$attachment['name'] = $mail_settings['ics_filename'] . ".ics";
}
Modified: mrbs/trunk/web/mrbs_sql.inc
===================================================================
--- mrbs/trunk/web/mrbs_sql.inc 2011-08-29 18:22:01 UTC (rev 1906)
+++ mrbs/trunk/web/mrbs_sql.inc 2011-08-30 09:07:08 UTC (rev 1907)
@@ -623,8 +623,6 @@
* Creates a repeat entry in the data base + all the repeating entrys
*
* $data - An array containing the entry details
- * $skip_list - A 2D array of bookings to skip past, indexed by
- * room_id and start_time
*
* Returns:
* an array
@@ -634,12 +632,17 @@
* FALSE if the id refers to the entry table
*
*/
-function mrbsCreateRepeatingEntrys($data, &$skip_list)
+function mrbsCreateRepeatingEntrys($data)
{
global $max_rep_entrys;
$result = array('id' => 0, 'series' => FALSE);
-
+
+ if (!isset($data['skip_list']))
+ {
+ $data['skip_list'] = array();
+ }
+
$reps = mrbsGetRepeatEntryList($data['start_time'], $data['end_date'],
$data['rep_type'], $data['rep_opt'],
$max_rep_entrys, $data['rep_num_weeks']);
@@ -666,7 +669,7 @@
// This is a repeat booking. If we've got to skip past all
// the entries, then don't make a booking!
- if (count($reps) == count($skip_list[$data['room_id']]))
+ if (count($reps) == count($data['skip_list']))
{
$result['id'] = 0;
return $result;;
@@ -678,8 +681,15 @@
// maybe slightly strange result that the start date of the series won't
// have an entry on that date. But then this is no different from
// the way MRBS works at present if you create a series and then
- // delete the first entry. (But maybe that's not the way we want it
- // to behave??)
+ // delete the first entry.
+ //
+ // Note also that RFC 5545 allows this behaviour in 3.8.5.1:
+ // 'The "EXDATE" property can be used to exclude the value specified
+ // in "DTSTART". However, in such cases, the original "DTSTART" date
+ // MUST still be maintained by the calendaring and scheduling system
+ // because the original "DTSTART" value has inherent usage
+ // dependencies by other properties such as the "RECURRENCE-ID".'
+
$id = mrbsCreateRepeatEntry($data);
if ($id)
@@ -692,7 +702,7 @@
{
// Provided this isn't one of the entries to skip, go ahead
// and make the booking
- if (!in_array($reps[$i], $skip_list[$data['room_id']]))
+ if (!in_array($reps[$i], $data['skip_list']))
{
// calculate diff each time and correct where events
// cross DST
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits