/**
  * move folder node
  * 
  * @param Tinebase_Model_Tree_Node_Path $source
  * @param Tinebase_Model_Tree_Node $sourceNode [unused]
  * @param Tinebase_Model_Tree_Node_Path $destination
  * @param boolean $_forceOverwrite
  * @return Tinebase_Model_Tree_Node
  */
 protected function _moveFolderNode($source, $sourceNode, $destination, $_forceOverwrite = FALSE)
 {
     $this->_checkPathACL($source, 'get', FALSE);
     $destinationParentPathRecord = $destination->getParent();
     $destinationNodeName = NULL;
     if ($destination->isToplevelPath()) {
         $this->_moveFolderContainer($source, $destination, $_forceOverwrite);
         $destinationNodeName = $destination->container->getId();
     } else {
         $this->_checkPathACL($destinationParentPathRecord, 'update');
         if ($source->getParent()->flatpath != $destinationParentPathRecord->flatpath) {
             try {
                 $this->_checkIfExists($destination);
             } catch (Filemanager_Exception_NodeExists $fene) {
                 if ($_forceOverwrite && $source->statpath !== $destination->statpath) {
                     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Removing folder node ' . $destination->statpath);
                     }
                     $this->_backend->rmdir($destination->statpath, TRUE);
                 } else {
                     if (!$_forceOverwrite) {
                         throw $fene;
                     }
                 }
             }
         } else {
             if (!$_forceOverwrite) {
                 $this->_checkIfExists($destination);
             }
         }
     }
     // remove source container if it doesn't have the same parent - otherwise a new one will be created
     if ($source->isToplevelPath() && $source->getParent()->getId() !== $destination->getParent()->getId()) {
         Tinebase_Container::getInstance()->deleteContainer($source->container->getId());
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Rename Folder ' . $source->statpath . ' -> ' . $destination->statpath);
     }
     $this->_backend->rename($source->statpath, $destination->statpath);
     $movedNode = $this->_backend->stat($destination->statpath);
     if ($destinationNodeName !== NULL) {
         $movedNode->name = $destinationNodeName;
     }
     return $movedNode;
 }
Ejemplo n.º 2
0
 /**
  * move folder node
  * 
  * @param Tinebase_Model_Tree_Node_Path $source
  * @param Tinebase_Model_Tree_Node $sourceNode [unused]
  * @param Tinebase_Model_Tree_Node_Path $destination
  * @return Tinebase_Model_Tree_Node
  */
 protected function _moveFolderNode($source, $sourceNode, $destination)
 {
     $this->_checkPathACL($source, 'get', FALSE);
     $destinationParentPathRecord = $destination->getParent();
     $destinationNodeName = NULL;
     if (!$destinationParentPathRecord->container) {
         // destination has no container yet (toplevel)
         $this->_moveFolderContainer($source, $destination);
         $destinationNodeName = $destination->container->getId();
     } else {
         $this->_checkPathACL($destinationParentPathRecord, 'update');
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Rename Folder ' . $source->statpath . ' -> ' . $destination->statpath);
     }
     $this->_backend->rename($source->statpath, $destination->statpath);
     $movedNode = $this->_backend->stat($destination->statpath);
     if ($destinationNodeName !== NULL) {
         $movedNode->name = $destinationNodeName;
     }
     return $movedNode;
 }