From e5f5f8fc3bfca77693c62f194689607a3a032ffb Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Sun, 26 Dec 2010 17:44:16 +1300 Subject: [PATCH] New url() and GetProperty() methods matching DAVResource. Signed-off-by: Andrew McMillan --- inc/CalDAVPrincipal.php | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/inc/CalDAVPrincipal.php b/inc/CalDAVPrincipal.php index c9d37662..19184546 100644 --- a/inc/CalDAVPrincipal.php +++ b/inc/CalDAVPrincipal.php @@ -27,7 +27,7 @@ class CalDAVPrincipal /** * @var The home URL of the principal */ - var $url; + private $url; /** * @var Identifies whether this principal exists in the DB yet @@ -435,6 +435,38 @@ class CalDAVPrincipal } + /** + * Return an arbitrary property + * @return string The name of the arbitrary property + */ + function GetProperty( $property_id ) { + + switch( $property_id ) { + case 'DAV::resource-id': + if ( $this->exists && $this->principal_id > 0 ) + ConstructURL('/.resources/'.$this->principal_id); + else + return null; + break; + } + + if ( isset($this->{$property_id}) ) { + if ( ! is_object($this->{$property_id}) ) return $this->{$property_id}; + return clone($this->{$property_id}); + } + return null; + } + + + /** + * Return the URL for this principal + * @return string The principal-URL, or null if they don't exist + */ + function url() { + return ($this->exists ? $this->url : null ); + } + + /** * Get the calendar_home_set, as lazily as possible */