From 1f76e0c191bbcdc9180b2825e6aae42e97173b0c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 10 Feb 2012 21:29:50 +0000 Subject: [PATCH] fixed several small issues around CardDAV and history logging in addressbook (dont log not set custom fields as there are not stored and therefore not changed) --- addressbook/inc/class.addressbook_bo.inc.php | 4 ++-- .../inc/class.addressbook_groupdav.inc.php | 7 +++---- .../inc/class.addressbook_tracking.inc.php | 2 ++ addressbook/inc/class.addressbook_vcal.inc.php | 16 +++++++++------- etemplate/inc/class.bo_tracking.inc.php | 2 ++ 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/addressbook/inc/class.addressbook_bo.inc.php b/addressbook/inc/class.addressbook_bo.inc.php index d2c54c8d86..2efd4027d0 100755 --- a/addressbook/inc/class.addressbook_bo.inc.php +++ b/addressbook/inc/class.addressbook_bo.inc.php @@ -1882,10 +1882,9 @@ class addressbook_bo extends addressbook_so */ function find_or_add_categories($catname_list, $contact_id=null) { - if ($contact_id && $contact_id > 0) + if ($contact_id && $contact_id > 0 && ($old_contact = $this->read($contact_id))) { // preserve categories without users read access - $old_contact = $this->read($contact_id); $old_categories = explode(',',$old_contact['cat_id']); $old_cats_preserve = array(); if (is_array($old_categories) && count($old_categories) > 0) @@ -1932,6 +1931,7 @@ class addressbook_bo extends addressbook_so sort($cat_id_list, SORT_NUMERIC); } + //error_log(__METHOD__."(".array2string($catname_list).", $contact_id) returning ".array2string($cat_id_list)); return $cat_id_list; } diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index 464085e7e1..17df932e06 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -508,6 +508,8 @@ class addressbook_groupdav extends groupdav_handler $contact['owner'] = $oldContact['owner']; $contact['private'] = $oldContact['private']; $contact['carddav_name'] = $oldContact['carddav_name']; + $contact['tid'] = $oldContact['tid']; + $contact['creator'] = $oldContact['creator']; } else { @@ -699,12 +701,9 @@ class addressbook_groupdav extends groupdav_handler { $handler = new addressbook_vcal('addressbook','text/vcard'); // Apple iOS or OS X addressbook - if ($this->agent = 'cfnetwork' || $this->agent == 'dataaccess') + if ($this->agent == 'cfnetwork' || $this->agent == 'dataaccess') { $supportedFields = $handler->supportedFields; - // Apple Addressbook don't support CLASS - unset($supportedFields['CLASS']); - unset($supportedFields['CATEGORIES']); // use just CELL and IPHONE, CELL;WORK and CELL;HOME are NOT understood //'TEL;CELL;WORK' => array('tel_cell'), //'TEL;CELL;HOME' => array('tel_cell_private'), diff --git a/addressbook/inc/class.addressbook_tracking.inc.php b/addressbook/inc/class.addressbook_tracking.inc.php index b002cbf20d..3464e3dead 100644 --- a/addressbook/inc/class.addressbook_tracking.inc.php +++ b/addressbook/inc/class.addressbook_tracking.inc.php @@ -79,6 +79,8 @@ class addressbook_tracking extends bo_tracking unset($this->field2history['modified']); unset($this->field2history['modifier']); unset($this->field2history['etag']); + unset($this->field2history['creator']); + unset($this->field2history['tz']); // we currently can only track text unset($this->field2history['jpegphoto']); diff --git a/addressbook/inc/class.addressbook_vcal.inc.php b/addressbook/inc/class.addressbook_vcal.inc.php index 64cd5d3a8b..9be01b93cb 100644 --- a/addressbook/inc/class.addressbook_vcal.inc.php +++ b/addressbook/inc/class.addressbook_vcal.inc.php @@ -72,7 +72,7 @@ class addressbook_vcal extends addressbook_bo 'X-ASSISTANT' => array('assistent'), 'X-ASSISTANT-TEL' => array('tel_assistent'), 'UID' => array('uid'), - 'REV' => array('modified'), + 'REV' => array('modified'), ); /** @@ -204,7 +204,7 @@ class addressbook_vcal extends addressbook_bo #Horde::logMessage("vCalAddressbook clientProperties:\n" . print_r($this->clientProperties, true), __FILE__, __LINE__, PEAR_LOG_DEBUG); $vCard = new Horde_iCalendar_vcard($this->version); - $vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['addressbook']['version'].'//'. + $vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['phpgwapi']['version'].'//'. strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); $sysCharSet = translation::charset(); @@ -283,6 +283,7 @@ class addressbook_vcal extends addressbook_bo { case 'modified': $value = gmdate("Y-m-d\TH:i:s\Z",egw_time::user2server($value)); + $hasdata++; break; case 'private': @@ -329,7 +330,7 @@ class addressbook_vcal extends addressbook_bo break; case 'cat_id': - if (!empty($value) && ($values = $this->get_categories($value))) + if (!empty($value) && ($values = /*str_replace(',','\\,',*/$this->get_categories($value)))//) { $values = (array) translation::convert($values, $sysCharSet, $_charset); $value = implode(',', $values); // just for the CHARSET recognition @@ -468,7 +469,6 @@ class addressbook_vcal extends addressbook_bo } $vCard->setAttribute($vcardField, $value, $options, true, $values); - //$vCard->setParameter($vcardField, $options); } $result = $vCard->exportvCalendar($_charset); @@ -560,6 +560,7 @@ class addressbook_vcal extends addressbook_bo 'X-ASSISTANT' => array('assistent'), 'X-ASSISTANT-TEL' => array('tel_assistent'), 'UID' => array('uid'), + 'REV' => array('modified'), ); if ($this->log) @@ -579,7 +580,7 @@ class addressbook_vcal extends addressbook_bo } $vcardValues = $vCard->getAllAttributes(); - if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) + if (!empty($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) { $minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']; } @@ -599,6 +600,7 @@ class addressbook_vcal extends addressbook_bo $url = 1; $pref_tel = false; + $rowNames = array(); foreach($vcardValues as $key => $vcardRow) { $rowName = strtoupper($vcardRow['name']); @@ -676,7 +678,7 @@ class addressbook_vcal extends addressbook_bo switch ($pname) { case 'PREF': - if ($rowName == 'TEL' && !$pref_tel) + if (substr($rowName,0,3) == 'TEL' && !$pref_tel) { $pref_tel = $key; } @@ -1053,7 +1055,7 @@ class addressbook_vcal extends addressbook_bo require_once(EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/iCalendar/vcard.php'); $vCard = new Horde_iCalendar_vcard($version); - $vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['addressbook']['version'].'//'. + $vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['phpgwapi']['version'].'//'. strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); $vCard->setAttribute('N',$list['list_name'],array(),true,array($list['list_name'],'','','','')); diff --git a/etemplate/inc/class.bo_tracking.inc.php b/etemplate/inc/class.bo_tracking.inc.php index 771551fea7..32fdba4e71 100644 --- a/etemplate/inc/class.bo_tracking.inc.php +++ b/etemplate/inc/class.bo_tracking.inc.php @@ -400,6 +400,8 @@ abstract class bo_tracking { if (!$old[$name] && !$data[$name]) continue; // treat all sorts of empty equally + if ($name[0] == '#' && !isset($data[$name])) continue; // no set customfields are not stored, therefore not changed + if (is_array($status)) // 1:N relation { self::compact_1_N_relation($data[$name],$status);