Revision: 2490
https://sourceforge.net/p/mrbs/code/2490/
Author: cimorrison
Date: 2012-10-12 14:05:06 +0000 (Fri, 12 Oct 2012)
Log Message:
-----------
Made the start time correspond to the start time of the first entry for a series
Modified Paths:
--------------
mrbs/branches/improved_repeat_interface/web/edit_entry_handler.php
mrbs/branches/improved_repeat_interface/web/mrbs_sql.inc
Modified: mrbs/branches/improved_repeat_interface/web/edit_entry_handler.php
===================================================================
--- mrbs/branches/improved_repeat_interface/web/edit_entry_handler.php
2012-10-12 12:26:01 UTC (rev 2489)
+++ mrbs/branches/improved_repeat_interface/web/edit_entry_handler.php
2012-10-12 14:05:06 UTC (rev 2490)
@@ -500,41 +500,53 @@
$rep_opt = "";
-// Processing for weekly repeats
-if (isset($rep_type) && ($rep_type == REP_WEEKLY))
+
+// Get the repeat details
+if (isset($rep_type) && ($rep_type != REP_NONE))
{
- // If no repeat day has been set, then set a default repeat day
- // as the day of the week of the start of the period
- if (count($rep_day) == 0)
+ if ($rep_type == REP_WEEKLY)
{
- $rep_day[] = date('w', $starttime);
+ // If no repeat day has been set, then set a default repeat day
+ // as the day of the week of the start of the period
+ if (count($rep_day) == 0)
+ {
+ $rep_day[] = date('w', $starttime);
+ }
+ // Build string of weekdays to repeat on:
+ for ($i = 0; $i < 7; $i++)
+ {
+ $rep_opt .= in_array($i, $rep_day) ? "1" : "0"; // $rep_opt is a string
+ }
}
- // Build string of weekdays to repeat on:
- for ($i = 0; $i < 7; $i++)
- {
- $rep_opt .= in_array($i, $rep_day) ? "1" : "0"; // $rep_opt is a string
- }
-
- // Make sure that the starttime and endtime coincide with a repeat day. In
- // other words make sure that the first starttime and endtime define an
actual
+ // Make sure that the starttime coincides with a repeat day. In
+ // other words make sure that the first starttime defines an actual
// entry. We need to do this because if we are going to construct an
iCalendar
- // object, RFC 5545 demands that the start and end time are the first events
of
+ // object, RFC 5545 demands that the start time is the first event of
// a series. ["The "DTSTART" property for a "VEVENT" specifies the inclusive
// start of the event. For recurring events, it also specifies the very
first
// instance in the recurrence set."]
- while (!$rep_opt[date('w', $starttime)])
+
+ $rep_details = array('rep_type' => $rep_type,
+ 'rep_opt' => $rep_opt,
+ 'rep_num_weeks' => $rep_num_weeks);
+ if (isset($month_absolute))
{
- $start = getdate($starttime);
- $end = getdate($endtime);
- $starttime = mktime($start['hours'], $start['minutes'], $start['seconds'],
- $start['mon'], $start['mday'] + 1, $start['year']);
- $endtime = mktime($end['hours'], $end['minutes'], $end['seconds'],
- $end['mon'], $end['mday'] + 1, $end['year']);
+ $rep_details['month_absolute'] = $month_absolute;
}
+
+ // Get the first entry in the series and make that the start time
+ $reps = mrbsGetRepeatEntryList($starttime, $end_date, $rep_details, 1);
+
+ if (count($reps) > 0)
+ {
+ $duration = $endtime - $starttime;
+ $duration -= cross_dst($starttime, $endtime);
+ $starttime = $reps[0];
+ $endtime = $starttime + $duration;
+ }
}
-
// Assemble an array of bookings, one for each room
$bookings = array();
foreach ($rooms as $room_id)
Modified: mrbs/branches/improved_repeat_interface/web/mrbs_sql.inc
===================================================================
--- mrbs/branches/improved_repeat_interface/web/mrbs_sql.inc 2012-10-12
12:26:01 UTC (rev 2489)
+++ mrbs/branches/improved_repeat_interface/web/mrbs_sql.inc 2012-10-12
14:05:06 UTC (rev 2490)
@@ -679,6 +679,7 @@
return $days_jump;
}
+
/** mrbsGetRepeatEntryList
*
* Returns a list of the repeating entrys
@@ -733,6 +734,7 @@
for ($i = 0; $i < $max_ittr; $i++)
{
$time = mktime($hour, $min, $sec, $month, $day, $year);
+
if ($time > $enddate)
{
break;
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits