当前位置: 首页>>代码示例>>PHP>>正文


PHP Trashbin::restore方法代码示例

本文整理汇总了PHP中OCA\Files_Trashbin\Trashbin::restore方法的典型用法代码示例。如果您正苦于以下问题:PHP Trashbin::restore方法的具体用法?PHP Trashbin::restore怎么用?PHP Trashbin::restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCA\Files_Trashbin\Trashbin的用法示例。


在下文中一共展示了Trashbin::restore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRestoreFile

 /**
  * @medium
  * @brief test restore file
  *
  * @depends testDeleteFile
  */
 function testRestoreFile($filename)
 {
     // prepare file information
     $path_parts = pathinfo($filename);
     $trashFileSuffix = $path_parts['extension'];
     $timestamp = str_replace('d', '', $trashFileSuffix);
     $fileNameWithoutSuffix = str_replace('.' . $trashFileSuffix, '', $filename);
     // restore file
     $this->assertTrue(\OCA\Files_Trashbin\Trashbin::restore($filename, $fileNameWithoutSuffix, $timestamp));
     // check if file exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $fileNameWithoutSuffix));
     // check if key for admin exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $fileNameWithoutSuffix . '.key'));
     // check if share key for admin exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' . $fileNameWithoutSuffix . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:22,代码来源:trashbin.php

示例2: restoreTrashedNote

 /**
  * Restores a trashed note
  *
  * We try to mimic undelete.php to get all versions restored too.
  * @see owncloud/core/apps/files_trashbin/ajax/undelete.php
  *
  * @NoAdminRequired
  * @NoCSRFRequired
  * @CORS
  *
  * @return string
  */
 public function restoreTrashedNote()
 {
     $filename = $this->request->getParam("file_name");
     $timestamp = (int) $this->request->getParam("timestamp");
     $path = $filename . ".d{$timestamp}";
     $pathParts = pathinfo($path);
     $path = "//" . $pathParts['basename'];
     $pathParts = pathinfo($filename);
     $filename = $pathParts['basename'];
     $restoreResult = Trashbin::restore($path, $filename, $timestamp);
     $data = array();
     $data['result'] = $restoreResult;
     $data['path'] = $path;
     $data['filename'] = $filename;
     return $data;
 }
开发者ID:pbek,项目名称:qownnotesapi,代码行数:28,代码来源:noteapicontroller.php

示例3: testRestoreFile

 /**
  * @medium
  * test restore file
  */
 function testRestoreFile()
 {
     // generate filename
     $filename = 'tmp-' . uniqid() . '.txt';
     $filename2 = $filename . '.backup';
     // a second file with similar name
     // save file with content
     $cryptedFile = file_put_contents('crypt:///' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename, $this->dataShort);
     $cryptedFile2 = file_put_contents('crypt:///' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename2, $this->dataShort);
     // delete both files
     \OC\Files\Filesystem::unlink($filename);
     \OC\Files\Filesystem::unlink($filename2);
     $trashFiles = $this->view->getDirectoryContent('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/files/');
     $trashFileSuffix = null;
     $trashFileSuffix2 = null;
     // find created file with timestamp
     foreach ($trashFiles as $file) {
         if (strncmp($file['path'], $filename, strlen($filename))) {
             $path_parts = pathinfo($file['name']);
             $trashFileSuffix = $path_parts['extension'];
         }
         if (strncmp($file['path'], $filename2, strlen($filename2))) {
             $path_parts = pathinfo($file['name']);
             $trashFileSuffix2 = $path_parts['extension'];
         }
     }
     // prepare file information
     $timestamp = str_replace('d', '', $trashFileSuffix);
     // restore first file
     $this->assertTrue(\OCA\Files_Trashbin\Trashbin::restore($filename . '.' . $trashFileSuffix, $filename, $timestamp));
     // check if file exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename));
     // check if key for admin exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename . '.key'));
     // check if share key for admin exists
     $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' . $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
     // check that second file was NOT restored
     $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename2));
     // check if key for admin exists
     $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename2 . '.key'));
     // check if share key for admin exists
     $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/' . $filename2 . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
 }
开发者ID:Romua1d,项目名称:core,代码行数:47,代码来源:trashbin.php

示例4: testRestoreFile

 /**
  * @medium
  * test restore file
  */
 function testRestoreFile()
 {
     // generate filename
     $filename = 'tmp-' . $this->getUniqueID() . '.txt';
     $filename2 = $filename . '.backup';
     // a second file with similar name
     // save file with content
     file_put_contents('crypt:///' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename, $this->dataShort);
     file_put_contents('crypt:///' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename2, $this->dataShort);
     // delete both files
     \OC\Files\Filesystem::unlink($filename);
     \OC\Files\Filesystem::unlink($filename2);
     $trashFiles = \OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_ENCRYPTION_TRASHBIN_USER1);
     // find created file with timestamp
     $timestamp = null;
     foreach ($trashFiles as $file) {
         if ($file['name'] === $filename) {
             $timestamp = $file['mtime'];
             break;
         }
     }
     // make sure that we have a timestamp
     $this->assertNotNull($timestamp);
     // before calling the restore operation the keys shouldn't be there
     $this->assertFalse($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keys/' . $filename . '/fileKey'));
     $this->assertFalse($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keys/' . $filename . '/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
     // restore first file
     $this->assertTrue(\OCA\Files_Trashbin\Trashbin::restore($filename . '.d' . $timestamp, $filename, $timestamp));
     // check if file exists
     $this->assertTrue($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename));
     // check if key for admin exists
     $this->assertTrue($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keys/' . $filename . '/fileKey'));
     // check if share key for admin exists
     $this->assertTrue($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keys/' . $filename . '/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
     // check that second file was NOT restored
     $this->assertFalse($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename2));
     // check if key for admin exists
     $this->assertFalse($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keys/' . $filename2 . '/fileKey'));
     // check if share key for admin exists
     $this->assertFalse($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keys/' . $filename2 . '/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
 }
开发者ID:samj1912,项目名称:repo,代码行数:45,代码来源:trashbin.php


注:本文中的OCA\Files_Trashbin\Trashbin::restore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。