steffen: server/kolab-resource-handlers/kolab-resource-handlers/freebusy freebusy.class.php, 1.6, 1.7 freebusycollector.class.php, 1.2, 1.3
cvs at intevation.de
cvs at intevation.de
Wed Oct 20 03:14:51 CEST 2004
Author: steffen
Update of /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy
In directory doto:/tmp/cvs-serv10774/kolab-resource-handlers/freebusy
Modified Files:
freebusy.class.php freebusycollector.class.php
Log Message:
fix for issue465 (DTSTART and END problems)
Index: freebusy.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusy.class.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- freebusy.class.php 18 Oct 2004 23:53:07 -0000 1.6
+++ freebusy.class.php 20 Oct 2004 01:14:48 -0000 1.7
@@ -131,18 +131,60 @@
// We have a recurring event
$rec = $event['recurrence'];
$duration = $initial_end-$initial_start;
- myLog( "Recurring event ".$summary." recurring cycle ".$rec['cycle'], RM_LOG_DEBUG );
+ $rangetype = $rec['rangetype'];
+ if( $rangetype == 'number' ) {
+ $range = (int)$rec['range'];
+ } else if( $rangetype == 'date' ) {
+ $range = $this->parseDateTime( $rec['range'] );
+ }
+ myLog( "Recurring event ".$summary." recurring cycle ".$rec['cycle'], RM_LOG_DEBUG );
switch( $rec['cycle'] ) {
case 'daily':
// Daily recurrence, every 'interval' days
+ $count = 0;
for( $t = $initial_start; $t < $endstamp; $t += 24*60*60*(int)$rec['interval'] ) {
myLog("Adding recurrence $t -> ".($t+$duration), RM_LOG_DEBUG );
$vFb->addBusyPeriod('BUSY', $t, null, $duration, $extra);
+ $count++;
+ if( $rangetype == 'number' && $count > $range ) {
+ break;
+ } else if( $rangetype == 'date' && $t > $range+24*60*60) {
+ break;
+ }
}
break;
case 'weekly':
// Weekly recurrence, every 'interval' weeks on 'day' days
- // TODO
+ $wstart = $this->weekStart( $initial_start );
+ $interval = (int)$rec['interval'];
+ if( !$interval ) $interval = 1;
+ $count = 0;
+ for( $t = $wstart; $t < $endstamp; $t += 7*24*60*60*$interval ) {
+ if( $this->week_starts_on_sunday ) {
+ $days = array( 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3,
+ 'thursday' => 4, 'friday' => 5, 'saturday' => 6,
+ 'sunday' => 0 );
+ } else {
+ $days = array( 'monday' => 0, 'tuesday' => 1, 'wednesday' => 2,
+ 'thursday' => 3, 'friday' => 4, 'saturday' => 5,
+ 'sunday' => 6 );
+ }
+ foreach( $rec['day'] as $day ) {
+ $tmp = $t+24*60*60*$days[$day] + $this->getTimePart( $t );
+ if( $tmp < $endstamp ) {
+ myLog("Adding recurrence $tmp -> ".($tmp+$duration), RM_LOG_DEBUG );
+ $vFb->addBusyPeriod('BUSY', $tmp, null, $duration, $extra);
+ } else {
+ break;
+ }
+ }
+ $count++;
+ if( $rangetype == 'number' && $count > $range ) {
+ break;
+ } else if( $rangetype == 'date' && $t > $range+24*60*60) {
+ break;
+ }
+ }
case 'monthly':
// TODO
case 'yearly':
@@ -241,6 +283,27 @@
$date['month'], $date['mday'], $date['year']);
}
+ /* Returns 00:00 on the first day of the current week
+ * in local time */
+ function weekStart( $ts ) {
+ $a = getdate($ts);
+ if( $this->week_starts_on_sunday ) {
+ $d = $a['wday'];
+ } else {
+ $d = $a['wday']-1;
+ if( $d < 0 ) $d = 6;
+ }
+ $ts = $ts - 24*60*60*$d;
+ $a = getdate($ts);
+ return mktime( 0,0,0,$a['mon'], $a['mday'], $a['year']);
+ }
+
+ /* Return the time of day of a timestamp as seconds since midnight */
+ function getTimePart( $ts ) {
+ $a = getdate($ts);
+ return mktime( $a['hour'], $a['minutes'], $a['seconds'],0,0,0,0 );
+ }
+
function getEventHash($xml_text) {
$xmldoc = @domxml_open_mem($xml_text, DOMXML_LOAD_PARSING +
DOMXML_LOAD_COMPLETE_ATTRS + DOMXML_LOAD_SUBSTITUTE_ENTITIES +
@@ -267,9 +330,13 @@
$rhash[$attr->name] = $attr->value;
}
foreach( $value->child_nodes() as $v ) {
- $rhash[$v->tagname] = $v->get_content();
- if( $v->tagname == 'range' && $v->has_attribute('type') ) {
- $rhash['rangetype'] = $v->get_attribute('type');
+ if( $v->tagname == 'day' || $v->tagname == 'exclusion' ) {
+ $rhash[$v->tagname][] = $v->get_content();
+ } else {
+ $rhash[$v->tagname] = $v->get_content();
+ if( $v->tagname == 'range' && $v->has_attribute('type') ) {
+ $rhash['rangetype'] = $v->get_attribute('type');
+ }
}
}
$event_hash[$value->tagname] = $rhash;
@@ -321,6 +388,7 @@
// Settings
var $freebusy_days = 60;
var $default_domain = 'foo';
+ var $week_starts_on_sunday = false;
var $imap;
};
Index: freebusycollector.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusycollector.class.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- freebusycollector.class.php 16 Oct 2004 10:05:16 -0000 1.2
+++ freebusycollector.class.php 20 Oct 2004 01:14:48 -0000 1.3
@@ -41,20 +41,23 @@
trigger_error("Could not find freebusy info in ical", E_USER_ERROR);
return false;
}
- if( ($sts = $this->vCal->getAttributeDefault('DTSTART', false)) === false ) {
- $this->vCal->setAttribute('DTSTART', $vCal->getAttribute('DTSTART'), array(), false );
+
+ if( ($sts = $vFb1->getAttributeDefault('DTSTART', false)) === false ) {
+ $vFb1->setAttribute('DTSTART', $vFb2->getAttribute('DTSTART'), array(), false );
} else {
- $this->vCal->setAttribute('DTSTART', min( $sts, $vCal->getAttribute('DTSTART') ), array(), false );
+ $vFb1->setAttribute('DTSTART', min( $sts, $vFb2->getAttribute('DTSTART') ), array(), false );
}
- if( ($ets = $this->vCal->getAttributeDefault('DTEND', false)) === false ) {
- $this->vCal->setAttribute('DTEND', $vCal->getAttribute('DTEND'), array(), false );
+ if( ($ets = $vFb1->getAttributeDefault('DTEND', false)) === false ) {
+ $vFb1->setAttribute('DTEND', $vFb2->getAttribute('DTEND'), array(), false );
} else {
- $this->vCal->setAttribute('DTEND', max( $ets, $vCal->getAttribute('DTEND')), array(), false );
+ $vFb1->setAttribute('DTEND', max( $ets, $vFb2->getAttribute('DTEND')), array(), false );
}
+
return $vFb1->merge( $vFb2 );
}
function exportvCalendar() {
+ //$vFb->setAttribute('URL', 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
return $this->vCal->exportvCalendar();
}
More information about the commits
mailing list