diff --git a/src/CalDAVClient.php b/src/CalDAVClient.php index 0016df9..e731a5a 100644 --- a/src/CalDAVClient.php +++ b/src/CalDAVClient.php @@ -62,6 +62,9 @@ class CalDAVClient { private $httpResponseBody = ''; protected $parser; // our XML parser object + protected $request_url = ""; + protected $xmlnodes = array(); + protected $xmltags = array(); // Requests timeout private $timeout; @@ -176,11 +179,10 @@ function DoOptionsRequestAndGetDAVHeader( $url = null ) { $headers = preg_split('/\r?\n/', $headers); // DAV header(s) - $dav_header = preg_grep('/^DAV:/', $headers); + $dav_header = preg_grep('/^DAV:/i', $headers); // /i for case insensitive as some servers (example Nextcloud) do not send uppercase headers if (is_array($dav_header)) { $dav_header = array_values($dav_header); - $dav_header = preg_replace('/^DAV: /', '', $dav_header); - + $dav_header = preg_replace('/^DAV: /i', '', $dav_header); // /i for case insensitive $dav_options = array(); foreach ($dav_header as $d) { diff --git a/src/SimpleCalDAVClient.php b/src/SimpleCalDAVClient.php index 4edafec..6be0c5b 100644 --- a/src/SimpleCalDAVClient.php +++ b/src/SimpleCalDAVClient.php @@ -323,6 +323,33 @@ function getEvents ( $start = null, $end = null ) return $report; } + /** + * function getEventByGuid( $guid ) + * Gets an events from the CalDAV-Server with specified UID. + * + * Arguments: + * @param string $guid UID of the iCal requested. + * + * Return value: + * @return array an array of arrays containing ['href'], ['etag'] and the iCal in ['data'] for the found event. + * + */ + function getEventByGuid ( $guid ) + { + // Connection and calendar set? + if(!isset($this->client)) throw new CalDAVException('No connection. Try connect().', $this->client); + if(!isset($this->client->calendar_url)) throw new CalDAVException('No calendar selected. Try findCalendars() and setCalendar().', $this->client); + + // Get it! + $data = $this->client->GetEntryByUid($guid); + foreach ($data as &$element) { + $element['href'] = $this->client->calendar_url . $element['href']; + unset($element); + } + return $data; + + } + /** * function getTODOs() * Gets a all TODOs from the CalDAV-Server which lie in a defined time interval and match the