本文整理汇总了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;
}
示例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;
}
示例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));
}