/**
  * 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);
     }
 }
示例#2
0
 /**
  * the singleton pattern
  *
  * @return Tinebase_FileSystem
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new Tinebase_FileSystem();
     }
     return self::$_instance;
 }
 public function testGetEtag()
 {
     $this->testCreateFile();
     $node = $this->_controller->stat($this->_basePath . '/PHPUNIT/phpunit.txt');
     $etag = $this->_controller->getETag($this->_basePath . '/PHPUNIT/phpunit.txt');
     $this->assertEquals($node->hash, $etag);
 }
 /**
  * tear down tests
  */
 protected function tearDown()
 {
     parent::tearDown();
     Tinebase_FileSystem::getInstance()->clearStatCache();
     Tinebase_FileSystem::getInstance()->clearDeletedFilesFromFilesystem();
     Tinebase_Cache_PerRequest::getInstance()->reset();
 }
示例#5
0
 /**
  * testDeleteDirectoryNodes
  */
 public function testDeleteDirectoryNodes()
 {
     $dirpaths = $this->testCreateDirectoryNodesInShared();
     $result = $this->_json->deleteNodes($dirpaths);
     // check if node is deleted
     $this->setExpectedException('Tinebase_Exception_NotFound');
     $node = $this->_fsController->stat(Filemanager_Controller_Node::getInstance()->addBasePath($dirpaths[0]));
 }
示例#6
0
 /**
  * Renames the node
  * 
  * @throws Sabre_DAV_Exception_Forbidden
  * @param string $name The new name
  * @return void
  */
 public function setName($name)
 {
     self::checkForbiddenFile($name);
     if (!Tinebase_Core::getUser()->hasGrant($this->_getContainer(), Tinebase_Model_Grants::GRANT_EDIT)) {
         throw new Sabre_DAV_Exception_Forbidden('Forbidden to rename file: ' . $this->_path);
     }
     list($dirname, $basename) = Sabre_DAV_URLUtil::splitPath($this->_path);
     Tinebase_FileSystem::getInstance()->rename($this->_path, $dirname . '/' . $name);
 }
 /**
  * create reporting templates folder
  */
 public static function createReportTemplatesFolder()
 {
     $templateContainer = Tinebase_Container::getInstance()->createSystemContainer('HumanResources', 'Report Templates', HumanResources_Config::REPORT_TEMPLATES_CONTAINER_ID);
     try {
         Tinebase_FileSystem::getInstance()->createContainerNode($templateContainer);
     } catch (Tinebase_Exception_Backend $teb) {
         if (Tinebase_Core::isLogLevel(Zend_Log::ERR)) {
             Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' Could not create template folder: ' . $teb);
         }
     }
 }
 /**
  * create vacation templates folder
  */
 public static function createVacationTemplatesFolder()
 {
     $templateContainer = Tinebase_Container::getInstance()->createSystemContainer('Expressomail', 'Vacation Templates', Expressomail_Config::VACATION_TEMPLATES_CONTAINER_ID);
     try {
         Tinebase_FileSystem::getInstance()->createContainerNode($templateContainer);
     } catch (Tinebase_Exception_Backend $teb) {
         if (Tinebase_Core::isLogLevel(Zend_Log::ERR)) {
             Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' Could not create vacation template folder: ' . $teb);
         }
     }
 }
 /**
  * Deletes a set of records.
  *
  * If one of the records could not be deleted, no record is deleted
  *
  * @param   array array of record identifiers
  * @return  Tinebase_Record_RecordSet
  */
 public function delete($_ids)
 {
     $nodes = $this->getMultiple($_ids);
     foreach ($nodes as $node) {
         if ($this->_checkACLContainer($this->_backend->getNodeContainer($node->getId()), 'delete')) {
             $this->_backend->deleteFileNode($node);
         } else {
             $nodes->removeRecord($node);
         }
     }
     return $nodes;
 }
 /**
  * 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;
 }
 /**
  * Creates a new subdirectory
  *
  * @param  string  $name  name of the new subdirectory
  * @throws Sabre\DAV\Exception\Forbidden
  * @return Tinebase_Model_Container
  */
 public function createDirectory($name)
 {
     $container = parent::createDirectory($name);
     $path = '/' . $this->_getApplication()->getId() . '/folders/' . $container->type . '/';
     if ($container->type == Tinebase_Model_Container::TYPE_PERSONAL) {
         $path .= Tinebase_Core::getUser()->accountId . '/';
     }
     $path .= $container->getId();
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' create directory: ' . $path);
     }
     Tinebase_FileSystem::getInstance()->mkdir($path);
 }
 /**
  * create vacation templates folder
  */
 public static function createVacationTemplatesFolder()
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Creating vacation template in vfs ...');
     }
     $templateContainer = Tinebase_Container::getInstance()->createSystemContainer('Felamimail', 'Vacation Templates', Felamimail_Config::VACATION_TEMPLATES_CONTAINER_ID, null, 'Tinebase_Model_Tree_Node');
     try {
         Tinebase_FileSystem::getInstance()->createContainerNode($templateContainer);
     } catch (Tinebase_Exception_Backend $teb) {
         if (Tinebase_Core::isLogLevel(Zend_Log::ERR)) {
             Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' Could not create vacation template folder: ' . $teb);
         }
     }
 }
