public function testRmdir() { $testPath = $this->testMkdir(); $result = $this->_controller->rmdir($testPath); $this->assertTrue($result, 'wrong result for rmdir command'); $this->assertFalse($this->_controller->fileExists($testPath), 'failed to delete directory'); }
/** * 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; } }
/** * get path for record attachments * * @param Tinebase_Record_Abstract $record * @param boolean $createDirIfNotExists * @throws Tinebase_Exception_InvalidArgument * @return string */ public function getRecordAttachmentPath(Tinebase_Record_Abstract $record, $createDirIfNotExists = FALSE) { if (!$record->getId()) { throw new Tinebase_Exception_InvalidArgument('record needs an identifier'); } $parentPath = $this->_fsController->getApplicationBasePath($record->getApplication(), Tinebase_FileSystem::FOLDER_TYPE_RECORDS); $recordPath = $parentPath . '/' . get_class($record) . '/' . $record->getId(); if ($createDirIfNotExists && !$this->_fsController->fileExists($recordPath)) { $this->_fsController->mkdir($recordPath); } return $recordPath; }
/** * copy or move an array of nodes identified by their path * * @param array $_sourceFilenames array->multiple * @param string|array $_destinationFilenames string->singlefile OR directory, array->multiple files * @param string $_action copy|move * @param boolean $_forceOverwrite * @return Tinebase_Record_RecordSet of Tinebase_Model_Tree_Node */ protected function _copyOrMoveNodes($_sourceFilenames, $_destinationFilenames, $_action, $_forceOverwrite = FALSE) { $result = new Tinebase_Record_RecordSet('Tinebase_Model_Tree_Node'); $nodeExistsException = NULL; foreach ($_sourceFilenames as $idx => $source) { $sourcePathRecord = Tinebase_Model_Tree_Node_Path::createFromPath($this->addBasePath($source)); $destinationPathRecord = $this->_getDestinationPath($_destinationFilenames, $idx, $sourcePathRecord); if ($this->_backend->fileExists($destinationPathRecord->statpath) && $sourcePathRecord->flatpath == $destinationPathRecord->flatpath) { throw new Filemanager_Exception_DestinationIsSameNode(); } // test if destination is subfolder of source $dest = explode('/', $destinationPathRecord->statpath); $source = explode('/', $sourcePathRecord->statpath); $isSub = TRUE; for ($i = 0; $i < count($source); $i++) { if (!isset($dest[$i])) { break; } if ($source[$i] != $dest[$i]) { $isSub = FALSE; } } if ($isSub) { throw new Filemanager_Exception_DestinationIsOwnChild(); } try { if ($_action === 'move') { $node = $this->_moveNode($sourcePathRecord, $destinationPathRecord, $_forceOverwrite); } else { if ($_action === 'copy') { $node = $this->_copyNode($sourcePathRecord, $destinationPathRecord, $_forceOverwrite); } } if ($node instanceof Tinebase_Record_Abstract) { $result->addRecord($node); } else { if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) { Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Could not copy or move node to destination ' . $destinationPathRecord->flatpath); } } } catch (Filemanager_Exception_NodeExists $fene) { $nodeExistsException = $this->_handleNodeExistsException($fene, $nodeExistsException); } } $this->resolveContainerAndAddPath($result, $destinationPathRecord->getParent()); if ($nodeExistsException) { // @todo add correctly moved/copied files here? throw $nodeExistsException; } return $result; }
/** * testDeleteLeadWithAttachment * * @see 0005024: allow to attach external files to records */ public function testDeleteLeadWithAttachment() { $lead = $this->testCreateLeadWithAttachment(); $this->_instance->deleteLeads(array($lead['id'])); $this->assertFalse($this->_fsController->fileExists($this->_objects['paths'][0])); }