From 20fb58dd6a7ca7082047bd61fe44c3cf05712237 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 20 Oct 2010 13:23:19 +0000 Subject: [PATCH] loop over existing addressbooks, to make sure each ab is only once in addressbook-home-set, even when selected multiple times in the prefs because of symbolic ab like "primary group" --- .../inc/class.groupdav_principals.inc.php | 48 ++++++++----------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/phpgwapi/inc/class.groupdav_principals.inc.php b/phpgwapi/inc/class.groupdav_principals.inc.php index 92abc89525..732165061a 100644 --- a/phpgwapi/inc/class.groupdav_principals.inc.php +++ b/phpgwapi/inc/class.groupdav_principals.inc.php @@ -257,37 +257,31 @@ class groupdav_principals extends groupdav_handler $prefs = $GLOBALS['egw_info']['user']['preferences']['groupdav']; $addressbook_home_set = $prefs['addressbook-home-set']; if (empty($addressbook_home_set)) $addressbook_home_set = 'P'; // personal addressbook - - if (strpos($addressbook_home_set,'A') !== false) + $addressbook_home_set = explode(',',$addressbook_home_set); + // replace symbolic id's with real nummeric id's + foreach(array( + 'P' => $GLOBALS['egw_info']['user']['account_id'], + 'G' => $GLOBALS['egw_info']['user']['account_primary_group'], + 'U' => '0', + ) as $sym => $id) { - $addressbook_home_set = array_keys(ExecMethod('addressbook.addressbook_bo.get_addressbooks',EGW_ACL_READ)); - } - else - { - $addressbook_home_set = explode(',',$addressbook_home_set); - } - foreach($addressbook_home_set as $id) - { - switch($id) + if (($key = array_search($sym, $addressbook_home_set)) !== false) { - case 'P': - $id = $GLOBALS['egw_info']['user']['account_id']; - break; - case 'G': - $id = $GLOBALS['egw_info']['user']['account_primary_group']; - break; - case 'O': // "all in one" from groupdav.php/addressbook/ - $addressbooks[] = HTTP_WebDAV_Server::mkprop('href', - $this->base_uri.'/'); - continue 2; - } - if (is_numeric($id) && ($owner = $GLOBALS['egw']->accounts->id2name($id))) - { - $addressbooks[] = HTTP_WebDAV_Server::mkprop('href', - $this->base_uri.'/'.$owner.'/'); + $addressbook_home_set[$key] = $id; + } + } + if (in_array('O',$addressbook_home_set)) // "all in one" from groupdav.php/addressbook/ + { + $addressbooks[] = HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'); + } + foreach(ExecMethod('addressbook.addressbook_bo.get_addressbooks',EGW_ACL_READ) as $id => $label) + { + if ((in_array('A',$addressbook_home_set) || in_array((string)$id,$addressbook_home_set)) && + is_numeric($id) && ($owner = $GLOBALS['egw']->accounts->id2name($id))) + { + $addressbooks[] = HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'.$owner.'/'); } } - $cal_bo = new calendar_bo(); foreach ($cal_bo->list_cals() as $label => $entry) {