コード例 #1
0
 /**
  * Handle the PROPPATCH request
  *
  * @param DAV_Resource $resource
  * @return void
  * @throws DAV_Status
  */
 protected function handle($resource)
 {
     $resource->assertLock();
     if (empty($this->props)) {
         throw new DAV_Status(DAV::HTTP_BAD_REQUEST, 'No properties found in request body.');
     }
     $priv_write = $resource->property_priv_write(array_keys($this->props));
     $errors = array();
     foreach ($this->props as $name => $value) {
         try {
             if (@DAV::$PROTECTED_PROPERTIES[$name]) {
                 throw new DAV_Status(DAV::HTTP_FORBIDDEN, DAV::COND_CANNOT_MODIFY_PROTECTED_PROPERTY);
             }
             if (!@$priv_write[$name]) {
                 throw DAV::forbidden();
             }
             $resource->method_PROPPATCH($name, $value);
         } catch (DAV_Status $e) {
             $errors[$name] = $e;
         }
     }
     $response = new DAV_Element_response(DAV::getPath());
     if (empty($errors)) {
         try {
             $resource->storeProperties();
         } catch (DAV_Status $e) {
             foreach (array_keys($this->props) as $propname) {
                 $errors[$propname] = $e;
             }
         }
     }
     if (empty($errors)) {
         foreach (array_keys($this->props) as $propname) {
             $response->setStatus($propname, DAV_Status::$OK);
         }
     } else {
         $failed_dependency = new DAV_Status(DAV::HTTP_FAILED_DEPENDENCY);
         foreach (array_keys($this->props) as $propname) {
             if (!isset($errors[$propname])) {
                 $errors[$propname] = $failed_dependency;
             }
         }
         foreach ($errors as $propname => $status) {
             $response->setStatus($propname, $status);
         }
     }
     DAV_Multistatus::inst()->addResponse($response);
     DAV_Multistatus::inst()->close();
 }
コード例 #2
0
 /**
  * Set or delete a property when a PROPPATCH request was made
  * 
  * @param string $propname the name of the property to be set.
  * @param string $value an XML fragment, or null to unset the property.
  * @see DAV_Resource::method_PROPPATCH()
  */
 public function method_PROPPATCH($propname, $value = null)
 {
     if ($method = @DAV::$ACL_PROPERTIES[$propname] or $this instanceof DAVACL_Principal && ($method = @DAV::$PRINCIPAL_PROPERTIES[$propname])) {
         return call_user_func(array($this, "set_{$method}"), $value);
     }
     return parent::method_PROPPATCH($propname, $value);
 }