new parameter "ical" to calendar_uforms::edit, to create a new event based on an ical

This commit is contained in:
Ralf Becker 2011-05-26 18:28:41 +00:00
parent b1427273d8
commit 547ec37257
2 changed files with 33 additions and 5 deletions

View File

@ -773,6 +773,12 @@ function load_cal(url,id) {
'link' => False
);
}
$file[] = array(
'text' => lang('Import').': '.html::a_href(lang('iCal'),'calendar.calendar_uiforms.import').
' & '.html::a_href(lang('CSV'),'/calendar/csv_import.php'),
'no_lang' => True,
'link' => False,
);
// Merge print
if ($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'])

View File

@ -1080,7 +1080,7 @@ class calendar_uiforms extends calendar_ui
);
$cal_id = (int) $_GET['cal_id'];
if (!$cal_id || $cal_id && !($event = $this->bo->read($cal_id)))
if (!$cal_id && empty($_GET['ical']) || $cal_id && !($event = $this->bo->read($cal_id)))
{
if ($cal_id)
{
@ -1096,6 +1096,28 @@ class calendar_uiforms extends calendar_ui
}
$event =& $this->default_add_event();
}
elseif (!empty($_GET['ical']))
{
$ical = new calendar_ical();
if (!($events = $ical->icaltoegw($_GET['ical'], '', 'utf-8')) || count($events) != 1)
{
error_log(__METHOD__."('$_GET[ical]') error parsing iCal!");
$msg = lang('Error: importing the iCal');
$event =& $this->default_add_event();
}
else
{
$event = array_shift($events);
$event['participant_types'] = array();
foreach($event['participants'] as $uid => $status)
{
calendar_so::split_user($uid, $user_type, $user_id);
$event['participant_types'][$user_type][$user_id] = $status;
}
//error_log(__METHOD__."(...) parsed as ".array2string($event));
}
unset($ical);
}
else
{
$preserv['actual_date'] = $event['start']; // remember the date clicked