/** * move folder container * * @param Tinebase_Model_Tree_Node_Path $source * @param Tinebase_Model_Tree_Node_Path $destination * @param boolean $forceOverwrite * @return Tinebase_Model_Tree_Node */ protected function _moveFolderContainer($source, $destination, $forceOverwrite = FALSE) { if ($source->isToplevelPath()) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Moving container ' . $source->container->name . ' to ' . $destination->flatpath); } $this->_checkACLContainer($source->container, 'update'); $container = $source->container; if ($container->name !== $destination->name) { try { $existingContainer = Tinebase_Container::getInstance()->getContainerByName($this->_applicationName, $destination->name, $destination->containerType, Tinebase_Core::getUser()); if (!$forceOverwrite) { $fene = new Filemanager_Exception_NodeExists('container exists'); $fene->addExistingNodeInfo($this->_backend->stat($destination->statpath)); throw $fene; } else { if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Removing existing folder node and container ' . $destination->flatpath); } $this->_backend->rmdir($destination->statpath, TRUE); } } catch (Tinebase_Exception_NotFound $tenf) { // ok } $container->name = $destination->name; $container = Tinebase_Container::getInstance()->update($container); } } else { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Creating container ' . $destination->name); } $container = $this->_createContainer($destination->name, $destination->containerType); } $destination->setContainer($container); }
/** * check file existance * * @param Tinebase_Model_Tree_Node_Path $_path * @param Tinebase_Model_Tree_Node $_node * @throws Filemanager_Exception_NodeExists */ protected function _checkIfExists(Tinebase_Model_Tree_Node_Path $_path, $_node = NULL) { if ($this->_backend->fileExists($_path->statpath)) { $existsException = new Filemanager_Exception_NodeExists(); $existsException->addExistingNodeInfo($_node !== NULL ? $_node : $this->_backend->stat($_path->statpath)); throw $existsException; } }