示例#1
0
 function testPurgeDeletedVersion()
 {
     $versionFactory = new Docman_VersionFactoryTestVersionDeleteFile($this);
     $dao = new MockDocman_VersionDao($this);
     $dao->setReturnValue('setPurgeDate', true);
     $versionFactory->setReturnValue('_getVersionDao', $dao);
     $version = new Docman_Version(array('id' => null, 'user_id' => null, 'item_id' => null, 'number' => null, 'label' => null, 'changelog' => null, 'date' => null, 'filename' => 'fileToPurge.txt', 'filesize' => null, 'filetype' => null, 'path' => dirname(__FILE__) . '/_fixtures/fileToPurge_txt'));
     $fp = fopen($version->getPath(), 'w');
     $this->assertTrue($versionFactory->PurgeDeletedVersion($version));
     $this->assertFalse(file_exists($version->getPath()));
 }
 /**
  * Index a new document with permissions
  *
  * @param Docman_Item    $item    The docman item
  * @param Docman_Version $version The version to index
  *
  * @throws FullTextSearchDocmanIndexFileTooBigException
  */
 public function indexNewVersion(Docman_Item $item, Docman_Version $version)
 {
     try {
         $this->client->getIndexedElement($item->getGroupId(), $item->getId());
         $this->logger->debug('index new version #' . $version->getId() . ' for document #' . $item->getId());
         $update_data = array();
         if (filesize($version->getPath()) > $this->max_indexed_file_size) {
             throw new FullTextSearchDocmanIndexFileTooBigException($item->getId());
         }
         $this->request_data_factory->updateFile($update_data, $version->getPath());
         $this->client->update($item->getGroupId(), $item->getId(), $update_data);
     } catch (ElasticSearch_ElementNotIndexed $exception) {
         $this->indexNewDocument($item, $version);
         return;
     }
 }
 public function getFileContent(Docman_Version $version)
 {
     return array('file' => $this->fileContentEncode($version->getPath()));
 }
示例#4
0
 private function getIndexedData(Docman_Item $item, Docman_Version $version)
 {
     return array('id' => $item->getId(), 'group_id' => $item->getGroupId(), 'title' => $item->getTitle(), 'description' => $item->getDescription(), 'permissions' => $this->permissions_manager->exportPermissions($item), 'file' => $this->fileContentEncode($version->getPath()));
 }
 /**
  *  method to load the pdf document in zend_framework
  *  @param  void
  *  @return void
  */
 public function load()
 {
     $this->pdf = Zend_Pdf::load($this->version->getPath());
 }
 /**
  * Invoque ''archive deleted item' hook in order to make a backup of a given item version.
  * This method should be used whithin the deleted docman version purge process
  *
  * @param Docman_Version $version Deleted docman item version
  *
  * @return Void
  */
 public function archiveBeforePurge($version)
 {
     $item = $this->_getItemFactory()->getItemFromDb($version->getItemId(), array('ignore_deleted' => true));
     $prefix = $item->getGroupId() . '_i' . $version->getItemId() . '_v' . $version->getNumber();
     $params = array('source_path' => $version->getPath(), 'archive_prefix' => $prefix);
     $this->_getEventManager()->processEvent('archive_deleted_item', $params);
 }
 /**
  * Downloads the file
  *
  * @param Docman_Version $version
  *
  * @return void
  */
 function download($version)
 {
     $version->preDownload($this->getItem(), $this->getUser());
     // Download the file
     parent::download($version->getFiletype(), $version->getFilesize(), $version->getPath());
 }
 /**
  * Physically remove the given version from the filesystem
  *
  * @param Docman_Version $version
  *
  * @return Boolean
  */
 public function purgeDeletedVersion($version)
 {
     if (file_exists($version->getPath()) && $this->physicalDeleteVersion($version->getPath())) {
         $dao = $this->_getVersionDao();
         return $dao->setPurgeDate($version->getId(), time());
     }
     return false;
 }