Esempio n. 1
0
 /**
  * copyNode 
  * 
  * @param Sabre_DAV_INode $source 
  * @param Sabre_DAV_ICollection $destination 
  * @return void
  */
 protected function copyNode(Sabre_DAV_INode $source, Sabre_DAV_ICollection $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_ICollection) {
         $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());
         $destination->updateProperties($props);
     }
 }