From ffefc2848ea0e54c76c325b63ccbfe4525d16a8b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 6 Aug 2013 09:14:20 +0000 Subject: [PATCH] * CardDAV/Addressbook/ActiveDirectory: fixes SQL error when clients tries to propfind groups/distribution lists on accounts-addressbook, also return "403 Forbidden" when he tries to create one, as they are not (yet) supported on accounts, if not stored in SQL --- addressbook/inc/class.addressbook_so.inc.php | 10 ++++++---- addressbook/inc/class.addressbook_sql.inc.php | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addressbook/inc/class.addressbook_so.inc.php b/addressbook/inc/class.addressbook_so.inc.php index 298c68eab1..d56e0aca12 100755 --- a/addressbook/inc/class.addressbook_so.inc.php +++ b/addressbook/inc/class.addressbook_so.inc.php @@ -1001,9 +1001,10 @@ class addressbook_so */ function read_lists($keys,$member_attr=null,$limit_in_ab=false) { - if (!method_exists($this->somain,'get_lists')) return false; + $backend = (string)$limit_in_ab === '0' && $this->so_accounts ? $this->so_accounts : $this->somain; + if (!method_exists($backend, 'get_lists')) return false; - return $this->somain->get_lists($keys,null,$member_attr,$limit_in_ab); + return $backend->get_lists($keys,null,$member_attr,$limit_in_ab); } /** @@ -1017,9 +1018,10 @@ class addressbook_so */ function add_list($keys,$owner,$contacts=array(),array &$data=array()) { - if (!method_exists($this->somain,'add_list')) return false; + $backend = (string)$owner === '0' && $this->so_accounts ? $this->so_accounts : $this->somain; + if (!method_exists($backend, 'add_list')) return false; - return $this->somain->add_list($keys,$owner,$contacts,$data); + return $backend->add_list($keys,$owner,$contacts,$data); } /** diff --git a/addressbook/inc/class.addressbook_sql.inc.php b/addressbook/inc/class.addressbook_sql.inc.php index 97e9119233..76f7d0cdde 100644 --- a/addressbook/inc/class.addressbook_sql.inc.php +++ b/addressbook/inc/class.addressbook_sql.inc.php @@ -485,6 +485,11 @@ class addressbook_sql extends so_sql_cf */ function get_lists($uids,$uid_column='list_owner',$member_attr=null,$limit_in_ab=false) { + if (is_array($uids) && array_key_exists('list_id', $uids)) + { + $uids[] = $this->db->expression($this->lists_table, $this->lists_table.'.',array('list_id' => $uids['list_id'])); + unset($uids['list_id']); + } $lists = array(); foreach($this->db->select($this->lists_table,'*',$uid_column?array($uid_column=>$uids):$uids,__LINE__,__FILE__, false,'ORDER BY list_owner<>'.(int)$GLOBALS['egw_info']['user']['account_id'].',list_name') as $row)