diff --git a/calendar/inc/class.boical.inc.php b/calendar/inc/class.boical.inc.php
index 05033af41f..d56eb89d41 100644
--- a/calendar/inc/class.boical.inc.php
+++ b/calendar/inc/class.boical.inc.php
@@ -464,27 +464,53 @@
}
break;
- case 'D': // 1.0
- if(!preg_match('/D(\d+) (.*)/',$recurence, $recurenceMatches)) break;
- $vcardData['recur_interval'] = $recurenceMatches[1];
- if($recurenceMatches[2] != '#0')
- $vcardData['recur_enddate'] = $vcal->_parseDateTime($recurenceMatches[2]);
+ case 'D': // 1.0
+ if(preg_match('/D(\d+) #(.\d)/', $recurence, $recurenceMatches)) {
+ $vcardData['recur_interval'] = $recurenceMatches[1];
+ if($recurenceMatches[2] > 0 && $vcardData['end']) {
+ $vcardData['recur_enddate'] = mktime(
+ date('H', $vcardData['end']),
+ date('i', $vcardData['end']),
+ date('s', $vcardData['end']),
+ date('m', $vcardData['end']),
+ date('d', $vcardData['end']) + ($recurenceMatches[2] * $vcardData['recur_interval']),
+ date('Y', $vcardData['end']),
+ );
+ }
+ } elseif(preg_match('/D(\d+) (.*)/', $recurence, $recurenceMatches)) {
+ $vcardData['recur_interval'] = $recurenceMatches[1];
+ if($recurenceMatches[2] != '#0') {
+ $vcardData['recur_enddate'] = $vcal->_parseDateTime($recurenceMatches[2]);
+ }
+ } else {
+ break;
+ }
// fall-through
case 'DAILY': // 2.0
$vcardData['recur_type'] = MCAL_RECUR_DAILY;
break;
case 'M':
- if(preg_match('/MD(\d+) (.*)/',$recurence, $recurenceMatches))
- {
+ if(preg_match('/MD(\d+) #(.\d)/', $recurence, $recurenceMatches)) {
+ $vcardData['recur_type'] = MCAL_RECUR_MONTHLY_MDAY;
+ $vcardData['recur_interval'] = $recurenceMatches[1];
+ if($recurenceMatches[2] > 0 && $vcardData['end']) {
+ $vcardData['recur_enddate'] = mktime(
+ date('H', $vcardData['end']),
+ date('i', $vcardData['end']),
+ date('s', $vcardData['end']),
+ date('m', $vcardData['end']) + ($recurenceMatches[2] * $vcardData['recur_interval']),
+ date('d', $vcardData['end']),
+ date('Y', $vcardData['end']),
+ );
+ }
+ } elseif(preg_match('/MD(\d+) (.*)/',$recurence, $recurenceMatches)) {
$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_MDAY;
if($recurenceMatches[1] > 1)
$vcardData['recur_interval'] = $recurenceMatches[1];
if($recurenceMatches[2] != '#0')
$vcardData['recur_enddate'] = $vcal->_parseDateTime($recurenceMatches[2]);
- }
- elseif(preg_match('/MP(\d+) (.*) (.*) (.*)/',$recurence, $recurenceMatches))
- {
+ } elseif(preg_match('/MP(\d+) (.*) (.*) (.*)/',$recurence, $recurenceMatches)) {
$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_WDAY;
if($recurenceMatches[1] > 1)
$vcardData['recur_interval'] = $recurenceMatches[1];
@@ -498,10 +524,26 @@
break;
case 'Y': // 1.0
- if(!preg_match('/YM(\d+) (.*)/',$recurence, $recurenceMatches)) break;
- $vcardData['recur_interval'] = $recurenceMatches[1];
- if($recurenceMatches[2] != '#0')
- $vcardData['recur_enddate'] = $vcal->_parseDateTime($recurenceMatches[2]);
+ if(preg_match('/YM(\d+) #(.\d)/', $recurence, $recurenceMatches)) {
+ $vcardData['recur_interval'] = $recurenceMatches[1];
+ if($recurenceMatches[2] > 0 && $vcardData['end']) {
+ $vcardData['recur_enddate'] = mktime(
+ date('H', $vcardData['end']),
+ date('i', $vcardData['end']),
+ date('s', $vcardData['end']),
+ date('m', $vcardData['end']),
+ date('d', $vcardData['end']),
+ date('Y', $vcardData['end']) + ($recurenceMatches[2] * $vcardData['recur_interval']),
+ );
+ }
+ } elseif(preg_match('/YM(\d+) (.*)/',$recurence, $recurenceMatches)) {
+ $vcardData['recur_interval'] = $recurenceMatches[1];
+ if($recurenceMatches[2] != '#0') {
+ $vcardData['recur_enddate'] = $vcal->_parseDateTime($recurenceMatches[2]);
+ }
+ } else {
+ break;
+ }
// fall-through
case 'YEARLY': // 2.0
$vcardData['recur_type'] = MCAL_RECUR_YEARLY;
@@ -1033,29 +1075,23 @@
if(!$event = $this->icaltoegw($_vcalData)) {
return false;
}
-
- $search['start'] = $event['start'];
- $search['end'] = $event['end'];
-
- unset($event['description']);
- unset($event['start']);
- unset($event['end']);
-
- foreach($event as $key => $value) {
- if (substr($key,0,6) != 'recur_' && substr($key,0,5) != 'alarm') {
- $search['query']['cal_'.$key] = $value;
- } else {
- #$search['query'][$key] = $value;
- }
+ $query = array(
+ 'cal_start='.$this->date2ts($event['start'],true), // true = Server-time
+ 'cal_end='.$this->date2ts($event['end'],true),
+ );
+ foreach(array('title','location','priority','public','non_blocking') as $name) {
+ if (isset($event[$name])) $query['cal_'.$name] = $event[$name];
}
- if($foundEvents = parent::search($search)) {
+ if($foundEvents = parent::search(array(
+ 'user' => $this->user,
+ 'query' => $query,
+ ))) {
if(is_array($foundEvents)) {
$event = array_shift($foundEvents);
return $event['id'];
}
}
-
return false;
}
diff --git a/calendar/inc/class.sifcalendar.inc.php b/calendar/inc/class.sifcalendar.inc.php
index 6bf084f15b..51367dbbb2 100644
--- a/calendar/inc/class.sifcalendar.inc.php
+++ b/calendar/inc/class.sifcalendar.inc.php
@@ -449,7 +449,7 @@
case 'Start':
if($event['end'] - $event['start'] == 86399 && date('Y-m-d', $event['end']) == date('Y-m-d', $event['start'])) {
- $value = date('Y-m-d');
+ $value = date('Y-m-d', $event['start']);
$sifEvent .= "$value";
$sifEvent .= "$value";
$sifEvent .= "1";