From 9e49963a464ca7dc423f567ad773a1fda21fa17c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 6 Apr 2010 12:51:17 +0000 Subject: [PATCH] reverting r29716 (Fix for SyncML prefs) --- addressbook/inc/class.addressbook_sif.inc.php | 49 ++++++------------- .../inc/class.addressbook_vcal.inc.php | 48 +++++++----------- calendar/inc/class.calendar_ical.inc.php | 10 ++-- calendar/inc/class.calendar_sif.inc.php | 8 ++- 4 files changed, 41 insertions(+), 74 deletions(-) diff --git a/addressbook/inc/class.addressbook_sif.inc.php b/addressbook/inc/class.addressbook_sif.inc.php index a724ded2ef..8ad5a9e4bd 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) + function siftoegw($sifData, $_abID=null) { #$tmpfname = tempnam('/tmp/sync/contents','sifc_'); @@ -150,9 +150,14 @@ class addressbook_sif extends addressbook_bo case 'cat_id': if (!empty($value)) { - $categories1 = explode(',', $value); - $categories2 = explode(';', $value); - $finalContact[$key] = count($categories1) > count($categories2) ? $categories1 : $categories2; + $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] = ''; } break; @@ -181,7 +186,7 @@ class addressbook_sif extends addressbook_bo { $result = array(); - if (($contact = $this->siftoegw($_sifdata))) + if (($contact = $this->siftoegw($_sifdata, $contentID))) { if ($contentID) { @@ -202,7 +207,7 @@ class addressbook_sif extends addressbook_bo */ function addSIF($_sifdata, $_abID=null, $merge=false) { - if (!$contact = $this->siftoegw($_sifdata)) + if (!$contact = $this->siftoegw($_sifdata, $_abID)) { return false; } @@ -227,41 +232,17 @@ 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; } - else + elseif (array_key_exists('filter_addressbook', $GLOBALS['egw_info']['user']['preferences']['syncml'])) { - 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'] = (int) $GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']; + if ($contact['owner'] == -1) { - $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; - } + $contact['owner'] = $GLOBALS['egw_info']['user']['account_primary_group']; } } return $this->save($contact); diff --git a/addressbook/inc/class.addressbook_vcal.inc.php b/addressbook/inc/class.addressbook_vcal.inc.php index 3ee243dea2..05a0d31b6f 100644 --- a/addressbook/inc/class.addressbook_vcal.inc.php +++ b/addressbook/inc/class.addressbook_vcal.inc.php @@ -145,48 +145,32 @@ class addressbook_vcal extends addressbook_bo { $contact['account_id'] = $old_contact['account_id']; } - if (is_array($contact['cat_id'])) + if (is_array($contact['category'])) { - $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], $_abID)); + $contact['category'] = implode(',',$this->find_or_add_categories($contact['category'], $_abID)); } else { // restore from orignal - $contact['cat_id'] = $old_contact['cat_id']; + $contact['category'] = $old_contact['category']; } } } // update entry $contact['id'] = $_abID; } - else - { - if (is_array($contact['cat_id'])) + elseif (array_key_exists('filter_addressbook', $GLOBALS['egw_info']['user']['preferences']['syncml'])) + { + $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'])) { - $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1)); + $contact['category'] = implode(',',$this->find_or_add_categories($contact['category'], -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); } @@ -882,6 +866,7 @@ class addressbook_vcal extends addressbook_bo } } + if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . @@ -944,6 +929,11 @@ 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 5e8922c0c7..3fa47a1d33 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -1758,13 +1758,11 @@ 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']; - switch ($owner) + if ($owner == 0) { - case 'G': - case 'P': - $owner = $this->user; + $owner = $GLOBALS['egw_info']['user']['account_primary_group']; } - 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; } @@ -1981,7 +1979,7 @@ class calendar_ical extends calendar_boupdate '(' . $this->productManufacturer . ', '. $this->productName .', ' . ($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) . - ', ' . $this->calendarOwner . ")\n" , 3, $this->logfile); + ")\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 2888f16fee..120e9ae720 100644 --- a/calendar/inc/class.calendar_sif.inc.php +++ b/calendar/inc/class.calendar_sif.inc.php @@ -1213,13 +1213,11 @@ 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']; - switch ($owner) + if ($owner == 0) { - case 'G': - case 'P': - $owner = $this->user; + $owner = $GLOBALS['egw_info']['user']['account_primary_group']; } - 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; }