mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-13 17:38:19 +01:00
- fixed php4 problem reported by omgs on the list
- fixed import probs with attendee and recuring events
This commit is contained in:
parent
50548b05f5
commit
3be64eb200
@ -278,8 +278,11 @@
|
|||||||
return $vcal->exportvCalendar();
|
return $vcal->exportvCalendar();
|
||||||
}
|
}
|
||||||
|
|
||||||
function importVCal(&$_vcalData, $cal_id=-1)
|
function importVCal($_vcalData, $cal_id=-1)
|
||||||
{
|
{
|
||||||
|
// our (patched) horde classes, do NOT unfold folded lines, which causes a lot trouble in the import
|
||||||
|
$_vcalData = preg_replace("/[\r\n]+ /",'',$_vcalData);
|
||||||
|
|
||||||
$vcal = &new Horde_iCalendar;
|
$vcal = &new Horde_iCalendar;
|
||||||
if(!$vcal->parsevCalendar($_vcalData))
|
if(!$vcal->parsevCalendar($_vcalData))
|
||||||
{
|
{
|
||||||
@ -298,7 +301,7 @@
|
|||||||
if(is_a($component, 'Horde_iCalendar_vevent'))
|
if(is_a($component, 'Horde_iCalendar_vevent'))
|
||||||
{
|
{
|
||||||
$supportedFields = $this->supportedFields;
|
$supportedFields = $this->supportedFields;
|
||||||
$event = array();
|
$event = array('participants' => array());
|
||||||
$vcardData = array('recur_type' => 0);
|
$vcardData = array('recur_type' => 0);
|
||||||
|
|
||||||
// lets see what we can get from the vcard
|
// lets see what we can get from the vcard
|
||||||
@ -327,53 +330,54 @@
|
|||||||
$vcardData['location'] = $attributes['value'];
|
$vcardData['location'] = $attributes['value'];
|
||||||
break;
|
break;
|
||||||
case 'RRULE':
|
case 'RRULE':
|
||||||
$recurence = $attributes['value'];
|
$recurence = $attributes['value'];
|
||||||
switch(substr($recurence,0,1))
|
$type = preg_match('/FREQ=([^;: ]+)/i',$recurence,$matches) ? $matches[1] : $recurence{0};
|
||||||
|
// vCard 2.0 values for all types
|
||||||
|
if (preg_match('/UNTIL=([0-9T]+)/',$recurence,$matches))
|
||||||
|
{
|
||||||
|
$vcardData['recur_enddate'] = $vcal->_parseDateTime($matches[1]);
|
||||||
|
}
|
||||||
|
if (preg_match('/INTERVAL=([0-9]+)/',$recurence,$matches))
|
||||||
|
{
|
||||||
|
$vcardData['recur_interval'] = (int) $matches[1];
|
||||||
|
}
|
||||||
|
$vcardData['recur_data'] = 0;
|
||||||
|
switch($type)
|
||||||
{
|
{
|
||||||
case 'W':
|
case 'W':
|
||||||
if(preg_match('/W(\d+) (.*) (.*)/',$recurence, $recurenceMatches))
|
case 'WEEKLY':
|
||||||
|
$days = array();
|
||||||
|
if(preg_match('/W(\d+) (.*) (.*)/',$recurence, $recurenceMatches)) // 1.0
|
||||||
{
|
{
|
||||||
|
$vcardData['recur_interval'] = $recurenceMatches[1];
|
||||||
|
$days = explode(' ',trim($recurenceMatches[2]));
|
||||||
|
}
|
||||||
|
elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) // 2.0
|
||||||
|
{
|
||||||
|
$days = exploce(',',$recurenceMatches[1]);
|
||||||
|
}
|
||||||
|
if ($days)
|
||||||
|
{
|
||||||
|
foreach($this->recur_days as $id => $day)
|
||||||
|
{
|
||||||
|
if (in_array(strtoupper(substr($day,0,2)),$matches))
|
||||||
|
{
|
||||||
|
$vcardData['recur_data'] |= $id;
|
||||||
|
}
|
||||||
|
}
|
||||||
$vcardData['recur_type'] = MCAL_RECUR_WEEKLY;
|
$vcardData['recur_type'] = MCAL_RECUR_WEEKLY;
|
||||||
$vcardData['recur_interval'] = $recurenceMatches[1];
|
|
||||||
foreach(explode(' ',trim($recurenceMatches[2])) as $recurenceDay)
|
|
||||||
{
|
|
||||||
switch($recurenceDay)
|
|
||||||
{
|
|
||||||
case 'SU':
|
|
||||||
$vcardData['recur_data'][] = MCAL_M_SUNDAY;
|
|
||||||
break;
|
|
||||||
case 'MO':
|
|
||||||
$vcardData['recur_data'][] = MCAL_M_MONDAY;
|
|
||||||
break;
|
|
||||||
case 'TU':
|
|
||||||
$vcardData['recur_data'][] = MCAL_M_TUESDAY;
|
|
||||||
break;
|
|
||||||
case 'WE':
|
|
||||||
$vcardData['recur_data'][] = MCAL_M_WEDNESDAY;
|
|
||||||
break;
|
|
||||||
case 'TH':
|
|
||||||
$vcardData['recur_data'][] = MCAL_M_THURSDAY;
|
|
||||||
break;
|
|
||||||
case 'FR':
|
|
||||||
$vcardData['recur_data'][] = MCAL_M_FRIDAY;
|
|
||||||
break;
|
|
||||||
case 'SA':
|
|
||||||
$vcardData['recur_data'][] = MCAL_M_SATURDAY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'D':
|
case 'D': // 1.0
|
||||||
if(preg_match('/D(\d+) (.*)/',$recurence, $recurenceMatches))
|
if(!preg_match('/D(\d+) (.*)/',$recurence, $recurenceMatches)) break;
|
||||||
{
|
$vcardData['recur_interval'] = $recurenceMatches[1];
|
||||||
$vcardData['recur_type'] = MCAL_RECUR_DAILY;
|
$vcardData['recur_enddate'] = $vcal->_parseDateTime($recurenceMatches[2]);
|
||||||
$vcardData['recur_interval'] = $recurenceMatches[1];
|
// fall-through
|
||||||
$vcardData['recur_enddate'] = $vcal->_parseDateTime($recurenceMatches[2]);
|
case 'DAILY': // 2.0
|
||||||
|
$vcardData['recur_type'] = MCAL_RECUR_DAILY;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'M':
|
case 'M':
|
||||||
if(preg_match('/MD(\d+) (.*)/',$recurence, $recurenceMatches))
|
if(preg_match('/MD(\d+) (.*)/',$recurence, $recurenceMatches))
|
||||||
{
|
{
|
||||||
@ -385,14 +389,18 @@
|
|||||||
$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_WDAY;
|
$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_WDAY;
|
||||||
$vcardData['recur_interval'] = $recurenceMatches[1];
|
$vcardData['recur_interval'] = $recurenceMatches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'Y':
|
case 'MONTHLY':
|
||||||
if(preg_match('/YM(\d+) (.*)/',$recurence, $recurenceMatches))
|
$vcardData['recur_type'] = strstr($recurence,'BYDAY') ?
|
||||||
{
|
MCAL_RECUR_MONTHLY_WDAY : MCAL_RECUR_MONTHLY_MDAY;
|
||||||
$vcardData['recur_type'] = MCAL_RECUR_YEARLY;
|
break;
|
||||||
$vcardData['recur_interval'] = $recurenceMatches[1];
|
|
||||||
}
|
case 'Y': // 1.0
|
||||||
|
if(!preg_match('/YM(\d+) (.*)/',$recurence, $recurenceMatches)) break;
|
||||||
|
$vcardData['recur_interval'] = $recurenceMatches[1];
|
||||||
|
// fall-through
|
||||||
|
case 'YEARLY': // 2.0
|
||||||
|
$vcardData['recur_type'] = MCAL_RECUR_YEARLY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -432,7 +440,7 @@
|
|||||||
{
|
{
|
||||||
if (!($cat_id = $this->cat->name2id($cat_name)))
|
if (!($cat_id = $this->cat->name2id($cat_name)))
|
||||||
{
|
{
|
||||||
$cat_id = $this->cat->add( array('name' => $cat,'descr' => $cat ));
|
$cat_id = $this->cat->add( array('name' => $cat_name,'descr' => $cat_name ));
|
||||||
}
|
}
|
||||||
$vcardData['category'][] = $cat_id;
|
$vcardData['category'][] = $cat_id;
|
||||||
}
|
}
|
||||||
@ -440,15 +448,16 @@
|
|||||||
break;
|
break;
|
||||||
case 'ATTENDEE':
|
case 'ATTENDEE':
|
||||||
if (preg_match('/MAILTO:([@.a-z0-9_-]+)/i',$attributes['value'],$matches) &&
|
if (preg_match('/MAILTO:([@.a-z0-9_-]+)/i',$attributes['value'],$matches) &&
|
||||||
($uid = $GLOBALS['egw']->accounts->name2id($matches[1])))
|
($uid = $GLOBALS['egw']->accounts->name2id($matches[1],'account_email')))
|
||||||
{
|
{
|
||||||
$event['participants'][$uid] = preg_match('/PARTSTAT=([a-z-]+)/i',$attributes['value'],$matches) ?
|
$event['participants'][$uid] = isset($attributes['params']['PARTSTAT']) ?
|
||||||
$this->status_ical2egw[strtoupper($matches[1])] : ($uid == $event['owner'] ? 'A' : 'U');
|
$this->status_ical2egw[strtoupper($attributes['params']['PARTSTAT'])] :
|
||||||
|
($uid == $event['owner'] ? 'A' : 'U');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'ORGANIZER': // will be written direct to the event
|
case 'ORGANIZER': // will be written direct to the event
|
||||||
if (preg_match('/MAILTO:([@.a-z0-9_-]+)/i',$attributes['value'],$matches) &&
|
if (preg_match('/MAILTO:([@.a-z0-9_-]+)/i',$attributes['value'],$matches) &&
|
||||||
($uid = $GLOBALS['egw']->accounts->name2id($matches[1])))
|
($uid = $GLOBALS['egw']->accounts->name2id($matches[1],'account_email')))
|
||||||
{
|
{
|
||||||
$event['owner'] = $uid;
|
$event['owner'] = $uid;
|
||||||
}
|
}
|
||||||
@ -461,7 +470,7 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#_debug_array($vcardData);exit;
|
//echo "event=";_debug_array($vcardData);
|
||||||
|
|
||||||
// now that we know what the vard provides, we merge that data with the information we have about the device
|
// now that we know what the vard provides, we merge that data with the information we have about the device
|
||||||
$event['priority'] = 2;
|
$event['priority'] = 2;
|
||||||
@ -469,7 +478,7 @@
|
|||||||
{
|
{
|
||||||
$event['id'] = $cal_id;
|
$event['id'] = $cal_id;
|
||||||
}
|
}
|
||||||
while($fieldName = array_shift($supportedFields))
|
while(($fieldName = array_shift($supportedFields)))
|
||||||
{
|
{
|
||||||
switch($fieldName)
|
switch($fieldName)
|
||||||
{
|
{
|
||||||
@ -479,7 +488,7 @@
|
|||||||
{
|
{
|
||||||
foreach(array('recur_interval','recur_enddate','recur_data','recur_exception') as $r)
|
foreach(array('recur_interval','recur_enddate','recur_data','recur_exception') as $r)
|
||||||
{
|
{
|
||||||
if(isset($vcardData[$f]))
|
if(isset($vcardData[$r]))
|
||||||
{
|
{
|
||||||
$event[$r] = $vcardData[$r];
|
$event[$r] = $vcardData[$r];
|
||||||
}
|
}
|
||||||
@ -509,7 +518,7 @@
|
|||||||
#{
|
#{
|
||||||
# error_log("KEY: $key VALUE: $value");
|
# error_log("KEY: $key VALUE: $value");
|
||||||
#}
|
#}
|
||||||
//_debug_array($event); exit;
|
//echo "event=";_debug_array($event);
|
||||||
|
|
||||||
if (!($Ok = $this->update($event, TRUE))) break; // stop with the first error
|
if (!($Ok = $this->update($event, TRUE))) break; // stop with the first error
|
||||||
}
|
}
|
||||||
@ -517,7 +526,7 @@
|
|||||||
return $Ok;
|
return $Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSupportedFields(&$_productManufacturer='file', &$_productName='')
|
function setSupportedFields($_productManufacturer='file', $_productName='')
|
||||||
{
|
{
|
||||||
$defaultFields = array('public' => 'public', 'description' => 'description', 'end' => 'end',
|
$defaultFields = array('public' => 'public', 'description' => 'description', 'end' => 'end',
|
||||||
'start' => 'start', 'location' => 'location', 'recur_type' => 'recur_type',
|
'start' => 'start', 'location' => 'location', 'recur_type' => 'recur_type',
|
||||||
|
Loading…
Reference in New Issue
Block a user