Author: ralfbecker
New Revision: 55602
URL: http://svn.stylite.de/viewvc/egroupware?rev=55602&view=rev
Log:
move CalDAV/CardDAV server to api
Added:
trunk/egroupware/api/src/CalDAV/
trunk/egroupware/api/src/CalDAV.php
- copied, changed from r55600, trunk/phpgwapi/inc/class.groupdav.inc.php
trunk/egroupware/api/src/CalDAV/Handler.php
- copied, changed from r55600, trunk/phpgwapi/inc/class.groupdav_handler.inc.php
trunk/egroupware/api/src/CalDAV/Hooks.php
- copied, changed from r55600, trunk/phpgwapi/inc/class.groupdav_hooks.inc.php
trunk/egroupware/api/src/CalDAV/Principals.php
- copied, changed from r55600, trunk/phpgwapi/inc/class.groupdav_principals.inc.php
trunk/egroupware/api/src/CalDAV/PropfindIterator.php
- copied, changed from r55600, trunk/phpgwapi/inc/class.groupdav_handler.inc.php
trunk/egroupware/api/src/Json/Tail.php
- copied, changed from r55599, trunk/phpgwapi/inc/class.egw_tail.inc.php
Removed:
trunk/phpgwapi/inc/class.groupdav.inc.php
trunk/phpgwapi/inc/class.groupdav_handler.inc.php
trunk/phpgwapi/inc/class.groupdav_hooks.inc.php
trunk/phpgwapi/inc/class.groupdav_principals.inc.php
Modified:
trunk/addressbook/inc/class.addressbook_groupdav.inc.php
trunk/calendar/inc/class.calendar_groupdav.inc.php
trunk/egroupware/api/src/Mail/Account.php
trunk/egroupware/groupdav.php
trunk/infolog/inc/class.infolog_groupdav.inc.php
trunk/phpgwapi/inc/class.common.inc.php
trunk/phpgwapi/inc/class.egw_tail.inc.php
trunk/phpgwapi/inc/common_functions.inc.php
trunk/phpgwapi/js/jsapi/egw_tail.js
trunk/phpgwapi/setup/setup.inc.php
— trunk/addressbook/inc/class.addressbook_groupdav.inc.php (original)
+++ trunk/addressbook/inc/class.addressbook_groupdav.inc.php Sat Apr 2 12:44:17 2016
@@ -5,7 +5,7 @@
/**
-
- EGroupware: GroupDAV access: addressbook handler
-
- CalDAV/CardDAV/GroupDAV access: Addressbook handler
-
-
- Propfind now uses a groupdav_propfind_iterator with a callback to query huge addressbooks in chunk,
-
- Propfind now uses a Api\CalDAV\PropfindIterator with a callback to query huge addressbooks in chunk,
- without getting into problems with memory_limit.
-
-
- Permanent error_log() calls should use $this->groupdav->log($str) instead, to be send to PHP error_log()
-
- Permanent error_log() calls should use $this->caldav->log($str) instead, to be send to PHP error_log()
- and our request-log (prefixed with "### " after request and response, like exceptions).
/
-class addressbook_groupdav extends groupdav_handler
+class addressbook_groupdav extends Api\CalDAV\Handler
{
/*
- bo class of the application
-
-
-
@var Api\Contacts
*/
var $bo;
@@ -63,13 +63,13 @@
* Constructor
*
* @param string $app ‘calendar’, ‘addressbook’ or ‘infolog’
-
-
@param Api\CalDAV $caldav calling class
- */
- function __construct($app, Api\CalDAV $caldav)
- {
-
parent::__construct($app, $caldav);
-
-
$this->bo = new Api\Contacts();
// since 1.9.007 we allow clients to specify the URL when creating a new contact, as specified by CardDAV
// LDAP does NOT have a carddav_name attribute --> stick with id mapped to LDAP attribute uid
@@ -77,12 +77,12 @@
$this->bo->contact_repository != ‘sql’ ||
$this->bo->account_repository != ‘sql’ && strpos($_SERVER[‘REQUEST_URI’].’/’,’/addressbook-accounts/’) !== false)
{
-
self::$path_attr = 'carddav_name';
-
self::$path_extension = '';
}
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);
@@ -136,7 +136,7 @@
// check if we have to return the full contact data or just the etag's
if (!($filter['address_data'] = $options['props'] == 'all' &&
@@ -177,13 +177,13 @@
else
{
// return iterator, calling ourself to return result in chunks
-
$files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']);
}
return true;
}
/**
-
- Callback for profind interator
-
- Callback for profind iterator
-
-
@param string $path
-
@param array& $filter
@@ -243,7 +243,7 @@
continue;
}
$props = array(
-
'getcontenttype' => Api\CalDAV::mkprop('getcontenttype', 'text/vcard'),
'getlastmodified' => $contact['modified'],
'displayname' => $contact['n_fn'],
);
@@ -251,7 +251,7 @@
{
$content = $handler->getVCard($contact[‘id’],$this->charset,false);
$props[‘getcontentlength’] = bytes($content);
-
$props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'address-data',$content,true);
}
$files[] = $this->add_resource($path, $contact, $props);
}
@@ -271,11 +271,11 @@
$accounts_filter = $filter_in;
$accounts_filter[‘owner’] = ‘0’;
if ($sync_collection_report) $token_was = $this->sync_collection_token;
-
self::$path_attr = 'id';
-
self::$path_extension = '.vcf';
$files = array_merge($files, $this->propfind_callback($path, $accounts_filter, false, false));
@@ -310,7 +310,7 @@
$etag .= ‘:’.implode(’-’,$filter[‘owner’]);
}
$props = array(
-
'getcontenttype' => Api\CalDAV::mkprop('getcontenttype', 'text/vcard'),
'getlastmodified' => egw_time::to($list['list_modified'],'ts'),
'displayname' => $list['list_name'],
'getetag' => '"'.$etag.'"',
@@ -319,7 +319,7 @@
{
$content = $handler->getGroupVCard($list);
$props[‘getcontentlength’] = bytes($content);
-
$props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'address-data',$content,true);
}
$files[] = $this->add_resource($path, $list, $props);
@@ -391,7 +391,7 @@
switch((string)$filter[‘name’])
{
case ‘param-filter’:
-
$this->caldav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
break;
case 'prop-filter': // can be multiple prop-filter, see example
if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
@@ -456,7 +456,7 @@
}
// fall through
default:
@@ -498,11 +498,11 @@
case ‘sync-level’:
if ($option[‘data’] != ‘1’)
{
@@ -517,7 +517,7 @@
$parts = explode(’/’,$option[‘data’]);
if (($id = urldecode(array_pop($parts))))
{
@@ -526,7 +526,7 @@
}
elseif ($id)
{
@@ -848,27 +848,27 @@
if (!isset($props[‘addressbook-description’]))
{
// default addressbook description: can be overwritten via PROPPATCH, in which case it’s already set
-
$props['addressbook-description'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-description',$props['displayname']);
}
// setting an max image size, so iOS scales the images before transmitting them
// we currently scale down to width of 240px, which tests shown to be ~20k
-
'addressbook-query' => HTTP_WebDAV_Server::mkprop('supported-report',array(
-
HTTP_WebDAV_Server::mkprop('report',array(
-
HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-query',''))))),
-
'addressbook-multiget' => HTTP_WebDAV_Server::mkprop('supported-report',array(
-
HTTP_WebDAV_Server::mkprop('report',array(
-
HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-multiget',''))))),
-
'addressbook-query' => Api\CalDAV::mkprop('supported-report',array(
-
Api\CalDAV::mkprop('report',array(
-
Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-query',''))))),
-
'addressbook-multiget' => Api\CalDAV::mkprop('supported-report',array(
-
Api\CalDAV::mkprop('report',array(
-
Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-multiget',''))))),
);
// only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
if ($GLOBALS['egw_info']['server']['history'])
{
-
$props['supported-report-set']['sync-collection'] = HTTP_WebDAV_Server::mkprop('supported-report',array(
-
HTTP_WebDAV_Server::mkprop('report',array(
-
HTTP_WebDAV_Server::mkprop('sync-collection','')))));
-
$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
-
Api\CalDAV::mkprop('report',array(
-
Api\CalDAV::mkprop('sync-collection','')))));
}
return $props;
}
— trunk/calendar/inc/class.calendar_groupdav.inc.php (original)
+++ trunk/calendar/inc/class.calendar_groupdav.inc.php Sat Apr 2 12:44:17 2016
@@ -11,17 +11,19 @@
+use EGroupware\Api;
+
/**
-
- EGroupware: CalDAV / GroupDAV access: calendar handler
-
- CalDAV/CardDAV/GroupDAV access: Calendar handler
-
-
- Permanent error_log() calls should use $this->groupdav->log($str) instead, to be send to PHP error_log()
-
- Permanent error_log() calls should use $this->caldav->log($str) instead, to be send to PHP error_log()
- and our request-log (prefixed with "### " after request and response, like exceptions).
-
-
@ToDo: new properties on calendars and it’s ressources specially from sharing:
-
-
- bo class of the application
@@ -78,7 +80,7 @@
/**
- Are we using id, uid or caldav_name for the path/url
-
-
- Get’s set in constructor to ‘caldav_name’ and groupdav_handler::$path_extension = ‘’!
-
- Get’s set in constructor to ‘caldav_name’ and self::$path_extension = ‘’!
*/
static $path_attr = ‘id’;
@@ -86,11 +88,11 @@
* Constructor
*
* @param string $app ‘calendar’, ‘addressbook’ or ‘infolog’
@@ -99,7 +101,7 @@
if (version_compare($GLOBALS[‘egw_info’][‘apps’][‘calendar’][‘version’], ‘1.9.003’, ‘>=’))
{
self::$path_attr = ‘caldav_name’;
@@ -120,8 +122,8 @@
if (!is_array($event)) $event = $this->bo->read($event);
$name = $event[self::$path_attr];
}
-
$name .= groupdav_handler::$path_extension;
-
//error_log(__METHOD__.'('.array2string($event).") path_attr='".self::$path_attr."', path_extension='".groupdav_handler::$path_extension."' returning ".array2string($name));
-
$name .= self::$path_extension;
-
//error_log(__METHOD__.'('.array2string($event).") path_attr='".self::$path_attr."', path_extension='".self::$path_extension."' returning ".array2string($name));
return $name;
}
@@ -152,8 +154,8 @@
if (isset($_GET['download']))
{
-
$this->caldav->propfind_options['props'] = array(array(
-
'xmlns' => Api\CalDAV::CALDAV,
'name' => 'calendar-data',
));
}
@@ -251,7 +253,7 @@
else
{
// return iterator, calling ourself to return result in chunks
-
$files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']);
}
if (isset($_GET['download']))
{
@@ -319,7 +321,7 @@
{
if ($this->debug) $starttime = microtime(true);
@@ -358,14 +360,14 @@
‘getetag’ => ‘"’.$etag.’"’,
‘getlastmodified’ => $event[‘modified’],
// user and timestamp of creation or last modification of event, used in calendarserver only for shared calendars
-
'created-by' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'created-by',
$this->_created_updated_by_prop($event['creator'], $event['created'])),
-
'updated-by' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'updated-by',
$this->_created_updated_by_prop($event['modifier'], $event['modified'])),
);
if ($this->use_schedule_tag)
{
@@ -375,16 +377,16 @@
!isset($calendar_data[‘children’][‘expand’]) ? false :
($calendar_data[‘children’][‘expand’][‘attrs’] ? $calendar_data[‘children’][‘expand’][‘attrs’] : true));
$props[‘getcontentlength’] = bytes($content);
-
$props['calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data',$content);
}
/* Calendarserver reports new events with schedule-changes: action: create, which iCal request
* adding it, unfortunately does not lead to showing the new event in the users inbox
-
if (strpos($path, '/inbox/') !== false && $this->groupdav->prop_requested('schedule-changes'))
-
{
-
$props['schedule-changes'] = HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'schedule-changes',array(
-
HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'dtstamp',gmdate('Ymd\THis',$event['created']).'Z'),
-
HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'action',array(
-
HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'create',''),
-
if (strpos($path, '/inbox/') !== false && $this->caldav->prop_requested('schedule-changes'))
-
{
-
$props['schedule-changes'] = Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'schedule-changes',array(
-
Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'dtstamp',gmdate('Ymd\THis',$event['created']).'Z'),
-
Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'action',array(
-
Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'create',''),
)),
));
}*/
@@ -438,18 +440,18 @@
{
if ($user && ($val = $this->accounts->id2name($user, $name)))
{
-
$props[$prop] = $ns ? HTTP_WebDAV_Server::mkprop($ns, $prop, $val) : HTTP_WebDAV_Server::mkprop($prop, $val);
-
$props[$prop] = $ns ? Api\CalDAV::mkprop($ns, $prop, $val) : Api\CalDAV::mkprop($prop, $val);
}
}
if ($time)
{
-
$props['dtstamp'] = HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'dtstamp', gmdate('Ymd\\This\\Z', $time));
-
$props['dtstamp'] = Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'dtstamp', gmdate('Ymd\\This\\Z', $time));
}
//error_log(__METHOD__."($user, $time) returning ".array2string($props));
return $props ? $props : '';
@@ -567,11 +569,11 @@
case ‘sync-level’:
if ($option[‘data’] != ‘1’)
{
@@ -587,8 +589,8 @@
if ($id)
{
-
$cal_filters['query'][self::$path_attr] = groupdav_handler::$path_extension ?
-
basename($id,groupdav_handler::$path_extension) : $id;
-
$cal_filters['query'][self::$path_attr] = self::$path_extension ?
-
basename($id,self::$path_extension) : $id;
}
else // fetch all given url's
{
@@ -599,8 +601,8 @@
$parts = explode(’/’,$option[‘data’]);
if (($id = urldecode(array_pop($parts))))
{
-
$cal_filters['query'][self::$path_attr][] = groupdav_handler::$path_extension ?
-
basename($id,groupdav_handler::$path_extension) : $id;
-
$cal_filters['query'][self::$path_attr][] = self::$path_extension ?
-
basename($id,self::$path_extension) : $id;
}
}
}
@@ -872,12 +874,12 @@
{
if ($oldEvent[‘owner’] == $GLOBALS[‘egw_info’][‘user’][‘account_id’])
{
@@ -935,7 +937,7 @@
!($oldEvent[‘recur_date’] == $event[‘recurrence’] || !$event[‘recurrence’] && !$oldEvent[‘recurrence’]))
{
// if recurrence not found --> log it and continue with other recurrence
@@ -966,7 +968,7 @@
}
if (!$modified) // NO modififictions, or none we understood --> log it and return Ok: “204 No Content”
{
-
$this->groupdav->log(__METHOD__."(,,$user) NO changes for current user events=".array2string($events).', old-event='.array2string($oldEvent));
-
$this->caldav->log(__METHOD__."(,,$user) NO changes for current user events=".array2string($events).', old-event='.array2string($oldEvent));
}
$this->put_response_headers($eventId, $options['path'], '204 No Content', self::$path_attr == 'caldav_name');
@@ -1002,7 +1004,7 @@
}
if (!($cal_id = $handler->importVCal($vCalendar, $eventId,
-
self::etag2value($this->http_if_match), false, 0, $this->groupdav->current_user_principal, $user, $charset, $id)))
-
self::etag2value($this->http_if_match), false, 0, $this->caldav->current_user_principal, $user, $charset, $id)))
{
if ($this->debug) error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id));
if ($eventId && $cal_id === false)
@@ -1092,7 +1094,7 @@
list($eventId) = explode(’:’, $id);
if (!($cal_id = $handler->importVCal($vCalendar, $eventId, null,
-
false, 0, $this->groupdav->current_user_principal, $user, $charset)))
-
false, 0, $this->caldav->current_user_principal, $user, $charset)))
{
if ($this->debug) error_log(__METHOD__."() importVCal($eventId) returned false");
}
@@ -1128,13 +1130,13 @@
$handler->setSupportedFields(‘groupdav’);
$handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something
if (!($component = $vcal->getComponent(0)) ||
-
!($event = $handler->vevent2egw($component, $version, $handler->supportedFields, $this->groupdav->current_user_principal, 'Horde_Icalendar_Vfreebusy')))
-
!($event = $handler->vevent2egw($component, $version, $handler->supportedFields, $this->caldav->current_user_principal, 'Horde_Icalendar_Vfreebusy')))
{
return '400 Bad request';
}
if ($event['owner'] != $user)
{
@@ -1149,7 +1151,7 @@
$xml->openMemory();
$xml->setIndent(true);
$xml->startDocument(‘1.0’, ‘UTF-8’);
@@ -1224,16 +1226,16 @@
if ($this->bo->check_perms(EGW_ACL_FREEBUSY, 0, $user))
{
-
$privileges['read-free-busy'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'read-free-busy', '');
if (substr($path, -8) == '/outbox/' && $this->bo->check_acl_invite($user))
{
-
$privileges['schedule-send'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'schedule-send', '');
}
}
if (substr($path, -7) == '/inbox/' && $this->bo->check_acl_invite($user))
{
-
$privileges['schedule-deliver'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'schedule-deliver', '');
}
// remove bind privilege on other users or groups calendars, if calendar config require_acl_invite is set
// and current user has no invite grant
@@ -1494,47 +1496,47 @@
if (!isset($props[‘calendar-description’]))
{
// default calendar description: can be overwritten via PROPPATCH, in which case it’s already set
-
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VCALENDAR')),
-
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VEVENT')),
-
Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VCALENDAR')),
-
Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VEVENT')),
);
// outbox supports VFREEBUSY too, it is required from OS X iCal to autocomplete locations
if (substr($path,-8) == '/outbox/')
{
-
$supported_components[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VFREEBUSY'));
-
}
-
$props['supported-calendar-component-set'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,
-
$supported_components[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VFREEBUSY'));
-
}
-
$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,
'supported-calendar-component-set',$supported_components);
// supported reports
$props['supported-report-set'] = array(
-
'calendar-query' => HTTP_WebDAV_Server::mkprop('supported-report',array(
-
HTTP_WebDAV_Server::mkprop('report',array(
-
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-query',''))))),
-
'calendar-multiget' => HTTP_WebDAV_Server::mkprop('supported-report',array(
-
HTTP_WebDAV_Server::mkprop('report',array(
-
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-multiget',''))))),
-
'free-busy-query' => HTTP_WebDAV_Server::mkprop('supported-report',array(
-
HTTP_WebDAV_Server::mkprop('report',array(
-
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'free-busy-query',''))))),
-
'calendar-query' => Api\CalDAV::mkprop('supported-report',array(
-
Api\CalDAV::mkprop('report',array(
-
Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-query',''))))),
-
'calendar-multiget' => Api\CalDAV::mkprop('supported-report',array(
-
Api\CalDAV::mkprop('report',array(
-
Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))),
-
'free-busy-query' => Api\CalDAV::mkprop('supported-report',array(
-
Api\CalDAV::mkprop('report',array(
-
Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'free-busy-query',''))))),
);
// rfc 6578 sync-collection report for everything but outbox
// only if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
if (strpos($path, '/outbox/') === false && $GLOBALS['egw_info']['server']['calendar_delete_history'])
{
-
$props['supported-report-set']['sync-collection'] = HTTP_WebDAV_Server::mkprop('supported-report',array(
-
HTTP_WebDAV_Server::mkprop('report',array(
-
HTTP_WebDAV_Server::mkprop('sync-collection','')))));
-
}
-
$props['supported-calendar-data'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'supported-calendar-data',array(
-
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
-
HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));
-
$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
-
Api\CalDAV::mkprop('report',array(
-
Api\CalDAV::mkprop('sync-collection','')))));
-
}
-
$props['supported-calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-data',array(
-
Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
-
Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));
// get timezone of calendar
-
if ($this->groupdav->prop_requested('calendar-timezone'))
-
{
-
$props['calendar-timezone'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-timezone',
-
if ($this->caldav->prop_requested('calendar-timezone'))
-
{
-
$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-timezone',
calendar_timezones::user_timezone($user));
}
return $props;
@@ -1594,7 +1596,7 @@
foreach(explode(’,’, $pref) as $res_id)
{
$is_location = $res == ‘locations’;
-
$shared['r'.$res_id] = str_replace('s/', '-', groupdav_principals::resource2name($res_id, $is_location));
-
$shared['r'.$res_id] = str_replace('s/', '-', Api\CalDAV\Principals::resource2name($res_id, $is_location));
}
}
}
@@ -1652,12 +1654,12 @@
);
// allow to subscribe to resources
— trunk/phpgwapi/inc/class.groupdav.inc.php (original)
+++ trunk/egroupware/api/src/CalDAV.php Sat Apr 2 12:44:17 2016
@@ -5,13 +5,21 @@
-require_once(EGW_INCLUDE_ROOT.’/api/src/WebDAV/Server.php’);
+namespace EGroupware\Api;
+
+use EGroupware\Api\CalDAV\Handler;
+use EGroupware\Api\CalDAV\Principals;
+
+// explicit import non-namespaced classes
+require_once(DIR.’/WebDAV/Server.php’);
+use HTTP_WebDAV_Server;
+use calendar_hooks;
/**
- EGroupware: GroupDAV access
@@ -54,7 +62,7 @@
-
@link http://carddav.calconnect.org/ CardDAV resources
-
@link http://calendarserver.org/ Apple calendar and contacts server
/
-class groupdav extends HTTP_WebDAV_Server
+class CalDAV extends HTTP_WebDAV_Server
{
/*
- DAV namespace
@@ -141,7 +149,7 @@
/**
- Instance of our application specific handler
-
-
-
@var Handler
/
var $handler;
/*
@@ -228,7 +236,7 @@
$this->crrnd = false;
// identify clients, which do NOT support path AND full url in <D:href> of PROPFIND request
@@ -262,7 +270,7 @@
}*/
//error_log($_SERVER[‘REQUEST_URI’]." --> ".$this->_SERVER[‘REQUEST_URI’]);
@@ -288,13 +296,13 @@
* get the handler for $app
*
* @param string $app
-
-
@return Handler
*/
function app_handler($app)
{
if (isset($this->root[$app][‘app’])) $app = $this->root[$app][‘app’];
-
return Handler::app_handler($app,$this);
}
/**
@@ -632,7 +640,7 @@
$displayname = ‘EGroupware (Cal|Card|Group)DAV server’;
}
-
$displayname = Translation::convert($displayname, Translation::charset(),'utf-8');
// self url
$props = array(
'displayname' => $displayname,
@@ -710,12 +718,12 @@
}
if ($depth)
{
-
foreach(Principals::get_resources() as $resource)
-
{
-
if ($is_location == Principals::resource_is_location($resource))
{
$files['files'][] = $this->add_app('calendar', false, 'r'.$resource['res_id'],
@@ -800,11 +808,11 @@
{
if ($this->debug) error_log(METHOD."(app=’$app’, no_extra_types=$no_extra_types, user=’$user’, path=’$path’)");
$user_preferences = $GLOBALS[‘egw_info’][‘user’][‘preferences’];
-
if (is_string($user) && $user[0] == 'r' && ($resource = groupdav_principals::read_resource(substr($user, 1))))
-
{
-
$is_location = groupdav_principals::resource_is_location($resource);
-
if (is_string($user) && $user[0] == 'r' && ($resource = Principals::read_resource(substr($user, 1))))
-
{
-
$is_location = Principals::resource_is_location($resource);
$displayname = null;
-
list($principalType, $account_lid) = explode('/', groupdav_principals::resource2name($resource, $is_location, $displayname));
-
list($principalType, $account_lid) = explode('/', Principals::resource2name($resource, $is_location, $displayname));
}
elseif ($user)
{
@@ -850,7 +858,7 @@
}
// fall through
default:
-
$props['displayname'] = Translation::convert(lang($app).' '.$displayname, $this->egw_charset, 'utf-8');
}
// rfc 5995 (Use POST to add members to WebDAV collections): we use collection path with add-member query param
@@ -926,7 +934,7 @@
if (method_exists($handler,‘getctag’) && $this->prop_requested(‘getctag’) === true)
{
$props[‘getctag’] = self::mkprop(
-
self::CALENDARSERVER,'getctag',$handler->getctag($path,$user));
}
// add sync-token url if handler supports sync-collection report
if (isset($props['supported-report-set']['sync-collection']) && $this->prop_requested('sync-token') === true)
@@ -1006,7 +1014,7 @@
{
return $ret; // no collection
}
@@ -1018,7 +1026,7 @@
foreach(explode(’/’,$this->_unslashify($options[‘path’])) as $n => $name)
{
$path .= ($n != 1 ? ‘/’ : ‘’).$name;
@@ -1069,7 +1077,7 @@
}
echo "\t<tr class='$class'>\n\t\t<td>$n</td>\n\t\t<td>".
-
Html::a_href(htmlspecialchars($name),'/groupdav.php'.strtr($file['path'], array(
'%' => '%25',
'#' => '%23',
'?' => '%3F',
@@ -1107,7 +1115,7 @@
echo "</body>\n</html>\n";
-
exit;
}
/**
@@ -1206,7 +1214,7 @@
{
// for some reason OS X Addressbook (CFNetwork user-agent) uses now (DAV:add-member given with collection URL+"?add-member")
// POST to the collection URL plus a UID like name component (like for regular PUT) to create new entrys
@@ -1251,7 +1259,7 @@
*
* @param array &$options
* @param string|int $id
-
-
@param groupdav_handler $handler
-
-
@param Handler $handler
-
@param string $action ‘attachment-add’, ‘attachment-update’, ‘attachment-remove’
-
@return string http status
-
@@ -1259,7 +1267,7 @@
* @todo managed-id does NOT change on update
* @todo updates of attachments through vfs need to call $handler->update_tags($id) too
*/
- protected function managed_attachements(&$options, $id, groupdav_handler $handler, $action)
- protected function managed_attachements(&$options, $id, Handler $handler, $action)
{
error_log(METHOD."(path=$options[path], id=$id, …, action=$action) _GET=".array2string($_GET));
$entry = $handler->_common_get_put_delete(‘GET’, $options, $id);
@@ -1269,7 +1277,7 @@
return $entry ? $entry : “404 Not found”;
}
@@ -1282,7 +1290,7 @@
substr($this->_SERVER[‘HTTP_CONTENT_DISPOSITION’], 0, 10) === ‘attachment’ &&
preg_match(’/filename="?([^";]+)/’, $this->_SERVER[‘HTTP_CONTENT_DISPOSITION’], $matches))
{
-
$filename = Vfs::basename($matches[1]);
}
$path = null;
if (!($to = self::fopen_attachment($handler->app, $handler->get_id($entry), $filename, $this->_SERVER['CONTENT_TYPE'], $path)) ||
@@ -1307,7 +1315,7 @@
}
if ($action == ‘attachment-remove’)
{
@@ -1320,16 +1328,16 @@
if (isset($this->_SERVER[‘HTTP_CONTENT_DISPOSITION’]) &&
substr($this->_SERVER[‘HTTP_CONTENT_DISPOSITION’], 0, 10) === ‘attachment’ &&
preg_match(’/filename="?([^";]+)/’, $this->_SERVER[‘HTTP_CONTENT_DISPOSITION’], $matches) &&
-
if (!Vfs::rename($old_path, $path = Vfs::concat(Vfs::dirname($path), $filename)))
{
self::xml_error(self::mkprop(self::CALDAV, 'valid-managed-id-parameter', ''));
return '403 Forbidden';
}
}
-
if (!($to = Vfs::fopen($path, 'w')) ||
isset($options['stream']) && ($copied=stream_copy_to_stream($options['stream'], $to)) === false ||
isset($options['content']) && ($copied=fwrite($to, $options['content'])) === false)
{
@@ -1377,7 +1385,7 @@
{
error_log(METHOD."(’$app’, $id, attach=".array2string($attach).", delete_via_put=".array2string($delete_via_put).’)’);
-
if (!Link::file_access($app, $id, EGW_ACL_EDIT))
{
error_log(__METHOD__."('$app', $id, ...) no rights to update attachments");
return; // no rights --> nothing to do
@@ -1386,7 +1394,7 @@
if ($delete_via_put)
{
-
foreach(egw_vfs::find(egw_link::vfs_path($app, $id, '', true), array('type' => 'F')) as $path)
-
foreach(Vfs::find(Link::vfs_path($app, $id, '', true), array('type' => 'F')) as $path)
{
$found = false;
foreach($attach as $key => $attr)
@@ -1400,8 +1408,8 @@
}
if (!$found)
{
-
$ok = egw_vfs::unlink($path);
-
error_log(__METHOD__."('$app', $id, ...) egw_vfs::unlink('$path') returned ".array2string($ok));
-
$ok = Vfs::unlink($path);
-
error_log(__METHOD__."('$app', $id, ...) Vfs::unlink('$path') returned ".array2string($ok));
}
}
}
@@ -1413,24 +1421,24 @@
if (isset($attr[‘params’][‘MANAGED-ID’]))
{
// invalid managed-id
-
if (!($path = self::managed_id2path($attr['params']['MANAGED-ID'])) || !Vfs::is_readable($path))
{
error_log(__METHOD__."('$app', $id, ...) invalid MANAGED-ID ".array2string($attr));
self::xml_error(self::mkprop(self::CALDAV, 'valid-managed-id', ''));
return false;
}
-
if($path == ($link = Link::vfs_path($app, $id, Vfs::basename($path))))
{
error_log(__METHOD__."('$app', $id, ...) trying to modify existing MANAGED-ID --> ignored! ".array2string($attr));
continue;
}
// reuse valid managed-id --> symlink attachment
-
if (egw_vfs::readlink($link) === $path) continue; // no need to recreate identical link
-
egw_vfs::unlink($link); // symlink will fail, if $link exists
-
if (Vfs::readlink($link) === $path) continue; // no need to recreate identical link
-
Vfs::unlink($link); // symlink will fail, if $link exists
}
-
if (!Vfs::symlink($path, $link))
{
error_log(__METHOD__."('$app', $id, ...) failed to symlink($path, $link) --> ignored!");
}
@@ -1465,15 +1473,15 @@
*/
protected static function fopen_attachment($app, $id, $_filename, $mime=null, &$path=null)
{
-
preg_match('/\.([^.]+)$/', $filename, $matches) && MimeMagic::ext2mime($matches[1]) == $mime)
{
$parts = explode('.', $filename);
$ext = '.'.array_pop($parts);
@@ -1485,18 +1493,18 @@
}
for($i = 1; $i < 100; ++$i)
{
-
$path = egw_link::vfs_path($app, $id, $filename.($i > 1 ? '-'.$i : '').$ext, true);
-
if (!egw_vfs::stat($path)) break;
-
$path = Link::vfs_path($app, $id, $filename.($i > 1 ? '-'.$i : '').$ext, true);
-
if (!Vfs::stat($path)) break;
}
if ($i >= 100) return null;