mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-16 18:31:26 +01:00
* CardDAV/GroupDAV/Addressbook: works now with LDAP backend (account only or all contacts), fixed not working update of accounts (SQL and LDAP), changed ctag generation to work with LDAP too
This commit is contained in:
parent
a0128663ed
commit
7bc098d7c3
@ -987,23 +987,26 @@ class addressbook_bo extends addressbook_so
|
||||
{
|
||||
if (!($data = parent::read($contact_id)))
|
||||
{
|
||||
return null; // not found
|
||||
$data = null; // not found
|
||||
}
|
||||
if (!$this->check_perms(EGW_ACL_READ,$data))
|
||||
elseif (!$this->check_perms(EGW_ACL_READ,$data))
|
||||
{
|
||||
return false; // no view perms
|
||||
$data = false; // no view perms
|
||||
}
|
||||
// determine the file-as type
|
||||
$data['fileas_type'] = $this->fileas_type($data);
|
||||
else
|
||||
{
|
||||
// determine the file-as type
|
||||
$data['fileas_type'] = $this->fileas_type($data);
|
||||
|
||||
// Update country name from code
|
||||
if($data['adr_one_countrycode'] != null) {
|
||||
$data['adr_one_countryname'] = $GLOBALS['egw']->country->get_full_name($data['adr_one_countrycode'], true);
|
||||
// Update country name from code
|
||||
if($data['adr_one_countrycode'] != null) {
|
||||
$data['adr_one_countryname'] = $GLOBALS['egw']->country->get_full_name($data['adr_one_countrycode'], true);
|
||||
}
|
||||
if($data['adr_two_countrycode'] != null) {
|
||||
$data['adr_two_countryname'] = $GLOBALS['egw']->country->get_full_name($data['adr_two_countrycode'], true);
|
||||
}
|
||||
}
|
||||
if($data['adr_two_countrycode'] != null) {
|
||||
$data['adr_two_countryname'] = $GLOBALS['egw']->country->get_full_name($data['adr_two_countrycode'], true);
|
||||
}
|
||||
|
||||
//error_log(__METHOD__.'('.array2string($contact_id).') returning '.array2string($data));
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -2220,22 +2223,22 @@ class addressbook_bo extends addressbook_so
|
||||
{
|
||||
$filter = array('tid' => null); // tid=null --> use all entries incl. deleted (tid='D')
|
||||
// show addressbook of a single user?
|
||||
if (!is_null($owner)) $filter['contact_owner'] = $owner;
|
||||
if (!is_null($owner)) $filter['owner'] = $owner;
|
||||
|
||||
// should we hide the accounts addressbook
|
||||
if (!$owner && $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
|
||||
{
|
||||
$filter['account_id'] = null;
|
||||
}
|
||||
$result = $this->search(array(),'MAX(contact_modified) AS contact_modified','','','',false,'AND',false,$filter);
|
||||
$result = $this->search(array(),'contact_modified','contact_modified DESC','','',false,'AND',array(0,1),$filter);
|
||||
|
||||
if (!$result || !isset($result[0]['contact_modified']))
|
||||
if (!$result || !isset($result[0]['modified']))
|
||||
{
|
||||
$ctag = 'empty'; // ctag for empty addressbook
|
||||
}
|
||||
else
|
||||
{
|
||||
$ctag = $result[0]['contact_modified'];
|
||||
$ctag = $result[0]['modified'];
|
||||
}
|
||||
//error_log(__METHOD__.'('.array2string($owner).') returning '.array2string($ctag));
|
||||
return $ctag;
|
||||
|
@ -72,15 +72,20 @@ class addressbook_groupdav extends groupdav_handler
|
||||
$this->bo = new addressbook_bo();
|
||||
|
||||
// since 1.9.007 we allow clients to specify the URL when creating a new contact, as specified by CardDAV
|
||||
if (version_compare($GLOBALS['egw_info']['apps']['phpgwapi']['version'], '1.9.007', '>='))
|
||||
// LDAP does NOT have a carddav_name attribute --> stick with id mapped to LDAP attribute uid
|
||||
if (version_compare($GLOBALS['egw_info']['apps']['phpgwapi']['version'], '1.9.007', '<') ||
|
||||
$this->bo->contact_repository == 'ldap' ||
|
||||
$this->bo->account_repository == 'ldap' && strpos($_SERVER['REQUEST_URI'].'/','/addressbook-accounts/') !== false)
|
||||
{
|
||||
groupdav_handler::$path_extension = '.vcf';
|
||||
}
|
||||
else
|
||||
{
|
||||
groupdav_handler::$path_attr = 'carddav_name';
|
||||
groupdav_handler::$path_extension = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
groupdav_handler::$path_extension = '.vcf';
|
||||
}
|
||||
if ($this->debug) error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension);
|
||||
|
||||
$this->home_set_pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set'];
|
||||
$this->home_set_pref = $this->home_set_pref ? explode(',',$this->home_set_pref) : array();
|
||||
|
||||
@ -108,13 +113,13 @@ class addressbook_groupdav extends groupdav_handler
|
||||
// If "Sync selected addressbooks into one" is set
|
||||
if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref))
|
||||
{
|
||||
$filter['contact_owner'] = array_keys($this->get_shared(true)); // true: ignore all-in-one pref
|
||||
$filter['contact_owner'][] = $user;
|
||||
$filter['owner'] = array_keys($this->get_shared(true)); // true: ignore all-in-one pref
|
||||
$filter['owner'][] = $user;
|
||||
}
|
||||
// show addressbook of a single user?
|
||||
elseif ($user && $path != '/addressbook/' || $user === 0)
|
||||
{
|
||||
$filter['contact_owner'] = $user;
|
||||
$filter['owner'] = $user;
|
||||
}
|
||||
// should we hide the accounts addressbook
|
||||
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null;
|
||||
@ -202,11 +207,11 @@ class addressbook_groupdav extends groupdav_handler
|
||||
$files[] = $this->add_resource($path, $contact, $props);
|
||||
}
|
||||
}
|
||||
// add groups after contacts, but only if enabled and NOT for '/addressbook/' (!isset($filter['contact_owner'])
|
||||
if (in_array('D',$this->home_set_pref) && (!$start || count($contacts) < $start[1]) && isset($filter['contact_owner']))
|
||||
// add groups after contacts, but only if enabled and NOT for '/addressbook/' (!isset($filter['owner'])
|
||||
if (in_array('D',$this->home_set_pref) && (!$start || count($contacts) < $start[1]) && isset($filter['owner']))
|
||||
{
|
||||
$where = array(
|
||||
'list_owner' => isset($filter['contact_owner'])?$filter['contact_owner']:array_keys($this->bo->grants)
|
||||
'list_owner' => isset($filter['owner'])?$filter['owner']:array_keys($this->bo->grants)
|
||||
);
|
||||
if (isset($filter[self::$path_attr])) // multiget report?
|
||||
{
|
||||
@ -220,9 +225,9 @@ class addressbook_groupdav extends groupdav_handler
|
||||
$list['carddav_name'] = $list['list_carddav_name'];
|
||||
$etag = $list['list_id'].':'.$list['list_etag'];
|
||||
// for all-in-one addressbook, add selected ABs to etag
|
||||
if (isset($filter['contact_owner']) && is_array($filter['contact_owner']))
|
||||
if (isset($filter['owner']) && is_array($filter['owner']))
|
||||
{
|
||||
$etag .= ':'.implode('-',$filter['contact_owner']);
|
||||
$etag .= ':'.implode('-',$filter['owner']);
|
||||
}
|
||||
$props = array(
|
||||
'getcontenttype' => HTTP_WebDAV_Server::mkprop('getcontenttype', 'text/vcard'),
|
||||
@ -513,6 +518,7 @@ class addressbook_groupdav extends groupdav_handler
|
||||
$contact['carddav_name'] = $oldContact['carddav_name'];
|
||||
$contact['tid'] = $oldContact['tid'];
|
||||
$contact['creator'] = $oldContact['creator'];
|
||||
$contact['account_id'] = $oldContact['account_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -645,7 +651,7 @@ class addressbook_groupdav extends groupdav_handler
|
||||
public function getctag($path,$user)
|
||||
{
|
||||
// not showing addressbook of a single user?
|
||||
if (!$user || $path == '/addressbook/') $user = null;
|
||||
if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null;
|
||||
|
||||
// If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too
|
||||
if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref))
|
||||
|
@ -108,6 +108,7 @@ class addressbook_ldap
|
||||
'n_fileas' => 'displayname',
|
||||
'label' => 'postaladdress',
|
||||
'pubkey' => 'usersmimecertificate',
|
||||
'uid' => 'entryuuid',
|
||||
),
|
||||
|
||||
#displayName
|
||||
@ -286,7 +287,8 @@ class addressbook_ldap
|
||||
*/
|
||||
function read($contact_id)
|
||||
{
|
||||
if (is_array($contact_id) && isset($contact_id['account_id']) || substr($contact_id,0,8) == 'account:')
|
||||
if (is_array($contact_id) && isset($contact_id['account_id']) ||
|
||||
!is_array($contact_id) && substr($contact_id,0,8) == 'account:')
|
||||
{
|
||||
$filter = 'uidNumber='.(int)(is_array($contact_id) ? $contact_id['account_id'] : substr($contact_id,8));
|
||||
}
|
||||
@ -436,6 +438,7 @@ class addressbook_ldap
|
||||
$needRecreation = false;
|
||||
// never allow to change the uidNumber (account_id) on update, as it could be misused by eg. xmlrpc or syncml
|
||||
unset($ldapContact['uidnumber']);
|
||||
unset($ldapContact['entryuuid']); // not allowed to modify that, no need either
|
||||
|
||||
// add missing objectclasses
|
||||
if($ldapContact['objectClass'] && array_diff($ldapContact['objectClass'],$oldObjectclasses))
|
||||
@ -665,6 +668,7 @@ class addressbook_ldap
|
||||
$sort = 'ASC';
|
||||
foreach(explode(',',$order_by) as $o)
|
||||
{
|
||||
if (substr($o,0,8) == 'contact_') $o = substr($o,8);
|
||||
if (substr($o,-4) == ' ASC')
|
||||
{
|
||||
$sort = 'ASC';
|
||||
|
@ -800,16 +800,19 @@ class addressbook_so
|
||||
/**
|
||||
* return the backend, to be used for the given $contact_id
|
||||
*
|
||||
* @param mixed $contact_id=null
|
||||
* @param array|string|int $keys=null
|
||||
* @param int $owner=null account_id of owner or 0 for accounts
|
||||
* @return object
|
||||
*/
|
||||
function get_backend($contact_id=null,$owner=null)
|
||||
function get_backend($keys=null,$owner=null)
|
||||
{
|
||||
if ($owner === '') $owner = null;
|
||||
|
||||
$contact_id = !is_array($keys) ? $keys :
|
||||
(isset($keys['id']) ? $keys['id'] : $keys['contact_id']);
|
||||
|
||||
if ($this->contact_repository != $this->account_repository && is_object($this->so_accounts) &&
|
||||
(!is_null($owner) && !$owner || is_array($contact_id) && $contact_id['account_id'] || !is_null($contact_id) &&
|
||||
(!is_null($owner) && !$owner || is_array($keys) && $keys['account_id'] || !is_null($contact_id) &&
|
||||
($this->contact_repository == 'sql' && (!is_numeric($contact_id) && !is_array($contact_id) )||
|
||||
$this->contact_repository == 'ldap' && is_numeric($contact_id))))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user