Prevent from a fatal error when DAV connection fails
This commit is contained in:
parent
3c44d7f768
commit
685370e309
1 changed files with 39 additions and 0 deletions
|
@ -116,6 +116,10 @@ class kolab_dav_client
|
|||
|
||||
/**
|
||||
* Discover DAV folders of specified type on the server
|
||||
*
|
||||
* @param string $component Component to filter by (VEVENT, VTODO, VCARD)
|
||||
*
|
||||
* @return false|array List of folders' metadata or False on error
|
||||
*/
|
||||
public function discover($component = 'VEVENT')
|
||||
{
|
||||
|
@ -137,6 +141,10 @@ class kolab_dav_client
|
|||
// Note: Cyrus CardDAV service requires Depth:1 (CalDAV works without it)
|
||||
$response = $this->request('/' . $roots[$component], 'PROPFIND', $body, ['Depth' => 1, 'Prefer' => 'return-minimal']);
|
||||
|
||||
if (empty($response)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$elements = $response->getElementsByTagName('response');
|
||||
|
||||
foreach ($elements as $element) {
|
||||
|
@ -171,6 +179,10 @@ class kolab_dav_client
|
|||
|
||||
$response = $this->request($principal_href, 'PROPFIND', $body);
|
||||
|
||||
if (empty($response)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$elements = $response->getElementsByTagName('response');
|
||||
|
||||
foreach ($elements as $element) {
|
||||
|
@ -234,6 +246,12 @@ class kolab_dav_client
|
|||
|
||||
/**
|
||||
* Create a DAV object in a folder
|
||||
*
|
||||
* @param string $location Object location
|
||||
* @param string $content Object content
|
||||
* @param string $component Content type (VEVENT, VTODO, VCARD)
|
||||
*
|
||||
* @return false|string|null ETag string (or NULL) on success, False on error
|
||||
*/
|
||||
public function create($location, $content, $component = 'VEVENT')
|
||||
{
|
||||
|
@ -262,6 +280,12 @@ class kolab_dav_client
|
|||
|
||||
/**
|
||||
* Update a DAV object in a folder
|
||||
*
|
||||
* @param string $location Object location
|
||||
* @param string $content Object content
|
||||
* @param string $component Content type (VEVENT, VTODO, VCARD)
|
||||
*
|
||||
* @return false|string|null ETag string (or NULL) on success, False on error
|
||||
*/
|
||||
public function update($location, $content, $component = 'VEVENT')
|
||||
{
|
||||
|
@ -270,6 +294,10 @@ class kolab_dav_client
|
|||
|
||||
/**
|
||||
* Delete a DAV object from a folder
|
||||
*
|
||||
* @param string $location Object location
|
||||
*
|
||||
* @return bool True on success, False on error
|
||||
*/
|
||||
public function delete($location)
|
||||
{
|
||||
|
@ -280,6 +308,11 @@ class kolab_dav_client
|
|||
|
||||
/**
|
||||
* Fetch DAV objects metadata (ETag, href) a folder
|
||||
*
|
||||
* @param string $location Folder location
|
||||
* @param string $component Object type (VEVENT, VTODO, VCARD)
|
||||
*
|
||||
* @return false|array Objects metadata on success, False on error
|
||||
*/
|
||||
public function getIndex($location, $component = 'VEVENT')
|
||||
{
|
||||
|
@ -327,6 +360,12 @@ class kolab_dav_client
|
|||
|
||||
/**
|
||||
* Fetch DAV objects data from a folder
|
||||
*
|
||||
* @param string $location Folder location
|
||||
* @param string $component Object type (VEVENT, VTODO, VCARD)
|
||||
* @param array $hrefs List of objects' locations to fetch (empty for all objects)
|
||||
*
|
||||
* @return false|array Objects metadata on success, False on error
|
||||
*/
|
||||
public function getData($location, $component = 'VEVENT', $hrefs = [])
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue