Skip to content

Commit

Permalink
Merge pull request #1 from temistokles/patch-1
Browse files Browse the repository at this point in the history
Fix PHP notice in case tags are not present
  • Loading branch information
carduz authored Jan 10, 2018
2 parents b8f62de + c559780 commit 561c07e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/CalDAVClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,10 @@ function CalendarUrls( $urls = null ) {
* @param string $tagname The tag name to find the href inside of
*/
function HrefValueInside( $tagname ) {
if (!isset($this->xmltags[$tagname])) {
return null;
}

foreach( $this->xmltags[$tagname] AS $k => $v ) {
$j = $v + 1;
if ( $this->xmlnodes[$j]['tag'] == 'DAV::href' ) {
Expand Down Expand Up @@ -729,12 +733,14 @@ function FindCalendarHome( $recursed=false ) {
}

$calendar_home = array();
foreach( $this->xmltags['urn:ietf:params:xml:ns:caldav:calendar-home-set'] AS $k => $v ) {
if ( $this->xmlnodes[$v]['type'] != 'open' ) continue;
while( $this->xmlnodes[++$v]['type'] != 'close' && $this->xmlnodes[$v]['tag'] != 'urn:ietf:params:xml:ns:caldav:calendar-home-set' ) {
// printf( "Tag: '%s' = '%s'\n", $this->xmlnodes[$v]['tag'], $this->xmlnodes[$v]['value']);
if ( $this->xmlnodes[$v]['tag'] == 'DAV::href' && isset($this->xmlnodes[$v]['value']) )
$calendar_home[] = rawurldecode($this->xmlnodes[$v]['value']);
if (isset($this->xamltags['urn:ietf:params:xml:ns:caldav:calendar-home-set'])) {
foreach( $this->xmltags['urn:ietf:params:xml:ns:caldav:calendar-home-set'] AS $k => $v ) {
if ( $this->xmlnodes[$v]['type'] != 'open' ) continue;
while( $this->xmlnodes[++$v]['type'] != 'close' && $this->xmlnodes[$v]['tag'] != 'urn:ietf:params:xml:ns:caldav:calendar-home-set' ) {
// printf( "Tag: '%s' = '%s'\n", $this->xmlnodes[$v]['tag'], $this->xmlnodes[$v]['value']);
if ( $this->xmlnodes[$v]['tag'] == 'DAV::href' && isset($this->xmlnodes[$v]['value']) )
$calendar_home[] = rawurldecode($this->xmlnodes[$v]['value']);
}
}
}

Expand Down

0 comments on commit 561c07e

Please sign in to comment.