steffen: server/kolab-resource-handlers/kolab-resource-handlers/freebusy freebusy.class.php, 1.25, 1.26 recurrence.class.php, 1.11, 1.12
cvs at intevation.de
cvs at intevation.de
Wed Jan 26 08:32:33 CET 2005
Author: steffen
Update of /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy
In directory doto:/tmp/cvs-serv20404/kolab-resource-handlers/freebusy
Modified Files:
freebusy.class.php recurrence.class.php
Log Message:
recurrence exclusions (Issue243)
Index: freebusy.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusy.class.php,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- freebusy.class.php 16 Jan 2005 08:17:49 -0000 1.25
+++ freebusy.class.php 26 Jan 2005 07:32:31 -0000 1.26
@@ -207,6 +207,7 @@
if( isset($rec['daynumber']) ) $recurrence->setDaynumber( $rec['daynumber'] );
if( isset($rec['day']) ) $recurrence->setDay( $rec['day'] );
if( isset($rec['month']) ) $recurrence->setMonth( $rec['month'] );
+ if( isset($rec['exclusion'] ) ) $recurrence->setExclusionDates( $rec['exclusion'] );
$rangetype = $rec['rangetype'];
if( $rangetype == 'number' ) {
$range = (int)$rec['range'];
@@ -271,7 +272,7 @@
return $fldr;
}
- // Date/Time value parsing, curtesy of the Horde iCalendar library
+ // Date/Time value parsing, courtesy of the Horde iCalendar library
function parseTime($text) {
// There must be a trailing 'Z' on a time
if (strlen($text) != 9) {
Index: recurrence.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/recurrence.class.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- recurrence.class.php 21 Jan 2005 03:00:59 -0000 1.11
+++ recurrence.class.php 26 Jan 2005 07:32:31 -0000 1.12
@@ -41,6 +41,15 @@
function setDaynumber( $num ) { $this->daynumber = is_array($num)?$num:array($num); }
function setDay( $day ) { $this->day = $day; }
function setMonth( $month ) { $this->month = is_array($month)?$month:array($month); }
+ function setExclusionDates( $ex ) {
+ // Prescale dates for easy comparison
+ $this->exclusion_dates = array();
+ foreach( $ex as $e ) {
+ $e = explode('-',$e);
+ $e = intval(sprintf('%04d%02d%02d', $e[0],$e[1],$e[2]));
+ $this->exclusion_dates[] = $e;
+ }
+ }
function setRangetype( $type ) { $this->range_type = $type; }
function setRange( $range ) { $this->range = $range; }
@@ -80,7 +89,7 @@
if( !$this->interval ) $this->interval = 1;
for( $t = $this->initial_start; $t < $endstamp; $t = strtotime( '+'.$this->interval.' days',$t) ) {
//myLog("Adding recurrence $t -> ".($t+$duration), RM_LOG_DEBUG );
- $this->setBusy( $t, null, $duration );
+ if( !$this->isExcluded( $t, $t+$duration) ) $this->setBusy( $t, null, $duration );
$count++;
if( $this->range_type == 'number' && $count > $this->range ) {
break;
@@ -98,10 +107,11 @@
$delta_days = (int)gmdate('w',$this->initial_start);
for( $t = strtotime("-$delta_days days", $this->initial_start); $t < $endstamp;
$t = strtotime( '+'.$this->interval.' weeks', $t) ) {
- myLog("t=".gmdate("D, M d Y H:i:s",$t), RM_LOG_DEBUG);
+ //myLog("t=".gmdate("D, M d Y H:i:s",$t), RM_LOG_DEBUG);
foreach( $this->day as $day ) {
$tmp = strtotime( '+'.$this->dayname2number($day).' days', $t);
- if( $tmp >= $this->initial_start && $tmp < $endstamp ) {
+ if( $tmp >= $this->initial_start && $tmp < $endstamp &&
+ !$this->isExcluded( $tmp, $tmp+$duration) ) {
myLog("Adding recurrence ".gmdate("D, M d Y H:i:s",$tmp)." -> "
.gmdate("D, M d Y H:i:s",$tmp+$duration), RM_LOG_DEBUG );
$this->setBusy( $tmp, null, $duration );
@@ -117,6 +127,7 @@
}
}
}
+
function expand_monthly( $startstamp, $endstamp ) {
// Weekly recurrence, every 'interval' weeks
$duration = $this->initial_end-$this->initial_start;
@@ -130,7 +141,8 @@
// On numbered days
foreach( $this->daynumber as $dayno ) {
$tmp = strtotime( '+'.($dayno-16).' days', $t);
- if( $tmp >= $this->initial_start && $tmp < $endstamp ) {
+ if( $tmp >= $this->initial_start && $tmp < $endstamp &&
+ !$this->isExcluded( $tmp, $tmp+$duration) ) {
myLog("Adding recurrence ".gmdate("D, M d Y H:i:s",$tmp)." -> "
.gmdate("D, M d Y H:i:s",$tmp+$duration), RM_LOG_DEBUG );
$this->setBusy( $tmp, null, $duration );
@@ -152,7 +164,8 @@
if( $wday < $firstday ) $tmp2 = strtotime( '+'.($dayno*7+$wday-$firstday).' days', $tmp);
else $tmp2 = strtotime( '+'.(($dayno-1)*7+$wday-$firstday).' days', $tmp);
$tmp2_month = gmdate('m',$tmp2); // make sure same month
- if( $tmp_month == $tmp2_month && $tmp2 >= $this->initial_start && $tmp2 < $endstamp ) {
+ if( $tmp_month == $tmp2_month && $tmp2 >= $this->initial_start && $tmp2 < $endstamp
+ && !$this->isExcluded( $tmp2, $tmp2+$duration) ) {
myLog("Adding recurrence ".gmdate("D, M d Y H:i:s",$tmp2)." -> "
.gmdate("D, M d Y H:i:s",$tmp2+$duration), RM_LOG_DEBUG );
$this->setBusy( $tmp2, null, $duration );
@@ -182,7 +195,8 @@
if( $this->type == 'yearday') {
foreach( $this->daynumber as $dayno ) {
$tmp = strtotime( '+'.($dayno-1).' days', $t);
- if( $this->initial_start <= $tmp && $tmp < $endstamp ) {
+ if( $this->initial_start <= $tmp && $tmp < $endstamp
+ && !$this->isExcluded( $tmp, $tmp+$duration) ) {
myLog("Adding recurrence ".gmdate("D, M d Y H:i:s",$tmp)." -> "
.gmdate("D, M d Y H:i:s",$tmp+$duration), RM_LOG_DEBUG );
$this->setBusy( $tmp, null, $duration );
@@ -200,7 +214,8 @@
//myLog("setting tmp to $year-$month-$dayno $time+0000", RM_LOG_DEBUG );
$tmp = strtotime( "$year-$month-$dayno $time+0000");
//myLog("tmp= ".gmdate("M d Y H:i:s",$tmp), RM_LOG_DEBUG );
- if( $this->initial_start <= $tmp && $tmp < $endstamp ) {
+ if( $this->initial_start <= $tmp && $tmp < $endstamp
+ && !$this->isExcluded( $tmp, $tmp+$duration) ) {
myLog("Adding recurrence ".gmdate("D, M d Y H:i:s",$tmp)." -> "
.gmdate("D, M d Y H:i:s",$tmp+$duration), RM_LOG_DEBUG );
$this->setBusy( $tmp, null, $duration );
@@ -218,7 +233,8 @@
$time = gmdate('H:i:s',$t);
$tmp = strtotime( "$dayno $wday", strtotime( "1 $month $year") );
$tmp = strtotime( gmdate('Y-m-d',$tmp)." $time+0000");
- if( $this->initial_start <= $tmp && $tmp < $endstamp ) {
+ if( $this->initial_start <= $tmp && $tmp < $endstamp
+ && !$this->isExcluded( $tmp, $tmp+$duration) ) {
myLog("Adding recurrence ".gmdate("D, M d Y H:i:s",$tmp)." -> "
.gmdate("D, M d Y H:i:s",$tmp+$duration), RM_LOG_DEBUG );
$this->setBusy( $tmp, null, $duration );
@@ -269,6 +285,22 @@
myLog("Recurrence::monthname2number($month): Invalid month", RM_LOG_ERROR);
return -1;
}
+ }
+
+ function isExcluded( $start, $end ) {
+ $start = explode(' ', gmdate('Y m d', $start));
+ $start = intval($start[0].$start[1].$start[2]);
+
+ $end = explode(' ', gmdate('Y m d', $end));
+ $end = intval($end[0].$end[1].$end[2]);
+
+ foreach( $this->exclusion_dates as $e ) {
+ if( $start <= $e && $end >= $e ) {
+ myLog("$start-$end excluded!", RM_LOG_DEBUG);
+ return true;
+ }
+ }
+ return false;
}
var $initial_start = NULL; // timestamp
More information about the commits
mailing list