當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。