mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-26 01:43:47 +01:00
Announce all available addressbooks and calendars of the current user with GroupDAV
This commit is contained in:
parent
d00b629269
commit
33bd0fed50
@ -169,7 +169,7 @@ class addressbook_groupdav extends groupdav_handler
|
||||
unset($filter['address_data']);
|
||||
$files = array();
|
||||
// we query etag and modified, as LDAP does not have the strong sql etag
|
||||
if (($contacts =& $this->bo->search(array(),$address_data ? false : array('id','uid','etag','modified'),'contact_id','','',False,'AND',$start,$filter)))
|
||||
if (($contacts =& $this->bo->search(array(),array('id','uid','etag','modified'),'contact_id','','',False,'AND',$start,$filter)))
|
||||
{
|
||||
foreach($contacts as &$contact)
|
||||
{
|
||||
|
@ -1528,6 +1528,7 @@ class calendar_bo
|
||||
function _list_cals_add($id,&$users,&$groups)
|
||||
{
|
||||
$name = $GLOBALS['egw']->common->grab_owner_name($id);
|
||||
$egw_name = $GLOBALS['egw']->accounts->id2name($id);
|
||||
if (($type = $GLOBALS['egw']->accounts->get_type($id)) == 'g')
|
||||
{
|
||||
$arr = &$groups;
|
||||
@ -1539,7 +1540,8 @@ class calendar_bo
|
||||
$arr[$name] = Array(
|
||||
'grantor' => $id,
|
||||
'value' => ($type == 'g' ? 'g_' : '') . $id,
|
||||
'name' => $name
|
||||
'name' => $name,
|
||||
'sname' => $egw_name
|
||||
);
|
||||
}
|
||||
|
||||
@ -1570,6 +1572,13 @@ class calendar_bo
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($groups as $name => $group)
|
||||
{
|
||||
foreach ($users as $user)
|
||||
{
|
||||
if ($user['sname'] == $group['sname']) unset($groups[$name]);
|
||||
}
|
||||
}
|
||||
uksort($users,'strnatcasecmp');
|
||||
uksort($groups,'strnatcasecmp');
|
||||
|
||||
|
@ -242,9 +242,6 @@ class groupdav extends HTTP_WebDAV_Server
|
||||
$account_lid = $GLOBALS['egw_info']['user']['account_lid'];
|
||||
}
|
||||
$account = $this->accounts->read($account_lid);
|
||||
$displayname = $GLOBALS['egw']->translation->convert($account['account_fullname'],
|
||||
$GLOBALS['egw']->translation->charset(),'utf-8');
|
||||
|
||||
$files = array('files' => array());
|
||||
$path = $user_prefix = $this->_slashify($user_prefix);
|
||||
|
||||
@ -254,21 +251,30 @@ class groupdav extends HTTP_WebDAV_Server
|
||||
{
|
||||
$user_prefix = '/'; //.$GLOBALS['egw_info']['user']['account_lid'].'/';
|
||||
}
|
||||
if ($options['depth'])
|
||||
{
|
||||
$displayname = 'EGroupware (Cal|Card|Group)DAV server';
|
||||
}
|
||||
$calendar_user_address_set = array(
|
||||
self::mkprop('href',$this->base_uri.'/principals/'.$principalType.'/'.$account['account_lid'].'/'),
|
||||
self::mkprop('href','urn:uuid:'.$account['account_lid']));
|
||||
if ($user < 0)
|
||||
{
|
||||
$principalType = 'groups';
|
||||
$displayname = lang('Group').' '.$account['account_lid'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$principalType = 'users';
|
||||
$displayname = $account['account_fullname'];
|
||||
$calendar_user_address_set[] = self::mkprop('href','MAILTO:'.$account['account_email']);
|
||||
}
|
||||
if ($options['depth'] && $user_prefix == '/')
|
||||
{
|
||||
$displayname = 'EGroupware (Cal|Card|Group)DAV server';
|
||||
}
|
||||
|
||||
$displayname = translation::convert($displayname, translation::charset(),'utf-8');
|
||||
// self url
|
||||
$props = array(
|
||||
self::mkprop('displayname',$displayname),
|
||||
self::mkprop('owner',array(self::mkprop('href',$this->base_uri.'/principals/'.$principalType.'/'.$account_lid.'/'))),
|
||||
self::mkprop('resourcetype',array(self::mkprop('collection',''))),
|
||||
// adding the calendar extra property (calendar-home-set, etc.) here, allows apple iCal to "autodetect" the URL
|
||||
self::mkprop(groupdav::CALDAV,'calendar-home-set',array(
|
||||
@ -276,10 +282,7 @@ class groupdav extends HTTP_WebDAV_Server
|
||||
self::mkprop(groupdav::CARDDAV,'addressbook-home-set',array(
|
||||
self::mkprop('href',$this->base_uri.$user_prefix))),
|
||||
self::mkprop('current-user-principal',array(self::mkprop('href',$this->principalURL))),
|
||||
self::mkprop(groupdav::CALDAV,'calendar-user-address-set',array(
|
||||
self::mkprop('href','MAILTO:'.$account['account_email']),
|
||||
self::mkprop('href',$this->base_uri.'/principals/'.$principalType.'/'.$account['account_lid'].'/'),
|
||||
self::mkprop('href','urn:uuid:'.$account['account_lid']))),
|
||||
self::mkprop(groupdav::CALDAV,'calendar-user-address-set',$calendar_user_address_set),
|
||||
self::mkprop(groupdav::CALENDARSERVER,'email-address-set',array(
|
||||
self::mkprop(groupdav::CALENDARSERVER,'email-address',$GLOBALS['egw_info']['user']['email']))),
|
||||
//self::mkprop('principal-URL',array(self::mkprop('href',$this->principalURL))),
|
||||
@ -464,8 +467,9 @@ class groupdav extends HTTP_WebDAV_Server
|
||||
}
|
||||
if (method_exists($app.'_groupdav','extra_properties'))
|
||||
{
|
||||
$displayname = $GLOBALS['egw']->translation->convert($account['account_fullname'],
|
||||
$GLOBALS['egw']->translation->charset(),'utf-8');
|
||||
$displayname = translation::convert(
|
||||
$account['account_id'] > 0 ? $account['account_fullname'] : lang('Group').' '.$account['account_lid'],
|
||||
translation::charset(),'utf-8');
|
||||
$props = ExecMethod2($app.'_groupdav::extra_properties',$props,$displayname,$this->base_uri);
|
||||
}
|
||||
return $props;
|
||||
@ -722,6 +726,7 @@ class groupdav extends HTTP_WebDAV_Server
|
||||
$options['content'] .= fread($options['stream'],8192);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->debug) error_log(__METHOD__.'('.array2string($options).')');
|
||||
|
||||
if (!$this->_parse_path($options['path'],$id,$app,$user))
|
||||
|
@ -251,6 +251,38 @@ class groupdav_principals extends groupdav_handler
|
||||
$this->base_uri.'/principals/groups/'.$group);
|
||||
}
|
||||
}
|
||||
$addressbooks = array();
|
||||
$calendars = array();
|
||||
if ($account['account_id'] == $GLOBALS['egw_info']['user']['account_id'])
|
||||
{
|
||||
$addr_bo = new addressbook_bo();
|
||||
foreach ($addr_bo->get_addressbooks() as $id => $label)
|
||||
{
|
||||
if ($id && is_numeric($id))
|
||||
{
|
||||
$owner = $GLOBALS['egw']->accounts->id2name($id);
|
||||
$addressbooks[] = HTTP_WebDAV_Server::mkprop('href',
|
||||
$this->base_uri.'/'.$owner.'/');
|
||||
}
|
||||
}
|
||||
$addressbooks[] = HTTP_WebDAV_Server::mkprop('href',
|
||||
$this->base_uri.'/DAB/');
|
||||
$cal_bo = new calendar_bo();
|
||||
foreach ($cal_bo->list_cals() as $label => $entry)
|
||||
{
|
||||
$id = $entry['grantor'];
|
||||
$owner = $GLOBALS['egw']->accounts->id2name($id);
|
||||
$calendars[] = HTTP_WebDAV_Server::mkprop('href',
|
||||
$this->base_uri.'/'.$owner.'/');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$addressbooks[] = HTTP_WebDAV_Server::mkprop('href',
|
||||
$this->base_uri.'/'.$account['account_lid'].'/');
|
||||
$calendars[] = HTTP_WebDAV_Server::mkprop('href',
|
||||
$this->base_uri.'/'.$account['account_lid'].'/');
|
||||
}
|
||||
$props = array(
|
||||
HTTP_WebDAV_Server::mkprop('displayname',$displayname),
|
||||
HTTP_WebDAV_Server::mkprop('getetag',$this->get_etag($account)),
|
||||
@ -260,8 +292,7 @@ class groupdav_principals extends groupdav_handler
|
||||
HTTP_WebDAV_Server::mkprop('href','MAILTO:'.$account['account_email']))),
|
||||
HTTP_WebDAV_Server::mkprop('principal-URL',array(
|
||||
HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/principals/users/'.$account['account_lid'].'/'))),
|
||||
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-home-set',array(
|
||||
HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/'))),
|
||||
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-home-set',$calendars),
|
||||
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-address-set',array(
|
||||
HTTP_WebDAV_Server::mkprop('href','MAILTO:'.$account['account_email']),
|
||||
HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/principals/users/'.$account['account_lid'].'/'),
|
||||
@ -274,8 +305,7 @@ class groupdav_principals extends groupdav_handler
|
||||
HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'first-name',$account['account_firstname']),
|
||||
HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'record-type','user'),
|
||||
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-type','INDIVIDUAL'),
|
||||
HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-home-set',array(
|
||||
HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/'))),
|
||||
HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-home-set',$addressbooks),
|
||||
HTTP_WebDAV_Server::mkprop('group-member-ship', $memberships),
|
||||
HTTP_WebDAV_Server::mkprop('supported-report-set',array(
|
||||
HTTP_WebDAV_Server::mkprop('supported-report',array(
|
||||
|
Loading…
Reference in New Issue
Block a user