示例#13
0
 public function put($data)
 {
     if (!Tinebase_Core::getUser()->hasGrant($this->_getContainer(), Tinebase_Model_Grants::GRANT_EDIT)) {
         throw new Sabre_DAV_Exception_Forbidden('Forbidden to edit file: ' . $this->_path);
     }
     $handle = Tinebase_FileSystem::getInstance()->fopen($this->_path, 'w');
     if (!is_resource($handle)) {
         throw new Sabre_DAV_Exception_Forbidden('Permission denied to create file:' . $this->_path);
     }
     if (is_resource($data)) {
         stream_copy_to_stream($data, $handle);
     }
     Tinebase_FileSystem::getInstance()->fclose($handle);
 }
示例#14
0
 /**
  * delete node in backend
  * 
  * @param Tinebase_Model_Tree_Node_Path $_path
  * @return boolean
  */
 protected function _deleteNodeInBackend(Tinebase_Model_Tree_Node_Path $_path)
 {
     $success = FALSE;
     $node = $this->_backend->stat($_path->statpath);
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Removing path ' . $_path->flatpath . ' of type ' . $node->type);
     }
     switch ($node->type) {
         case Tinebase_Model_Tree_Node::TYPE_FILE:
             $success = $this->_backend->unlink($_path->statpath);
             break;
         case Tinebase_Model_Tree_Node::TYPE_FOLDER:
             $success = $this->_backend->rmdir($_path->statpath, TRUE);
             break;
     }
     return $success;
 }
 /**
  * import one purchase imvoice file
  * 
  * a new invoice with default data will be created and the invoice file will be attached
  * 
  * @param string $name  name of the invoice
  * @param resource $data  binary data of the invoice (aka a pdf)
  * @throws Sabre\DAV\Exception\Forbidden
  * @return Sales_Model_PurchaseInvoice
  */
 public function importPurchaseInvoice($name, $data)
 {
     // create invoice
     $purchaseInvoice = new Sales_Model_PurchaseInvoice(array('number' => '', 'description' => '', 'date' => Tinebase_DateTime::now(), 'discount' => 0, 'due_in' => 0, 'due_at' => Tinebase_DateTime::now(), 'price_gross' => 0, 'price_net' => 0, 'price_tax' => 0, 'sales_tax' => 0));
     $invoice = $this->create($purchaseInvoice);
     // attach invoice file (aka a pdf)
     $attachmentPath = Tinebase_FileSystem_RecordAttachments::getInstance()->getRecordAttachmentPath($purchaseInvoice, TRUE);
     $handle = Tinebase_FileSystem::getInstance()->fopen($attachmentPath . '/' . $name, 'w');
     if (!is_resource($handle)) {
         throw new Sabre\DAV\Exception\Forbidden('Permission denied to create file:' . $attachmentPath . '/' . $name);
     }
     if (is_resource($data)) {
         stream_copy_to_stream($data, $handle);
     }
     Tinebase_FileSystem::getInstance()->fclose($handle);
     return $this->get($purchaseInvoice);
 }
 public function put($data)
 {
     if (!Tinebase_Core::getUser()->hasGrant($this->_getContainer(), Tinebase_Model_Grants::GRANT_EDIT)) {
         throw new Sabre\DAV\Exception\Forbidden('Forbidden to edit file: ' . $this->_path);
     }
     $handle = Tinebase_FileSystem::getInstance()->fopen($this->_path, 'w');
     if (!is_resource($handle)) {
         throw new Sabre\DAV\Exception\Forbidden('Permission denied to create file:' . $this->_path);
     }
     if (is_resource($data)) {
         stream_copy_to_stream($data, $handle);
     }
     // save file object
     Tinebase_FileSystem::getInstance()->fclose($handle);
     // refetch data
     $this->_node = Tinebase_FileSystem::getInstance()->stat($this->_path);
     return $this->getETag();
 }
 /**
  * Handles POST requests
  *
  * @param string $method
  * @param string $uri
  * @return bool
  */
 public function httpPOSTHandler($method, $uri)
 {
     if ($method != 'POST') {
         return;
     }
     $getVars = array();
     parse_str($this->server->httpRequest->getQueryString(), $getVars);
     if (!isset($getVars['action']) || !in_array($getVars['action'], array('attachment-add', 'attachment-update', 'attachment-remove'))) {
         return;
     }
     try {
         $node = $this->server->tree->getNodeForPath($uri);
     } catch (DAV\Exception\NotFound $e) {
         // We're simply stopping when the file isn't found to not interfere
         // with other plugins.
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->DEBUG(__METHOD__ . '::' . __LINE__ . " did not find node -> stopping");
         }
         return;
     }
     if (!$node instanceof Calendar_Frontend_WebDAV_Event) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->DEBUG(__METHOD__ . '::' . __LINE__ . " node is no event -> stopping ");
         }
         return;
     }
     $name = 'NO NAME';
     $disposition = $this->server->httpRequest->getHeader('Content-Disposition');
     $contentType = $this->server->httpRequest->getHeader('Content-Type');
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->DEBUG(__METHOD__ . '::' . __LINE__ . " disposition/contentType: " . $disposition . ' / ' . $contentType);
     }
     $managedId = isset($getVars['managed-id']) ? $getVars['managed-id'] : NULL;
     $rid = $this->getRecurranceIds($getVars);
     list($contentType) = explode(';', $contentType);
     if (preg_match("/filename\\*=utf-8''(.*)/", $disposition, $matches)) {
         // handle utf-8 dispositions (like this: filename=\"Reservierungsbesta?tigung _ OTTER.txt\";filename*=utf-8''Reservierungsbesta%CC%88tigung%20_%20OTTER.txt)
         $name = $matches[1];
     } else {
         if (preg_match('/filename=(.*)[ ;]{0,1}/', $disposition, $matches)) {
             $name = $matches[1];
         }
     }
     $name = trim($name, " \t\n\r\v\"'");
     // NOTE inputstream can not be rewinded
     $inputStream = fopen('php://temp', 'r+');
     stream_copy_to_stream($this->server->httpRequest->getBody(), $inputStream);
     rewind($inputStream);
     list($attachmentId) = Tinebase_FileSystem::getInstance()->createFileBlob($inputStream);
     switch ($getVars['action']) {
         case 'attachment-add':
             $attachment = new Tinebase_Model_Tree_Node(array('name' => rawurldecode($name), 'type' => Tinebase_Model_Tree_Node::TYPE_FILE, 'contenttype' => $contentType, 'hash' => $attachmentId), true);
             $this->_iterateByRid($node->getRecord(), $rid, function ($event) use($name, $attachment) {
                 $existingAttachment = $event->attachments->filter('name', $name)->getFirstRecord();
                 if ($existingAttachment) {
                     // yes, ... iCal does this :-(
                     $existingAttachment->hash = $attachment->hash;
                 } else {
                     $event->attachments->addRecord(clone $attachment);
                 }
             });
             $node->update($node->getRecord());
             break;
         case 'attachment-update':
             $eventsToUpdate = array();
             // NOTE: iterate base & all exceptions @see 3.5.2c of spec
             $this->_iterateByRid($node->getRecord(), NULL, function ($event) use($managedId, $attachmentId, &$eventsToUpdate) {
                 $attachmentToUpdate = $event->attachments->filter('hash', $managedId)->getFirstRecord();
                 if ($attachmentToUpdate) {
                     $eventsToUpdate[] = $event;
                     $attachmentToUpdate->hash = $attachmentId;
                 }
             });
             if (!$eventsToUpdate) {
                 throw new Sabre\DAV\Exception\PreconditionFailed("no attachment with id {$managedId} found");
             }
             $node->update($node->getRecord());
             break;
         case 'attachment-remove':
             $eventsToUpdate = array();
             $this->_iterateByRid($node->getRecord(), $rid, function ($event) use($managedId, &$eventsToUpdate) {
                 $attachmentToDelete = $event->attachments->filter('hash', $managedId)->getFirstRecord();
                 if ($attachmentToDelete) {
                     $eventsToUpdate[] = $event;
                     $event->attachments->removeRecord($attachmentToDelete);
                 }
             });
             if (!$eventsToUpdate) {
                 throw new Sabre\DAV\Exception\PreconditionFailed("no attachment with id {$managedId} found");
             }
             $node->update($node->getRecord());
             break;
     }
     //         @TODO respect Prefer header
     $this->server->httpResponse->setHeader('Content-Type', 'text/calendar; charset="utf-8"');
     $this->server->httpResponse->setHeader('Content-Length', $node->getSize());
     $this->server->httpResponse->setHeader('ETag', $node->getETag());
     if ($getVars['action'] != 'attachment-remove') {
         $this->server->httpResponse->setHeader('Cal-Managed-ID', $attachmentId);
     }
     // only at create!
     $this->server->httpResponse->sendStatus(201);
     $this->server->httpResponse->sendBody($node->get());
     return false;
 }
 /**
  * get available templates by containerId
  *
  * @param integer $containerId
  * @return array
  */
 public function getTemplates($containerId = NULL)
 {
     if (!$containerId) {
         return array('totalcount' => 0, 'results' => array());
     }
     try {
         $nodes = Tinebase_FileSystem::getInstance()->getNodesByContainer($containerId);
         $result = $this->_multipleRecordsToJson($nodes);
     } catch (Exception $e) {
         if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Could not get template files: ' . $e);
         }
         $result = array();
     }
     return array('totalcount' => count($result), 'results' => $result);
 }
 /**
  * Tears down the fixture
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     Tinebase_TransactionManager::getInstance()->rollBack();
     Tinebase_FileSystem::getInstance()->clearStatCache();
     Tinebase_FileSystem::getInstance()->clearDeletedFiles();
 }
 /**
  * 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]));
 }
 /**
  * clears deleted files from filesystem + database
  * @return boolean
  */
 public function clearDeletedFiles()
 {
     if (!$this->_checkAdminRight()) {
         return FALSE;
     }
     $this->_addOutputLogWriter();
     Tinebase_FileSystem::getInstance()->clearDeletedFiles();
     return 0;
 }
 /**
  * download file attachment
  * 
  * @param string $nodeId
  * @param string $recordId
  * @param string $modelName
  */
 public function downloadRecordAttachment($nodeId, $recordId, $modelName)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Downloading attachment of ' . $modelName . ' record with id ' . $recordId);
     }
     $recordController = Tinebase_Core::getApplicationInstance($modelName);
     $record = $recordController->get($recordId);
     $node = Tinebase_FileSystem::getInstance()->get($nodeId);
     $path = Tinebase_Model_Tree_Node_Path::STREAMWRAPPERPREFIX . Tinebase_FileSystem_RecordAttachments::getInstance()->getRecordAttachmentPath($record) . '/' . $node->name;
     $this->_downloadFileNode($node, $path);
     exit;
 }
 /**
  * url_stat
  * 
  * @param string $_path
  * @param array $_flags
  * @return boolean|array
  */
 public function url_stat($_path, $_flags)
 {
     $statLink = (bool) ($_flags & STREAM_URL_STAT_LINK);
     $quiet = (bool) ($_flags & STREAM_URL_STAT_QUIET);
     try {
         $node = Tinebase_FileSystem::getInstance()->stat(substr($_path, 9));
     } catch (Tinebase_Exception_InvalidArgument $teia) {
         if (!$quiet) {
             trigger_error($teia->getMessage(), E_USER_WARNING);
         }
         return false;
     } catch (Tinebase_Exception_NotFound $tenf) {
         if (!$quiet) {
             trigger_error($tenf->getMessage(), E_USER_WARNING);
         }
         return false;
     }
     $timestamp = $node->last_modified_time instanceof Tinebase_DateTime ? $node->last_modified_time->getTimestamp() : $node->creation_time->getTimestamp();
     $mode = 0;
     // set node type (directory, file, link)
     $mode = $node->type == Tinebase_Model_Tree_FileObject::TYPE_FOLDER ? $mode | 040000 : $mode | 0100000;
     $stat = array(0 => 0, 1 => crc32($node->object_id), 2 => $mode, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => $node->size, 8 => $timestamp, 9 => $timestamp, 10 => $node->creation_time->getTimestamp(), 11 => -1, 12 => -1, 'dev' => 0, 'ino' => crc32($node->object_id), 'mode' => $mode, 'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'size' => $node->size, 'atime' => $timestamp, 'mtime' => $timestamp, 'ctime' => $node->creation_time->getTimestamp(), 'blksize' => -1, 'blocks' => -1);
     return $stat;
 }
 /**
  * validate node/container existance
  * 
  * @throws Tinebase_Exception_NotFound
  */
 public function validateExistance()
 {
     if (!$this->containerType || !$this->statpath) {
         $this->_parsePath();
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Validate statpath: ' . $this->statpath);
     }
     $pathParts = $this->_getPathParts();
     if (!$this->container) {
         $containerPart = $this->containerType === Tinebase_Model_Container::TYPE_PERSONAL ? 5 : 4;
         if (count($pathParts) >= $containerPart) {
             throw new Tinebase_Exception_NotFound('Container not found');
         }
     } else {
         if (!Tinebase_FileSystem::getInstance()->fileExists($this->statpath)) {
             throw new Tinebase_Exception_NotFound('Node not found');
         }
     }
 }
 /**
  * return etag
  * 
  * @return string
  */
 public function getETag()
 {
     return '"' . Tinebase_FileSystem::getInstance()->stat($this->_path)->hash . '"';
 }
示例#26
0
 /**
  * Deleted the current node
  * 
  * @todo   use filesystem controller to delete directories recursive
  * @throws Sabre_DAV_Exception_Forbidden
  * @return void 
  */
 public function delete()
 {
     if (!Tinebase_Core::getUser()->hasGrant($this->_getContainer(), Tinebase_Model_Grants::GRANT_DELETE)) {
         throw new Sabre_DAV_Exception_Forbidden('Forbidden to delete directory: ' . $this->_path);
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' delete directory: ' . $this->_path);
     }
     foreach ($this->getChildren() as $child) {
         $child->delete();
     }
     if (!Tinebase_FileSystem::getInstance()->rmdir($this->_path)) {
         throw new Sabre_DAV_Exception_Forbidden('Permission denied to delete node');
     }
 }
 /**
  * gets image info and data
  * 
  * @param   string $application application which manages the image
  * @param   string $identifier identifier of image/record
  * @param   string $location optional additional identifier
  * @return  Tinebase_Model_Image
  * @throws  Tinebase_Exception_NotFound
  * @throws  Tinebase_Exception_UnexpectedValue
  */
 public function getImage($application, $identifier, $location = '')
 {
     if ($location === 'vfs') {
         $node = Tinebase_FileSystem::getInstance()->get($identifier);
         $path = Tinebase_Model_Tree_Node_Path::STREAMWRAPPERPREFIX . Tinebase_FileSystem::getInstance()->getPathOfNode($node, true);
         $image = Tinebase_ImageHelper::getImageInfoFromBlob(file_get_contents($path));
     } else {
         if ($application == 'Tinebase' && $location == 'tempFile') {
             $tempFile = Tinebase_TempFile::getInstance()->getTempFile($identifier);
             $image = Tinebase_ImageHelper::getImageInfoFromBlob(file_get_contents($tempFile->path));
         } else {
             $appController = Tinebase_Core::getApplicationInstance($application);
             if (!method_exists($appController, 'getImage')) {
                 throw new Tinebase_Exception_NotFound("{$application} has no getImage function.");
             }
             $image = $appController->getImage($identifier, $location);
         }
     }
     if (!$image instanceof Tinebase_Model_Image) {
         if (is_array($image)) {
             $image = new Tinebase_Model_Image($image + array('application' => $application, 'id' => $identifier, 'location' => $location));
         } else {
             throw new Tinebase_Exception_UnexpectedValue('broken image');
         }
     }
     return $image;
 }
 /**
  * get child by name
  * 
  * @param  string $name
  * @throws Sabre\DAV\Exception\NotFound
  * @return Tinebase_Frontend_WebDAV_File
  */
 public function getChild($path)
 {
     $basePath = Tinebase_FileSystem::getInstance()->getApplicationBasePath($this->_appName, Tinebase_FileSystem::FOLDER_TYPE_RECORDS);
     $filePath = preg_replace('@^' . $this->_appName . '/' . Tinebase_FileSystem::FOLDER_TYPE_RECORDS . '@', $basePath, $this->_path);
     return new Tinebase_Frontend_WebDAV_File($filePath . '/' . $path);
 }
