Exemplo n.º 1
0
 protected function PROPPATCHWrapper()
 {
     /** @var CDavRequest $request */
     $request = $this->request;
     $response = $this->response;
     if ($this->CheckLockStatus($request->GetPath())) {
         try {
             $requestDocument = $request->GetXmlDocument();
         } catch (CDavXMLParsingException $e) {
             $response->GenerateError("400 Error", $e->getMessage());
             return;
         } catch (Exception $e) {
             $response->SetHttpStatus("400 Error");
             return;
         }
         $arResources = array();
         $responseDescr = $this->PROPPATCH($arResources);
         $response->SetHttpStatus("207 Multi-Status");
         $response->AddHeader('Content-Type: text/xml; charset="utf-8"');
         $response->AddLine("<D:multistatus xmlns:D=\"DAV:\">");
         foreach ($arResources as $resource) {
             /** @var CDavResource $resource */
             $arResourceProps = $resource->GetProperties();
             $xmlnsHash = array('DAV:' => 'D');
             $xmlnsDefs = 'xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"';
             $response->AddLine(" <D:response %s>", $xmlnsDefs);
             $href = $this->UrlEncode(rtrim($request->GetBaseUri(), '/') . "/" . ltrim($resource->GetPath(), '/'));
             $response->AddLine("  <D:href>%s</D:href>", $href);
             foreach ($arResourceProps as &$prop) {
                 $response->AddLine("   <D:propstat>");
                 $response->AddLine("    <D:prop>");
                 CDavResource::RenderProperty($prop, $xmlnsHash, $response, $request);
                 $response->AddLine("    </D:prop>");
                 $response->AddLine("    <D:status>HTTP/1.1 " . $prop['status'] . "</D:status>");
                 $response->AddLine("   </D:propstat>");
             }
             if ($responseDescr) {
                 echo "\t<D:responsedescription>" . $response->Encode(htmlspecialcharsbx($responseDescr)) . "</D:responsedescription>\n";
             }
             $response->AddLine(" </D:response>");
         }
         $response->AddLine("</D:multistatus>");
     } else {
         $response->SetHttpStatus('423 Locked');
     }
 }