當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Trashbin::move2trash方法代碼示例

本文整理匯總了PHP中OCA\Files_Trashbin\Trashbin::move2trash方法的典型用法代碼示例。如果您正苦於以下問題:PHP Trashbin::move2trash方法的具體用法?PHP Trashbin::move2trash怎麽用?PHP Trashbin::move2trash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OCA\Files_Trashbin\Trashbin的用法示例。


在下文中一共展示了Trashbin::move2trash方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: unlink

 /**
  * Deletes the given file by moving it into the trashbin.
  *
  * @param string $path
  */
 public function unlink($path)
 {
     if (self::$disableTrash) {
         return $this->storage->unlink($path);
     }
     $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
     $result = true;
     if (!isset($this->deletedFiles[$normalized])) {
         $view = Filesystem::getView();
         $this->deletedFiles[$normalized] = $normalized;
         if ($filesPath = $view->getRelativePath($normalized)) {
             $filesPath = trim($filesPath, '/');
             $result = \OCA\Files_Trashbin\Trashbin::move2trash($filesPath);
             // in cross-storage cases the file will be copied
             // but not deleted, so we delete it here
             if ($result) {
                 $this->storage->unlink($path);
             }
         } else {
             $result = $this->storage->unlink($path);
         }
         unset($this->deletedFiles[$normalized]);
     } else {
         if ($this->storage->file_exists($path)) {
             $result = $this->storage->unlink($path);
         }
     }
     return $result;
 }
開發者ID:heldernl,項目名稱:owncloud8-extended,代碼行數:34,代碼來源:storage.php

示例2: doDelete

 /**
  * Run the delete operation with the given method
  *
  * @param string $path path of file or folder to delete
  * @param string $method either "unlink" or "rmdir"
  *
  * @return bool true if the operation succeeded, false otherwise
  */
 private function doDelete($path, $method)
 {
     if (self::$disableTrash || !\OC_App::isEnabled('files_trashbin') || pathinfo($path, PATHINFO_EXTENSION) === 'part' || $this->shouldMoveToTrash($path) === false) {
         return call_user_func_array([$this->storage, $method], [$path]);
     }
     // check permissions before we continue, this is especially important for
     // shared files
     if (!$this->isDeletable($path)) {
         return false;
     }
     $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
     $result = true;
     if (!isset($this->deletedFiles[$normalized])) {
         $view = Filesystem::getView();
         $this->deletedFiles[$normalized] = $normalized;
         if ($filesPath = $view->getRelativePath($normalized)) {
             $filesPath = trim($filesPath, '/');
             $result = \OCA\Files_Trashbin\Trashbin::move2trash($filesPath);
             // in cross-storage cases the file will be copied
             // but not deleted, so we delete it here
             if ($result) {
                 call_user_func_array([$this->storage, $method], [$path]);
             }
         } else {
             $result = call_user_func_array([$this->storage, $method], [$path]);
         }
         unset($this->deletedFiles[$normalized]);
     } else {
         if ($this->storage->file_exists($path)) {
             $result = call_user_func_array([$this->storage, $method], [$path]);
         }
     }
     return $result;
 }
開發者ID:enoch85,項目名稱:owncloud-testserver,代碼行數:42,代碼來源:storage.php

示例3: testDeleteSharedFile

 function testDeleteSharedFile()
 {
     // generate filename
     $filename = 'tmp-' . $this->getUniqueID() . '.txt';
     // save file with content
     $cryptedFile = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename, $this->dataShort);
     // test that data was successfully written
     $this->assertTrue(is_int($cryptedFile));
     // get the file info from previous created file
     $fileInfo = $this->view->getFileInfo('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename);
     // check if we have a valid file info
     $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
     // share the file
     $this->assertTrue(\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_TRASHBIN_USER2, OCP\PERMISSION_ALL));
     self::loginHelper(self::TEST_ENCRYPTION_TRASHBIN_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($filename));
     \OCA\Files_Trashbin\Trashbin::move2trash($filename);
     $query = \OC_DB::prepare('SELECT `timestamp` FROM `*PREFIX*files_trash`' . ' WHERE `id`=?');
     $result = $query->execute(array($filename))->fetchRow();
     $this->assertNotEmpty($result);
     $timestamp = $result['timestamp'];
     // check if key for both users exists
     $this->assertTrue($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keyfiles/' . $filename . '.key.d' . $timestamp));
     // check if key for admin exists
     $this->assertTrue($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER2 . '/files_trashbin/keyfiles/' . $filename . '.key.d' . $timestamp));
     // check if share key for both users exists
     $this->assertTrue($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/share-keys/' . $filename . '.' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey.d' . $timestamp));
     $this->assertTrue($this->view->file_exists('/' . self::TEST_ENCRYPTION_TRASHBIN_USER2 . '/files_trashbin/share-keys/' . $filename . '.' . self::TEST_ENCRYPTION_TRASHBIN_USER2 . '.shareKey.d' . $timestamp));
 }
開發者ID:droiter,項目名稱:openwrt-on-android,代碼行數:29,代碼來源:trashbin.php


注:本文中的OCA\Files_Trashbin\Trashbin::move2trash方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。