/**
  * beforeGetProperties
  *
  * This method handler is invoked before any after properties for a
  * resource are fetched. This allows us to add in any CalDAV specific 
  * properties. 
  * 
  * @param string $path
  * @param Sabre_DAV_INode $node
  * @param array $requestedProperties
  * @param array $returnedProperties
  * @return void
  */
 public function beforeGetProperties($path, Sabre_DAV_INode $node, &$requestedProperties, &$returnedProperties)
 {
     if ($node instanceof Sabre_DAVACL_IPrincipal) {
         // schedule-inbox-URL property
         $scheduleInboxURL = '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}schedule-inbox-URL';
         if (in_array($scheduleInboxURL, $requestedProperties)) {
             $principalId = $node->getName();
             $properties = $node->getProperties(array($scheduleInboxURL));
             if (isset($properties[$scheduleInboxURL])) {
                 $calendarPath = Sabre_CalDAV_Plugin::CALENDAR_ROOT . '/' . $principalId . '/' . $properties[$scheduleInboxURL];
                 unset($requestedProperties[$scheduleInboxURL]);
                 $returnedProperties[200][$scheduleInboxURL] = new Sabre_DAV_Property_Href($calendarPath);
             }
         }
         // schedule-outbox-URL property
         $scheduleOutboxURL = '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}schedule-outbox-URL';
         if (in_array($scheduleOutboxURL, $requestedProperties)) {
             $principalId = $node->getName();
             $properties = $node->getProperties(array($scheduleOutboxURL));
             if (isset($properties[$scheduleOutboxURL])) {
                 $calendarPath = Sabre_CalDAV_Plugin::CALENDAR_ROOT . '/' . $principalId . '/' . $properties[$scheduleOutboxURL];
                 unset($requestedProperties[$scheduleOutboxURL]);
                 $returnedProperties[200][$scheduleOutboxURL] = new Sabre_DAV_Property_Href($calendarPath);
             }
         }
     }
 }
 /**
  * copyNode 
  * 
  * @param Sabre_DAV_INode $source 
  * @param Sabre_DAV_IDirectory $destination 
  * @return void
  */
 protected function copyNode(Sabre_DAV_INode $source, Sabre_DAV_IDirectory $destinationParent, $destinationName = null)
 {
     if (!$destinationName) {
         $destinationName = $source->getName();
     }
     if ($source instanceof Sabre_DAV_IFile) {
         $data = $source->get();
         // If the body was a string, we need to convert it to a stream
         if (is_string($data)) {
             $stream = fopen('php://temp', 'r+');
             fwrite($stream, $data);
             rewind($stream);
             $data = $stream;
         }
         $destinationParent->createFile($destinationName, $data);
         $destination = $destinationParent->getChild($destinationName);
     } elseif ($source instanceof Sabre_DAV_IDirectory) {
         $destinationParent->createDirectory($destinationName);
         $destination = $destinationParent->getChild($destinationName);
         foreach ($source->getChildren() as $child) {
             $this->copyNode($child, $destination);
         }
     }
     if ($source instanceof Sabre_DAV_IProperties && $destination instanceof Sabre_DAV_IProperties) {
         $props = $source->getProperties(array());
         $newProps = array();
         foreach ($props as $k => $v) {
             $newProps[] = array(Sabre_DAV_Server::PROP_SET, $k, $v);
         }
         $destination->updateProperties($newProps);
     }
 }