public function testMkdir()
 {
     $testPath = $this->_basePath . '/PHPUNIT';
     $this->_controller->mkdir($testPath);
     $this->assertTrue($this->_controller->fileExists($testPath), 'path created by mkdir not found');
     $this->assertTrue($this->_controller->isDir($testPath), 'path created by mkdir is not a directory');
     return $testPath;
 }
 /**
  * setup the test paths
  * 
  * @param string|array $_types
  */
 protected function _setupTestPath($_types)
 {
     $testPaths = array();
     $types = (array) $_types;
     foreach ($types as $type) {
         switch ($type) {
             case Tinebase_Model_Container::TYPE_PERSONAL:
                 $testPaths[] = Tinebase_Model_Container::TYPE_PERSONAL . '/' . Tinebase_Core::getUser()->getId() . '/' . $this->_getPersonalFilemanagerContainer()->getId() . '/unittestdir_personal';
                 break;
             case Tinebase_Model_Container::TYPE_SHARED:
                 $testPaths[] = Tinebase_Model_Container::TYPE_SHARED . '/' . $this->_getSharedContainer()->getId();
                 $testPaths[] = Tinebase_Model_Container::TYPE_SHARED . '/' . $this->_getSharedContainer()->getId() . '/unittestdir_shared';
                 break;
             case Tinebase_Model_Container::TYPE_OTHERUSERS:
                 $personas = Zend_Registry::get('personas');
                 $testPaths[] = Tinebase_Model_Container::TYPE_PERSONAL . '/' . $personas['sclever']->getId() . '/' . $this->_getOtherUserContainer()->getId() . '/unittestdir_other';
                 break;
         }
     }
     foreach ($testPaths as $path) {
         $path = Filemanager_Controller_Node::getInstance()->addBasePath($path);
         $this->_objects['paths'][] = $path;
         $this->_fsController->mkdir($path);
     }
 }
 /**
  * test copying file to existing directory and change name
  */
 public function testCopyFileToExistingDirectoryAndChangeName()
 {
     $sourcePath = $this->testCreateFile();
     $destinationPath = $this->_basePath . '/TESTCOPY2/phpunit2.txt';
     $this->_controller->mkdir($this->_basePath . '/TESTCOPY2');
     $createdNode = $this->_controller->copy($sourcePath, $destinationPath);
     $this->assertNotEquals($this->_controller->stat($sourcePath)->getId(), $createdNode->getId());
     $this->assertEquals(Tinebase_Model_Tree_Node::TYPE_FILE, $createdNode->type);
     $this->assertEquals(basename($destinationPath), $createdNode->name);
     $this->assertTrue($this->_controller->fileExists($this->_basePath . '/TESTCOPY2/' . basename($destinationPath)));
 }
 /**
  * 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;
 }
 /**
  * create node in backend
  * 
  * @param string $_statpath
  * @param type
  * @param string $_tempFileId
  * @return Tinebase_Model_Tree_Node
  */
 protected function _createNodeInBackend($_statpath, $_type, $_tempFileId = NULL)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Creating new path ' . $_statpath . ' of type ' . $_type);
     }
     $node = NULL;
     switch ($_type) {
         case Tinebase_Model_Tree_Node::TYPE_FILE:
             $this->_backend->copyTempfile($_tempFileId, $_statpath);
             break;
         case Tinebase_Model_Tree_Node::TYPE_FOLDER:
             $node = $this->_backend->mkdir($_statpath);
             break;
     }
     return $node ? $node : $this->_backend->stat($_statpath);
 }
Example #6
0
 /**
  * delete node in backend
  * 
  * @param string $_statpath
  * @param type
  * @param string $_tempFileId
  * @return Tinebase_Model_Tree_Node
  */
 protected function _createNodeInBackend($_statpath, $_type, $_tempFileId = NULL)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Creating new path ' . $_statpath . ' of type ' . $_type);
     }
     switch ($_type) {
         case Tinebase_Model_Tree_Node::TYPE_FILE:
             if (!($handle = $this->_backend->fopen($_statpath, 'w'))) {
                 throw new Tinebase_Exception_AccessDenied('Permission denied to create file (filename ' . $_statpath . ')');
             }
             if ($_tempFileId !== NULL) {
                 $this->_copyTempfile($_tempFileId, $handle);
                 $this->_backend->clearStatCache($_statpath);
             }
             $this->_backend->fclose($handle);
             break;
         case Tinebase_Model_Tree_Node::TYPE_FOLDER:
             $this->_backend->mkdir($_statpath);
             break;
     }
     return $this->_backend->stat($_statpath);
 }