steffen: server/kolab-resource-handlers/kolab-resource-handlers/freebusy freebusy.class.php, 1.23, 1.24 freebusycollector.class.php, 1.5, 1.6 recurrence.class.php, 1.5, 1.6

cvs at intevation.de cvs at intevation.de
Wed Jan 12 03:51:06 CET 2005


Author: steffen

Update of /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy
In directory doto:/tmp/cvs-serv15388/kolab-resource-handlers/freebusy

Modified Files:
	freebusy.class.php freebusycollector.class.php 
	recurrence.class.php 
Log Message:
Fix for issue496 (dummy busyperiod) and issue243 (recurrence problem)

Index: freebusy.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusy.class.php,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- freebusy.class.php	7 Jan 2005 22:24:16 -0000	1.23
+++ freebusy.class.php	12 Jan 2005 02:51:04 -0000	1.24
@@ -128,7 +128,12 @@
       $vFb->setAttribute('DTSTART', 0, array(), false );
       $vFb->setAttribute('DTEND', 0, array(), false );
       $vFb->setAttribute('COMMENT', 'This is a dummy vfreebusy that indicates an empty calendar');
-      $vFb->addBusyPeriod( 'BUSY', 0,0, null );
+      /* It seems to be a bad idea to put bogus values in pfbs
+       * so we accept that they are not completely in line 
+       * with the rfc and take care of the problem when merging 
+       * pfbs to ifbs later 
+       */
+      //$vFb->addBusyPeriod( 'BUSY', 0,0, null );
       $vCal->addComponent($vFb);
       return array($vCal->exportvCalendar(),$vCal->exportvCalendar());
     }

Index: freebusycollector.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusycollector.class.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- freebusycollector.class.php	16 Dec 2004 20:54:46 -0000	1.5
+++ freebusycollector.class.php	12 Jan 2005 02:51:04 -0000	1.6
@@ -90,6 +90,16 @@
 
   function exportvCalendar() {
     //$vFb->setAttribute('URL', 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
+    $vFb = &$this->vCal->findComponent( 'vfreebusy' );
+    if( !(boolean)$vFb->getBusyPeriods() ) {
+      /* No busy periods in fb list. We have to add a
+       * dummy one to be standards compliant
+       */
+      $vFb->setAttribute('DTSTART', 0, array(), false );
+      $vFb->setAttribute('DTEND', 0, array(), false );
+      $vFb->setAttribute('COMMENT', 'This is a dummy vfreebusy that indicates an empty calendar');
+      $vFb->addBusyPeriod( 'BUSY', 0,0, null );
+    }
     return $this->vCal->exportvCalendar();
   }
 

Index: recurrence.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/recurrence.class.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- recurrence.class.php	16 Dec 2004 20:54:46 -0000	1.5
+++ recurrence.class.php	12 Jan 2005 02:51:04 -0000	1.6
@@ -47,7 +47,7 @@
   
   function expand( $startstamp, $endstamp ) {
     $duration = $this->initial_end-$this->initial_start;
-    myLog( "Recurrence::expand( $startstamp, $endstamp )", RM_LOG_DEBUG );	
+    //myLog( "Recurrence::expand( $startstamp, $endstamp )", RM_LOG_DEBUG );	
     //myLog( "cycletype=".$this->cycle_type, RM_LOG_DEBUG);
     switch( $this->cycle_type ) {
     case 'daily':
@@ -89,12 +89,14 @@
 	  // Weekly recurrence, every 'interval' weeks
 	  if( !$this->interval ) $this->interval = 1;
 	  $count = 0;
-	  for( $t = $this->initial_start; $t < $endstamp; $t = strtotime( "+$interval months", $t) ) {
+	  $delta_days = getdate($this->initial_start);
+	  $delta_days = $delta_days['mday'];
+	  for( $t = strtotime( "-$delta_days", $this->initial_start ); $t < $endstamp; $t = strtotime( "+$interval months", $t) ) {
 	    if( $this->type == 'daynumber') {
 	      // On numbered days
 	      foreach( $this->daynumber as $dayno ) {
 		$tmp = strtotime( "+$dayno days", $t);		
-		if( $tmp < $endstamp ) {
+		if( $tmp >= $this->initial_start && $tmp < $endstamp ) {
 		  //myLog("Adding recurrence $tmp -> ".($tmp+$duration), RM_LOG_DEBUG );
 		  $this->setBusy( $tmp, null, $duration );
 		} else {
@@ -108,10 +110,10 @@
 		$dayno = $this->daynumber[$i];
 		$wday  = $this->day[$i];
 		$tmp = strtotime( "+$dayno $wday", $t);
-		if( $tmp < $endstamp ) {
+		if( $tmp >= $this->initial_start && $tmp < $endstamp ) {
 		  //myLog("Adding recurrence $tmp -> ".($tmp+$duration), RM_LOG_DEBUG );
 		  $this->setBusy( $tmp, null, $duration );
-		} else {
+		} else if($tmp >= $endstamp ) {
 		  break;
 		}
 	      }
@@ -126,14 +128,16 @@
     case 'yearly':
 	  if( !$this->interval ) $interval = 1;
 	  $count = 0;
-	  for( $t = $this->initial_start; $t < $endstamp; $t = strtotime( "+$interval years", $t) ) {
+	  $delta_days = getdate($this->initial_start);
+	  $delta_days = $delta_days['yday'];
+	  for( $t = strtotime( "-$delta_days", $this->initial_start ); $t < $endstamp; $t = strtotime( "+$interval years", $t) ) {
 	    if( $this->type == 'yearday') {
 	      foreach( $this->daynumber as $dayno ) {
-		$tmp = strtotime( "+$dayno days", $t);
-		if( $tmp < $endstamp ) {
+		$tmp = strtotime( '+'.($dayno-1).' days', $t);
+		if( $this->initial_start <= $tmp && $tmp < $endstamp ) {
 		  //myLog("Adding recurrence $tmp -> ".($tmp+$duration), RM_LOG_DEBUG );
 		  $this->setBusy( $tmp, null, $duration );
-		} else {
+		} else if($tmp >= $endstamp ) {
 		  break;
 		}
 	      }





More information about the commits mailing list