/** * @depends testContructor * @param DAV_Element_response $obj The response object from previous tests * @return DAV_Element_response The response object for next tests */ public function testSetProperty($obj) { $obj->setProperty('test://test/ empty_prop'); $this->assertSame('<D:response><D:href>/path</D:href><D:propstat><D:prop><ns:empty_prop xmlns:ns="test://test/"/></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat></D:response>', str_replace("\n", '', $obj->toXML()), 'DAV_Element_response: the path set by the constructor should be used in toXML()'); $obj->setProperty('test://test/ prop_with_value', '<![CDATA[Some piece of data]]>'); $this->assertSame('<D:response><D:href>/path</D:href><D:propstat><D:prop><ns:empty_prop xmlns:ns="test://test/"/><ns:prop_with_value xmlns:ns="test://test/"><![CDATA[Some piece of data]]></ns:prop_with_value></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat></D:response>', str_replace("\n", '', $obj->toXML()), 'DAV_Element_response: the path set by the constructor should be used in toXML()'); return $obj; }
/** * Handles a DAV:principal-property-search REPORT request * * @param DAVACL_Principal_Collection $principal_collection The resource to perform the request on * @return void */ private function handle_principal_property_search($principal_collection) { $principals = $principal_collection->report_principal_property_search($this->entity['match']); DAV_Multistatus::inst(); foreach ($principals as $path) { $principal = DAV::$REGISTRY->resource($path); if ($principal && $principal->isVisible()) { $response = new DAV_Element_response($path); foreach ($this->entity['prop'] as $prop) { try { $propval = $principal->prop($prop); $response->setProperty($prop, $propval); } catch (DAV_Status $e) { $response->setStatus($prop, $e); } } DAV_Multistatus::inst()->addResponse($response); } } }
/** * Called by {@link method_PROPFIND()} * @param string $path * @param DAV_Resource $resource * @param array $props */ private function handle3($resource, $props) { $propprivs = $resource->property_priv_read($props); $response = new DAV_Element_response($resource->path); foreach ($props as $prop) { if (array_key_exists($prop, $propprivs) && !$propprivs[$prop]) { $response->setStatus($prop, DAV::forbidden()); } else { try { $value = $resource->prop($prop); if (!is_null($value)) { $response->setProperty($prop, $value); } else { $response->setStatus($prop, DAV_Status::$NOT_FOUND); } } catch (DAV_Status $e) { $response->setStatus($prop, $e); } } } DAV_Multistatus::inst()->addResponse($response); }