Exemplo n.º 1
0
 /**
  * This event is triggered when a PROPPATCH method is executed
  *
  * @param array $mutations
  * @param array $result
  * @param Sabre_DAV_INode $node
  * @return void
  */
 public function updateProperties(&$mutations, &$result, $node)
 {
     if (!$node instanceof Sabre_CardDAV_UserAddressBooks) {
         return true;
     }
     $meCard = '{http://calendarserver.org/ns/}me-card';
     // The only property we care about
     if (!isset($mutations[$meCard])) {
         return true;
     }
     $value = $mutations[$meCard];
     unset($mutations[$meCard]);
     if ($value instanceof Sabre_DAV_Property_IHref) {
         $value = $value->getHref();
         $value = $this->server->calculateUri($value);
     } elseif (!is_null($value)) {
         $result[400][$meCard] = null;
         return false;
     }
     $innerResult = $this->server->updateProperties($node->getOwner(), array('{http://sabredav.org/ns}vcard-url' => $value));
     $closureResult = false;
     foreach ($innerResult as $status => $props) {
         if (is_array($props) && array_key_exists('{http://sabredav.org/ns}vcard-url', $props)) {
             $result[$status][$meCard] = null;
             $closureResult = $status >= 200 && $status < 300;
         }
     }
     return $result;
 }
Exemplo n.º 2
0
 function testUpdatePropertiesEventSuccess()
 {
     $tree = array(new Sabre_DAV_SimpleDirectory('foo'));
     $server = new Sabre_DAV_Server($tree);
     $server->subscribeEvent('updateProperties', array($this, 'updatepropsuccess'));
     $result = $server->updateProperties('foo', array('{DAV:}foo' => 'bar', '{DAV:}foo2' => 'bla'));
     $expected = array('href' => 'foo', '200' => array('{DAV:}foo' => null), '201' => array('{DAV:}foo2' => null));
     $this->assertEquals($expected, $result);
 }
 public function testSetBadNode()
 {
     $tree = array(new Sabre_DAV_SimpleCollection('foo'));
     $server = new Sabre_DAV_Server($tree);
     $server->addPlugin(new Sabre_DAVACL_Plugin());
     $result = $server->updateProperties('foo', array('{DAV:}group-member-set' => new Sabre_DAV_Property_HrefList(array('bar', 'baz')), '{DAV:}bar' => 'baz'));
     $expected = array('href' => 'foo', '403' => array('{DAV:}group-member-set' => null), '424' => array('{DAV:}bar' => null));
     $this->assertEquals($expected, $result);
 }