/**
* Yet another problem: Outlook seems to remove the organizer from
* the iCal when forwarding -- we put the original sender back in
* as organizer.
*
* @param string $icaltext The ical message.
* @param MIME_Headers $from The message sender.
*/
function _addOrganizer(&$icaltxt, $from)
{
global $conf;
if (isset($conf['kolab']['filter']['email_domain'])) {
$email_domain = $conf['kolab']['filter']['email_domain'];
} else {
$email_domain = 'localhost';
}
$iCal = new Horde_Icalendar();
$iCal->parsevCalendar($icaltxt);
$vevent =& $iCal->findComponent('VEVENT');
if ($vevent) {
$organizer = $vevent->getAttribute('ORGANIZER', true);
if (is_a($organizer, 'PEAR_Error')) {
$adrs = imap_rfc822_parse_adrlist($from, $email_domain);
if (count($adrs) > 0) {
$org_email = 'mailto:' . $adrs[0]->mailbox . '@' . $adrs[0]->host;
$org_name = $adrs[0]->personal;
if ($org_name) {
$vevent->setAttribute('ORGANIZER', $org_email, array('CN' => $org_name), false);
} else {
$vevent->setAttribute('ORGANIZER', $org_email, array(), false);
}
Horde::log(sprintf("Adding missing organizer '%s <%s>' to iCal.", $org_name, $org_email), 'DEBUG');
$icaltxt = $iCal->exportvCalendar();
}
}
}
}