principalUri = $principalUri; $this->principalProperties = $principalProperties; } /** * Returns the name of the element * * @return void */ public function getName() { list(, $name) = Sabre_DAV_URLUtil::splitPath($this->principalUri); return $name; } /** * Returns the name of the user * * @return void */ public function getDisplayName() { if (isset($this->principalProperties['{DAV:}displayname'])) { return $this->principalProperties['{DAV:}displayname']; } else { return $this->getName(); } } /** * Returns a list of properties * * @param array $requestedProperties * @return void */ public function getProperties($requestedProperties) { if (!count($requestedProperties)) { // If all properties were requested // we will only returns properties from this list $requestedProperties = array( '{DAV:}resourcetype', '{DAV:}displayname', ); } // We need to always return the resourcetype // This is a bug in the core server, but it is easier to do it this way for now $newProperties = array( '{DAV:}resourcetype' => new Sabre_DAV_Property_ResourceType('{DAV:}principal') ); foreach($requestedProperties as $propName) switch($propName) { case '{DAV:}alternate-URI-set' : if (isset($this->principalProperties['{http://sabredav.org/ns}email-address'])) { $href = 'mailto:' . $this->principalProperties['{http://sabredav.org/ns}email-address']; $newProperties[$propName] = new Sabre_DAV_Property_Href($href); } else { $newProperties[$propName] = null; } break; case '{DAV:}group-member-set' : case '{DAV:}group-membership' : $newProperties[$propName] = null; break; case '{DAV:}principal-URL' : $newProperties[$propName] = new Sabre_DAV_Property_Href($this->principalUri); break; case '{DAV:}displayname' : $newProperties[$propName] = $this->getDisplayName(); break; default : if (isset($this->principalProperties[$propName])) { $newProperties[$propName] = $this->principalProperties[$propName]; } break; } return $newProperties; } /** * Updates this principals properties. * * Currently this is not supported * * @param array $properties * @see Sabre_DAV_IProperties::updateProperties * @return bool|array */ public function updateProperties($properties) { return false; } }