Ejemplo n.º 1
0
 function afterCreateFile($path, \Sabre\DAV\ICollection $parent)
 {
     $sFileName = basename($path);
     $node = $parent->getChild($sFileName);
     if ($node instanceof \Sabre\CardDAV\ICard) {
         $iUserId = $this->server->getUser();
         if (isset($iUserId)) {
             $oContact = new \CContact();
             $oContact->InitFromVCardStr($iUserId, $node->get());
             $oContact->IdContactStr = $sFileName;
             $this->oApiContactsManager->createContact($oContact);
         }
     }
 }
Ejemplo n.º 2
0
 function afterCreateFile($path, \Sabre\DAV\ICollection $parent)
 {
     if ('sabredav' !== \CApi::GetManager()->GetStorageByType('contacts')) {
         $sFileName = basename($path);
         $node = $parent->getChild($sFileName);
         if ($node instanceof \Sabre\CardDAV\ICard) {
             $oAccount = $this->server->getAccount();
             if (isset($oAccount)) {
                 $oContact = new \CContact();
                 $oContact->InitFromVCardStr($oAccount->IdUser, $node->get());
                 $this->oApiContactsManager->CreateContact($oContact);
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * copyNode
  *
  * @param INode $source
  * @param ICollection $destinationParent
  * @param string $destinationName
  * @return void
  */
 protected function copyNode(INode $source, ICollection $destinationParent, $destinationName = null)
 {
     if (!$destinationName) {
         $destinationName = $source->getName();
     }
     if ($source instanceof 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 ICollection) {
         $destinationParent->createDirectory($destinationName);
         $destination = $destinationParent->getChild($destinationName);
         foreach ($source->getChildren() as $child) {
             $this->copyNode($child, $destination);
         }
     }
     if ($source instanceof IProperties && $destination instanceof IProperties) {
         $props = $source->getProperties([]);
         $propPatch = new PropPatch($props);
         $destination->propPatch($propPatch);
         $propPatch->commit();
     }
 }
Ejemplo n.º 4
0
 public function afterCreateFile($uri, \Sabre\DAV\ICollection $parent)
 {
     $node = $parent->getChild(Backend\PDO::getEventUri($uri));
     $this->updateReminder($uri, $node->get(), $this->getUser());
 }