Skip to content

Commit

Permalink
Merge pull request #7 from n-osennij/patch-1
Browse files Browse the repository at this point in the history
Update SimpleCalDAVClient.php
  • Loading branch information
carduz authored Jan 30, 2020
2 parents dae70da + 22c3048 commit 406d3b8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/SimpleCalDAVClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function change ( $href, $new_data, $etag )
* @throws CalDAVException
* For debugging purposes, just sorround everything with try { ... } catch (Exception $e) { echo $e->__toString(); exit(-1); }
*/
function delete ( $href, $etag )
function delete ( $href, $etag = null )
{
// Connection and calendar set?
if(!isset($this->client)) throw new Exception('No connection. Try connect().');
Expand All @@ -259,12 +259,18 @@ function delete ( $href, $etag )
$result = $this->client->GetEntryByHref($href);
if(count($result) == 0) throw new CalDAVException('Can\'t find '.$href.'on server', $this->client);

// $etag correct?
if($result[0]['etag'] != $etag) { throw new CalDAVException('Wrong entity tag. The entity seems to have changed.', $this->client); }
if(isset($etag) and !empty($etag)) {
// $etag correct?
if($result[0]['etag'] != $etag) { throw new CalDAVException('Wrong entity tag. The entity seems to have changed.', $this->client); }
}

// Do the deletion
$this->client->DoDELETERequest($href, $etag);

if(isset($etag) and !empty($etag)) {
$this->client->DoDELETERequest($href, $etag);
} else {
$this->client->DoDELETERequest($href);
}

// Deletion successfull?
if ( $this->client->GetHttpResultCode() != '200' and $this->client->GetHttpResultCode() != '204' )
{
Expand Down

0 comments on commit 406d3b8

Please sign in to comment.