示例#29
0
 /**
  * adds parent id filter sql
  *
  * @param  Zend_Db_Select                    $_select
  * @param  Tinebase_Backend_Sql_Abstract     $_backend
  */
 protected function _addParentIdFilter($_select, $_backend)
 {
     $node = Tinebase_FileSystem::getInstance()->stat($this->_path->statpath);
     $parentIdFilter = new Tinebase_Model_Filter_Text('parent_id', 'equals', $node->getId());
     $parentIdFilter->appendFilterSql($_select, $_backend);
 }
 /**
  * get vacation message from template file
  * 
  * @param string $templateId
  * @return string
  * 
  * @todo generalize and move to Tinebase_FileSystem / Node controller
  */
 protected function _getMessageFromTemplateFile($templateId)
 {
     $template = Tinebase_FileSystem::getInstance()->searchNodes(new Tinebase_Model_Tree_Node_Filter(array(array('field' => 'id', 'operator' => 'equals', 'value' => $templateId))))->getFirstRecord();
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($template->toArray(), TRUE));
     }
     $templateContainer = Tinebase_Container::getInstance()->getContainerById(Expressomail_Config::getInstance()->{Expressomail_Config::VACATION_TEMPLATES_CONTAINER_ID});
     $path = Tinebase_FileSystem::getInstance()->getContainerPath($templateContainer) . '/' . $template->name;
     $templateHandle = Tinebase_FileSystem::getInstance()->fopen($path, 'r');
     $message = stream_get_contents($templateHandle);
     Tinebase_FileSystem::getInstance()->fclose($templateHandle);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $message);
     }
     return $message;
 }