diff --git a/addressbook/inc/class.addressbook_sif.inc.php b/addressbook/inc/class.addressbook_sif.inc.php index 697764a25e..1e0f4ed146 100644 --- a/addressbook/inc/class.addressbook_sif.inc.php +++ b/addressbook/inc/class.addressbook_sif.inc.php @@ -117,7 +117,7 @@ class addressbook_sif extends addressbook_bo $this->sifData .= $_data; } - function siftoegw($sifData, $_abID=null) + function siftoegw($sifData) { #$tmpfname = tempnam('/tmp/sync/contents','sifc_'); @@ -150,14 +150,9 @@ class addressbook_sif extends addressbook_bo case 'cat_id': if (!empty($value)) { - $categories1 = explode(',', $value); - $categories2 = explode(';', $value); - $categories = count($categories1) > count($categories2) ? $categories1 : $categories2; - $finalContact[$key] = implode(',', $this->find_or_add_categories($categories, $_abID)); - } - else - { - $finalContact[$key] = ''; + $categories1 = explode(',', $value); + $categories2 = explode(';', $value); + $finalContact[$key] = count($categories1) > count($categories2) ? $categories1 : $categories2; } break; @@ -186,7 +181,7 @@ class addressbook_sif extends addressbook_bo { $result = array(); - if ($contact = $this->siftoegw($_sifdata, $contentID)) + if ($contact = $this->siftoegw($_sifdata)) { if ($contentID) { @@ -207,7 +202,7 @@ class addressbook_sif extends addressbook_bo */ function addSIF($_sifdata, $_abID=null, $merge=false) { - if (!$contact = $this->siftoegw($_sifdata, $_abID)) + if (!$contact = $this->siftoegw($_sifdata)) { return false; } @@ -232,17 +227,41 @@ class addressbook_sif extends addressbook_bo { $contact['account_id'] = $old_contact['account_id']; } + if (is_array($contact['cat_id'])) + { + $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], $_abID)); + } + else + { + // restore from orignal + $contact['cat_id'] = $old_contact['cat_id']; + } } } // update entry $contact['id'] = $_abID; } - elseif (array_key_exists('filter_addressbook', $GLOBALS['egw_info']['user']['preferences']['syncml'])) + else { - $contact['owner'] = (int) $GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']; - if ($contact['owner'] == -1) + if (is_array($contact['cat_id'])) + { + $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1)); + } + if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook'])) { - $contact['owner'] = $GLOBALS['egw_info']['user']['account_primary_group']; + $owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']; + switch ($owner) + { + case 'G': + $contact['owner'] = $GLOBALS['egw_info']['user']['account_primary_group']; + break; + case 'P': + case 0: + $contact['owner'] = $this->user; + break; + default: + $contact['owner'] = (int)$owner; + } } } return $this->save($contact); diff --git a/addressbook/inc/class.addressbook_vcal.inc.php b/addressbook/inc/class.addressbook_vcal.inc.php index bf2b48cb2f..ed87ad0a20 100644 --- a/addressbook/inc/class.addressbook_vcal.inc.php +++ b/addressbook/inc/class.addressbook_vcal.inc.php @@ -148,32 +148,48 @@ class addressbook_vcal extends addressbook_bo { $contact['account_id'] = $old_contact['account_id']; } - if (is_array($contact['category'])) + if (is_array($contact['cat_id'])) { - $contact['category'] = implode(',',$this->find_or_add_categories($contact['category'], $_abID)); + $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], $_abID)); } else { // restore from orignal - $contact['category'] = $old_contact['category']; + $contact['cat_id'] = $old_contact['cat_id']; } } } // update entry $contact['id'] = $_abID; } - elseif (array_key_exists('filter_addressbook', $GLOBALS['egw_info']['user']['preferences']['syncml'])) + else { - $contact['owner'] = (int) $GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']; - if ($contact['owner'] == -1) - { - $contact['owner'] = $GLOBALS['egw_info']['user']['account_primary_group']; - } - if (is_array($contact['category'])) + if (is_array($contact['cat_id'])) { - $contact['category'] = implode(',',$this->find_or_add_categories($contact['category'], -1)); + $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1)); } + if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook'])) + { + $owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']; + switch ($owner) + { + case 'G': + $contact['owner'] = $GLOBALS['egw_info']['user']['account_primary_group']; + break; + case 'P': + case 0: + $contact['owner'] = $this->user; + break; + default: + $contact['owner'] = (int)$owner; + } + } } + if ($this->log) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . + array2string($contact)."\n",3,$this->logfile); + } return $this->save($contact); } @@ -869,7 +885,6 @@ class addressbook_vcal extends addressbook_bo } } - if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . @@ -932,11 +947,6 @@ class addressbook_vcal extends addressbook_bo } } - if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook'])) - { - $contact['owner'] = $GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']; - } - $this->fixup_contact($contact); if ($this->log) diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index c1b55b81da..5b7afb36c4 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -1662,12 +1662,14 @@ class calendar_ical extends calendar_boupdate if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner'])) { $owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner']; - if ($owner == 0) + switch ($owner) { - $owner = $GLOBALS['egw_info']['user']['account_primary_group']; + case 'G': + case 'P': + $owner = $this->user; + break; } - - if (0 < (int)$owner && $this->check_perms(EGW_ACL_EDIT,0,$owner)) + if (0 < (int)$owner && $this->check_perms(EGW_ACL_EDIT, 0, $owner)) { $this->calendarOwner = $owner; } @@ -1877,7 +1879,7 @@ class calendar_ical extends calendar_boupdate '(' . $this->productManufacturer . ', '. $this->productName .', ' . ($this->useServerTZ ? 'SERVERTIME' : 'USERTIME') . - ")\n" , 3, $this->logfile); + ', ' . $this->calendarOwner . ")\n" , 3, $this->logfile); } //Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', ' diff --git a/calendar/inc/class.calendar_sif.inc.php b/calendar/inc/class.calendar_sif.inc.php index 361e7eabc8..eda6c7121a 100644 --- a/calendar/inc/class.calendar_sif.inc.php +++ b/calendar/inc/class.calendar_sif.inc.php @@ -1011,11 +1011,14 @@ class calendar_sif extends calendar_boupdate if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner'])) { $owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner']; - if ($owner == 0) + switch ($owner) { - $owner = $GLOBALS['egw_info']['user']['account_primary_group']; + case 'G': + case 'P': + $owner = $this->user; + break; } - if (0 < (int)$owner && $this->check_perms(EGW_ACL_EDIT,0,$owner)) + if (0 < (int)$owner && $this->check_perms(EGW_ACL_EDIT, 0, $owner)) { $this->calendarOwner = $owner; } diff --git a/phpgwapi/inc/horde/Horde/iCalendar.php b/phpgwapi/inc/horde/Horde/iCalendar.php index f6e99fd9df..ede61557e5 100644 --- a/phpgwapi/inc/horde/Horde/iCalendar.php +++ b/phpgwapi/inc/horde/Horde/iCalendar.php @@ -462,8 +462,11 @@ class Horde_iCalendar { /** * Export as vCalendar format. + * + * @param string $charset The encoding charset for $text. Defaults to + * utf-8 for new format, standard character set for old format. */ - function exportvCalendar() + function exportvCalendar($charset = null) { // Default values. $requiredAttributes['PRODID'] = '-//The Horde Project//Horde_iCalendar Library' . (defined('HORDE_VERSION') ? ', Horde ' . constant('HORDE_VERSION') : '') . '//EN'; @@ -475,7 +478,7 @@ class Horde_iCalendar { } } - return $this->_exportvData('VCALENDAR'); + return $this->_exportvData('VCALENDAR', $charset); } /** @@ -881,10 +884,12 @@ class Horde_iCalendar { * Export this component in vCal format. * * @param string $base The type of the base object. + * @param string $charset The encoding charset for $text. Defaults to + * utf-8 for new format, standard character set for old format. * * @return string vCal format data. */ - function _exportvData($base = 'VCALENDAR') + function _exportvData($base = 'VCALENDAR', $charset = null) { $base = String::upper($base); @@ -898,6 +903,15 @@ class Horde_iCalendar { // Ensure that version is the first attribute. $result .= 'VERSION:' . $this->_version . $this->_newline; } + + if (empty($charset)) { + if ($this->isOldFormat()) { + $charset = NLS::getCharset(); + } else { + $charset = 'utf-8'; + } + } + foreach ($this->_attributes as $attribute) { $name = $attribute['name']; if ($name == 'VERSION') { @@ -910,9 +924,12 @@ class Horde_iCalendar { if ($params) { foreach ($params as $param_name => $param_value) { /* Skip CHARSET for iCalendar 2.0 data, not allowed. */ - if ($param_name == 'CHARSET' - && (!$this->isOldFormat() || empty($param_value))) { - continue; + if ($param_name == 'CHARSET') { + if (!$this->isOldFormat() || empty($param_value)) { + continue; + } else { + $param_value = String::Upper($param_value); + } } if ($param_name == 'ENCODING') { continue; @@ -926,6 +943,11 @@ class Horde_iCalendar { if ($this->isOldFormat() && $param_name == 'TZID') { continue; } + // Skip CN in ATTENDEE adn ORGANIZER for vCalendar 1.0 + if ($this->isOldFormat() && $param_name == 'CN' && + ($name == 'ATTENDEE' || $name == 'ORGANIZER')) { + continue; + } if ($param_value === null) { $params_str .= ";$param_name"; } else { @@ -945,8 +967,7 @@ class Horde_iCalendar { $value = $this->_exportDateTime($value); break; - - // Support additional fields after date. + // Support additional fields after date. case 'AALARM': case 'DALARM': if (isset($params['VALUE'])) { @@ -1143,7 +1164,7 @@ class Horde_iCalendar { !isset($params['CHARSET'])) { // Add CHARSET as well. At least the synthesis client // gets confused otherwise - $params['CHARSET'] = NLS::getCharset(); + $params['CHARSET'] = String::upper($charset); $params_str .= ';CHARSET=' . $params['CHARSET']; } } else { @@ -1209,7 +1230,7 @@ class Horde_iCalendar { $params_str .= ';ENCODING=' . $params['ENCODING']; $attr_string = $name . $params_str . ':' . $this->_newline . ' ' . $this->_base64Encode($value); $attr_string = String::wordwrap($attr_string, 75, $this->_newline . ' ', - true, 'utf-8', true); + true, 'utf-8', true); // charset does not matter $result .= $attr_string . $this->_newline; if ($this->isOldFormat()) { $result .= $this->_newline; // Append an empty line @@ -1227,7 +1248,7 @@ class Horde_iCalendar { } if (!$this->isOldFormat()) { $attr_string = String::wordwrap($attr_string, 75, $this->_newline . ' ', - true, 'utf-8', true); + true, $charset, true); } $result .= $attr_string . $this->_newline; } @@ -1238,7 +1259,7 @@ class Horde_iCalendar { // Not supported continue; } - $result .= $component->exportvCalendar(); + $result .= $component->exportvCalendar($charset); } return $result . 'END:' . $base . $this->_newline;