@@ -6,21 +6,21 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\Files_Versions\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
| 10 | - 'OCA\\Files_Versions\\BackgroundJob\\ExpireVersions' => $baseDir . '/../lib/BackgroundJob/ExpireVersions.php', |
|
| 11 | - 'OCA\\Files_Versions\\Capabilities' => $baseDir . '/../lib/Capabilities.php', |
|
| 12 | - 'OCA\\Files_Versions\\Command\\CleanUp' => $baseDir . '/../lib/Command/CleanUp.php', |
|
| 13 | - 'OCA\\Files_Versions\\Command\\Expire' => $baseDir . '/../lib/Command/Expire.php', |
|
| 14 | - 'OCA\\Files_Versions\\Command\\ExpireVersions' => $baseDir . '/../lib/Command/ExpireVersions.php', |
|
| 15 | - 'OCA\\Files_Versions\\Controller\\PreviewController' => $baseDir . '/../lib/Controller/PreviewController.php', |
|
| 16 | - 'OCA\\Files_Versions\\Events\\CreateVersionEvent' => $baseDir . '/../lib/Events/CreateVersionEvent.php', |
|
| 17 | - 'OCA\\Files_Versions\\Expiration' => $baseDir . '/../lib/Expiration.php', |
|
| 18 | - 'OCA\\Files_Versions\\Hooks' => $baseDir . '/../lib/Hooks.php', |
|
| 19 | - 'OCA\\Files_Versions\\Sabre\\RestoreFolder' => $baseDir . '/../lib/Sabre/RestoreFolder.php', |
|
| 20 | - 'OCA\\Files_Versions\\Sabre\\RootCollection' => $baseDir . '/../lib/Sabre/RootCollection.php', |
|
| 21 | - 'OCA\\Files_Versions\\Sabre\\VersionCollection' => $baseDir . '/../lib/Sabre/VersionCollection.php', |
|
| 22 | - 'OCA\\Files_Versions\\Sabre\\VersionFile' => $baseDir . '/../lib/Sabre/VersionFile.php', |
|
| 23 | - 'OCA\\Files_Versions\\Sabre\\VersionHome' => $baseDir . '/../lib/Sabre/VersionHome.php', |
|
| 24 | - 'OCA\\Files_Versions\\Sabre\\VersionRoot' => $baseDir . '/../lib/Sabre/VersionRoot.php', |
|
| 25 | - 'OCA\\Files_Versions\\Storage' => $baseDir . '/../lib/Storage.php', |
|
| 9 | + 'OCA\\Files_Versions\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
| 10 | + 'OCA\\Files_Versions\\BackgroundJob\\ExpireVersions' => $baseDir.'/../lib/BackgroundJob/ExpireVersions.php', |
|
| 11 | + 'OCA\\Files_Versions\\Capabilities' => $baseDir.'/../lib/Capabilities.php', |
|
| 12 | + 'OCA\\Files_Versions\\Command\\CleanUp' => $baseDir.'/../lib/Command/CleanUp.php', |
|
| 13 | + 'OCA\\Files_Versions\\Command\\Expire' => $baseDir.'/../lib/Command/Expire.php', |
|
| 14 | + 'OCA\\Files_Versions\\Command\\ExpireVersions' => $baseDir.'/../lib/Command/ExpireVersions.php', |
|
| 15 | + 'OCA\\Files_Versions\\Controller\\PreviewController' => $baseDir.'/../lib/Controller/PreviewController.php', |
|
| 16 | + 'OCA\\Files_Versions\\Events\\CreateVersionEvent' => $baseDir.'/../lib/Events/CreateVersionEvent.php', |
|
| 17 | + 'OCA\\Files_Versions\\Expiration' => $baseDir.'/../lib/Expiration.php', |
|
| 18 | + 'OCA\\Files_Versions\\Hooks' => $baseDir.'/../lib/Hooks.php', |
|
| 19 | + 'OCA\\Files_Versions\\Sabre\\RestoreFolder' => $baseDir.'/../lib/Sabre/RestoreFolder.php', |
|
| 20 | + 'OCA\\Files_Versions\\Sabre\\RootCollection' => $baseDir.'/../lib/Sabre/RootCollection.php', |
|
| 21 | + 'OCA\\Files_Versions\\Sabre\\VersionCollection' => $baseDir.'/../lib/Sabre/VersionCollection.php', |
|
| 22 | + 'OCA\\Files_Versions\\Sabre\\VersionFile' => $baseDir.'/../lib/Sabre/VersionFile.php', |
|
| 23 | + 'OCA\\Files_Versions\\Sabre\\VersionHome' => $baseDir.'/../lib/Sabre/VersionHome.php', |
|
| 24 | + 'OCA\\Files_Versions\\Sabre\\VersionRoot' => $baseDir.'/../lib/Sabre/VersionRoot.php', |
|
| 25 | + 'OCA\\Files_Versions\\Storage' => $baseDir.'/../lib/Storage.php', |
|
| 26 | 26 | ); |
@@ -6,43 +6,43 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInitFiles_Versions |
| 8 | 8 | { |
| 9 | - public static $prefixLengthsPsr4 = array ( |
|
| 9 | + public static $prefixLengthsPsr4 = array( |
|
| 10 | 10 | 'O' => |
| 11 | - array ( |
|
| 11 | + array( |
|
| 12 | 12 | 'OCA\\Files_Versions\\' => 19, |
| 13 | 13 | ), |
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | - public static $prefixDirsPsr4 = array ( |
|
| 16 | + public static $prefixDirsPsr4 = array( |
|
| 17 | 17 | 'OCA\\Files_Versions\\' => |
| 18 | - array ( |
|
| 19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
| 18 | + array( |
|
| 19 | + 0 => __DIR__.'/..'.'/../lib', |
|
| 20 | 20 | ), |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - public static $classMap = array ( |
|
| 24 | - 'OCA\\Files_Versions\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
| 25 | - 'OCA\\Files_Versions\\BackgroundJob\\ExpireVersions' => __DIR__ . '/..' . '/../lib/BackgroundJob/ExpireVersions.php', |
|
| 26 | - 'OCA\\Files_Versions\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php', |
|
| 27 | - 'OCA\\Files_Versions\\Command\\CleanUp' => __DIR__ . '/..' . '/../lib/Command/CleanUp.php', |
|
| 28 | - 'OCA\\Files_Versions\\Command\\Expire' => __DIR__ . '/..' . '/../lib/Command/Expire.php', |
|
| 29 | - 'OCA\\Files_Versions\\Command\\ExpireVersions' => __DIR__ . '/..' . '/../lib/Command/ExpireVersions.php', |
|
| 30 | - 'OCA\\Files_Versions\\Controller\\PreviewController' => __DIR__ . '/..' . '/../lib/Controller/PreviewController.php', |
|
| 31 | - 'OCA\\Files_Versions\\Events\\CreateVersionEvent' => __DIR__ . '/..' . '/../lib/Events/CreateVersionEvent.php', |
|
| 32 | - 'OCA\\Files_Versions\\Expiration' => __DIR__ . '/..' . '/../lib/Expiration.php', |
|
| 33 | - 'OCA\\Files_Versions\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php', |
|
| 34 | - 'OCA\\Files_Versions\\Sabre\\RestoreFolder' => __DIR__ . '/..' . '/../lib/Sabre/RestoreFolder.php', |
|
| 35 | - 'OCA\\Files_Versions\\Sabre\\RootCollection' => __DIR__ . '/..' . '/../lib/Sabre/RootCollection.php', |
|
| 36 | - 'OCA\\Files_Versions\\Sabre\\VersionCollection' => __DIR__ . '/..' . '/../lib/Sabre/VersionCollection.php', |
|
| 37 | - 'OCA\\Files_Versions\\Sabre\\VersionFile' => __DIR__ . '/..' . '/../lib/Sabre/VersionFile.php', |
|
| 38 | - 'OCA\\Files_Versions\\Sabre\\VersionHome' => __DIR__ . '/..' . '/../lib/Sabre/VersionHome.php', |
|
| 39 | - 'OCA\\Files_Versions\\Sabre\\VersionRoot' => __DIR__ . '/..' . '/../lib/Sabre/VersionRoot.php', |
|
| 40 | - 'OCA\\Files_Versions\\Storage' => __DIR__ . '/..' . '/../lib/Storage.php', |
|
| 23 | + public static $classMap = array( |
|
| 24 | + 'OCA\\Files_Versions\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
| 25 | + 'OCA\\Files_Versions\\BackgroundJob\\ExpireVersions' => __DIR__.'/..'.'/../lib/BackgroundJob/ExpireVersions.php', |
|
| 26 | + 'OCA\\Files_Versions\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php', |
|
| 27 | + 'OCA\\Files_Versions\\Command\\CleanUp' => __DIR__.'/..'.'/../lib/Command/CleanUp.php', |
|
| 28 | + 'OCA\\Files_Versions\\Command\\Expire' => __DIR__.'/..'.'/../lib/Command/Expire.php', |
|
| 29 | + 'OCA\\Files_Versions\\Command\\ExpireVersions' => __DIR__.'/..'.'/../lib/Command/ExpireVersions.php', |
|
| 30 | + 'OCA\\Files_Versions\\Controller\\PreviewController' => __DIR__.'/..'.'/../lib/Controller/PreviewController.php', |
|
| 31 | + 'OCA\\Files_Versions\\Events\\CreateVersionEvent' => __DIR__.'/..'.'/../lib/Events/CreateVersionEvent.php', |
|
| 32 | + 'OCA\\Files_Versions\\Expiration' => __DIR__.'/..'.'/../lib/Expiration.php', |
|
| 33 | + 'OCA\\Files_Versions\\Hooks' => __DIR__.'/..'.'/../lib/Hooks.php', |
|
| 34 | + 'OCA\\Files_Versions\\Sabre\\RestoreFolder' => __DIR__.'/..'.'/../lib/Sabre/RestoreFolder.php', |
|
| 35 | + 'OCA\\Files_Versions\\Sabre\\RootCollection' => __DIR__.'/..'.'/../lib/Sabre/RootCollection.php', |
|
| 36 | + 'OCA\\Files_Versions\\Sabre\\VersionCollection' => __DIR__.'/..'.'/../lib/Sabre/VersionCollection.php', |
|
| 37 | + 'OCA\\Files_Versions\\Sabre\\VersionFile' => __DIR__.'/..'.'/../lib/Sabre/VersionFile.php', |
|
| 38 | + 'OCA\\Files_Versions\\Sabre\\VersionHome' => __DIR__.'/..'.'/../lib/Sabre/VersionHome.php', |
|
| 39 | + 'OCA\\Files_Versions\\Sabre\\VersionRoot' => __DIR__.'/..'.'/../lib/Sabre/VersionRoot.php', |
|
| 40 | + 'OCA\\Files_Versions\\Storage' => __DIR__.'/..'.'/../lib/Storage.php', |
|
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | public static function getInitializer(ClassLoader $loader) |
| 44 | 44 | { |
| 45 | - return \Closure::bind(function () use ($loader) { |
|
| 45 | + return \Closure::bind(function() use ($loader) { |
|
| 46 | 46 | $loader->prefixLengthsPsr4 = ComposerStaticInitFiles_Versions::$prefixLengthsPsr4; |
| 47 | 47 | $loader->prefixDirsPsr4 = ComposerStaticInitFiles_Versions::$prefixDirsPsr4; |
| 48 | 48 | $loader->classMap = ComposerStaticInitFiles_Versions::$classMap; |
@@ -32,55 +32,55 @@ |
||
| 32 | 32 | |
| 33 | 33 | class RestoreFolder implements ICollection, IMoveTarget { |
| 34 | 34 | |
| 35 | - /** @var string */ |
|
| 36 | - protected $userId; |
|
| 35 | + /** @var string */ |
|
| 36 | + protected $userId; |
|
| 37 | 37 | |
| 38 | - public function __construct(string $userId) { |
|
| 39 | - $this->userId = $userId; |
|
| 40 | - } |
|
| 38 | + public function __construct(string $userId) { |
|
| 39 | + $this->userId = $userId; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function createFile($name, $data = null) { |
|
| 43 | - throw new Forbidden(); |
|
| 44 | - } |
|
| 42 | + public function createFile($name, $data = null) { |
|
| 43 | + throw new Forbidden(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public function createDirectory($name) { |
|
| 47 | - throw new Forbidden(); |
|
| 48 | - } |
|
| 46 | + public function createDirectory($name) { |
|
| 47 | + throw new Forbidden(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function getChild($name) { |
|
| 51 | - return null; |
|
| 52 | - } |
|
| 50 | + public function getChild($name) { |
|
| 51 | + return null; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function delete() { |
|
| 55 | - throw new Forbidden(); |
|
| 56 | - } |
|
| 54 | + public function delete() { |
|
| 55 | + throw new Forbidden(); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function getName() { |
|
| 59 | - return 'restore'; |
|
| 60 | - } |
|
| 58 | + public function getName() { |
|
| 59 | + return 'restore'; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function setName($name) { |
|
| 63 | - throw new Forbidden(); |
|
| 64 | - } |
|
| 62 | + public function setName($name) { |
|
| 63 | + throw new Forbidden(); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function getLastModified(): int { |
|
| 67 | - return 0; |
|
| 68 | - } |
|
| 66 | + public function getLastModified(): int { |
|
| 67 | + return 0; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function getChildren(): array { |
|
| 71 | - return []; |
|
| 72 | - } |
|
| 70 | + public function getChildren(): array { |
|
| 71 | + return []; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - public function childExists($name): bool { |
|
| 75 | - return false; |
|
| 76 | - } |
|
| 74 | + public function childExists($name): bool { |
|
| 75 | + return false; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - public function moveInto($targetName, $sourcePath, INode $sourceNode): bool { |
|
| 79 | - if (!($sourceNode instanceof VersionFile)) { |
|
| 80 | - return false; |
|
| 81 | - } |
|
| 78 | + public function moveInto($targetName, $sourcePath, INode $sourceNode): bool { |
|
| 79 | + if (!($sourceNode instanceof VersionFile)) { |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - return $sourceNode->rollBack(); |
|
| 84 | - } |
|
| 83 | + return $sourceNode->rollBack(); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | 86 | } |
@@ -32,63 +32,63 @@ |
||
| 32 | 32 | use Sabre\DAV\IFile; |
| 33 | 33 | |
| 34 | 34 | class VersionFile implements IFile { |
| 35 | - /** @var array */ |
|
| 36 | - private $data; |
|
| 35 | + /** @var array */ |
|
| 36 | + private $data; |
|
| 37 | 37 | |
| 38 | - /** @var Folder */ |
|
| 39 | - private $userRoot; |
|
| 38 | + /** @var Folder */ |
|
| 39 | + private $userRoot; |
|
| 40 | 40 | |
| 41 | - public function __construct(array $data, Folder $userRoot) { |
|
| 42 | - $this->data = $data; |
|
| 43 | - $this->userRoot = $userRoot; |
|
| 44 | - } |
|
| 41 | + public function __construct(array $data, Folder $userRoot) { |
|
| 42 | + $this->data = $data; |
|
| 43 | + $this->userRoot = $userRoot; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public function put($data) { |
|
| 47 | - throw new Forbidden(); |
|
| 48 | - } |
|
| 46 | + public function put($data) { |
|
| 47 | + throw new Forbidden(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function get() { |
|
| 51 | - try { |
|
| 52 | - /** @var Folder $versions */ |
|
| 53 | - $versions = $this->userRoot->get('files_versions'); |
|
| 54 | - /** @var File $version */ |
|
| 55 | - $version = $versions->get($this->data['path'].'.v'.$this->data['version']); |
|
| 56 | - } catch (NotFoundException $e) { |
|
| 57 | - throw new NotFound(); |
|
| 58 | - } |
|
| 50 | + public function get() { |
|
| 51 | + try { |
|
| 52 | + /** @var Folder $versions */ |
|
| 53 | + $versions = $this->userRoot->get('files_versions'); |
|
| 54 | + /** @var File $version */ |
|
| 55 | + $version = $versions->get($this->data['path'].'.v'.$this->data['version']); |
|
| 56 | + } catch (NotFoundException $e) { |
|
| 57 | + throw new NotFound(); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - return $version->fopen('rb'); |
|
| 61 | - } |
|
| 60 | + return $version->fopen('rb'); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function getContentType(): string { |
|
| 64 | - return $this->data['mimetype']; |
|
| 65 | - } |
|
| 63 | + public function getContentType(): string { |
|
| 64 | + return $this->data['mimetype']; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - public function getETag(): string { |
|
| 68 | - return $this->data['version']; |
|
| 69 | - } |
|
| 67 | + public function getETag(): string { |
|
| 68 | + return $this->data['version']; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - public function getSize(): int { |
|
| 72 | - return $this->data['size']; |
|
| 73 | - } |
|
| 71 | + public function getSize(): int { |
|
| 72 | + return $this->data['size']; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - public function delete() { |
|
| 76 | - throw new Forbidden(); |
|
| 77 | - } |
|
| 75 | + public function delete() { |
|
| 76 | + throw new Forbidden(); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - public function getName(): string { |
|
| 80 | - return $this->data['version']; |
|
| 81 | - } |
|
| 79 | + public function getName(): string { |
|
| 80 | + return $this->data['version']; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - public function setName($name) { |
|
| 84 | - throw new Forbidden(); |
|
| 85 | - } |
|
| 83 | + public function setName($name) { |
|
| 84 | + throw new Forbidden(); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - public function getLastModified(): int { |
|
| 88 | - return (int)$this->data['version']; |
|
| 89 | - } |
|
| 87 | + public function getLastModified(): int { |
|
| 88 | + return (int)$this->data['version']; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - public function rollBack(): bool { |
|
| 92 | - return Storage::rollback($this->data['path'], $this->data['version']); |
|
| 93 | - } |
|
| 91 | + public function rollBack(): bool { |
|
| 92 | + return Storage::rollback($this->data['path'], $this->data['version']); |
|
| 93 | + } |
|
| 94 | 94 | } |
@@ -85,7 +85,7 @@ |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function getLastModified(): int { |
| 88 | - return (int)$this->data['version']; |
|
| 88 | + return (int) $this->data['version']; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function rollBack(): bool { |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | public function getChild($name) { |
| 66 | 66 | $userFolder = $this->rootFolder->getUserFolder($this->userId); |
| 67 | 67 | |
| 68 | - $fileId = (int)$name; |
|
| 68 | + $fileId = (int) $name; |
|
| 69 | 69 | $nodes = $userFolder->getById($fileId); |
| 70 | 70 | |
| 71 | 71 | if ($nodes === []) { |
@@ -31,70 +31,70 @@ |
||
| 31 | 31 | |
| 32 | 32 | class VersionRoot implements ICollection { |
| 33 | 33 | |
| 34 | - /** @var string */ |
|
| 35 | - private $userId; |
|
| 34 | + /** @var string */ |
|
| 35 | + private $userId; |
|
| 36 | 36 | |
| 37 | - /** @var IRootFolder */ |
|
| 38 | - private $rootFolder; |
|
| 37 | + /** @var IRootFolder */ |
|
| 38 | + private $rootFolder; |
|
| 39 | 39 | |
| 40 | - public function __construct(string $userId, IRootFolder $rootFolder) { |
|
| 41 | - $this->userId = $userId; |
|
| 42 | - $this->rootFolder = $rootFolder; |
|
| 43 | - } |
|
| 40 | + public function __construct(string $userId, IRootFolder $rootFolder) { |
|
| 41 | + $this->userId = $userId; |
|
| 42 | + $this->rootFolder = $rootFolder; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function delete() { |
|
| 46 | - throw new Forbidden(); |
|
| 47 | - } |
|
| 45 | + public function delete() { |
|
| 46 | + throw new Forbidden(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function getName(): string { |
|
| 50 | - return 'versions'; |
|
| 51 | - } |
|
| 49 | + public function getName(): string { |
|
| 50 | + return 'versions'; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function setName($name) { |
|
| 54 | - throw new Forbidden(); |
|
| 55 | - } |
|
| 53 | + public function setName($name) { |
|
| 54 | + throw new Forbidden(); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function createFile($name, $data = null) { |
|
| 58 | - throw new Forbidden(); |
|
| 59 | - } |
|
| 57 | + public function createFile($name, $data = null) { |
|
| 58 | + throw new Forbidden(); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function createDirectory($name) { |
|
| 62 | - throw new Forbidden(); |
|
| 63 | - } |
|
| 61 | + public function createDirectory($name) { |
|
| 62 | + throw new Forbidden(); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - public function getChild($name) { |
|
| 66 | - $userFolder = $this->rootFolder->getUserFolder($this->userId); |
|
| 65 | + public function getChild($name) { |
|
| 66 | + $userFolder = $this->rootFolder->getUserFolder($this->userId); |
|
| 67 | 67 | |
| 68 | - $fileId = (int)$name; |
|
| 69 | - $nodes = $userFolder->getById($fileId); |
|
| 68 | + $fileId = (int)$name; |
|
| 69 | + $nodes = $userFolder->getById($fileId); |
|
| 70 | 70 | |
| 71 | - if ($nodes === []) { |
|
| 72 | - throw new NotFound(); |
|
| 73 | - } |
|
| 71 | + if ($nodes === []) { |
|
| 72 | + throw new NotFound(); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - $node = array_pop($nodes); |
|
| 75 | + $node = array_pop($nodes); |
|
| 76 | 76 | |
| 77 | - if (!$node instanceof File) { |
|
| 78 | - throw new NotFound(); |
|
| 79 | - } |
|
| 77 | + if (!$node instanceof File) { |
|
| 78 | + throw new NotFound(); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - return new VersionCollection($userFolder, $node, $this->userId); |
|
| 82 | - } |
|
| 81 | + return new VersionCollection($userFolder, $node, $this->userId); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - public function getChildren(): array { |
|
| 85 | - return []; |
|
| 86 | - } |
|
| 84 | + public function getChildren(): array { |
|
| 85 | + return []; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - public function childExists($name): bool { |
|
| 89 | - try { |
|
| 90 | - $this->getChild($name); |
|
| 91 | - return true; |
|
| 92 | - } catch (NotFound $e) { |
|
| 93 | - return false; |
|
| 94 | - } |
|
| 95 | - } |
|
| 88 | + public function childExists($name): bool { |
|
| 89 | + try { |
|
| 90 | + $this->getChild($name); |
|
| 91 | + return true; |
|
| 92 | + } catch (NotFound $e) { |
|
| 93 | + return false; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - public function getLastModified(): int { |
|
| 98 | - return 0; |
|
| 99 | - } |
|
| 97 | + public function getLastModified(): int { |
|
| 98 | + return 0; |
|
| 99 | + } |
|
| 100 | 100 | } |
@@ -29,37 +29,37 @@ |
||
| 29 | 29 | |
| 30 | 30 | class RootCollection extends AbstractPrincipalCollection { |
| 31 | 31 | |
| 32 | - /** @var IRootFolder */ |
|
| 33 | - private $rootFolder; |
|
| 32 | + /** @var IRootFolder */ |
|
| 33 | + private $rootFolder; |
|
| 34 | 34 | |
| 35 | - public function __construct(PrincipalBackend\BackendInterface $principalBackend, |
|
| 36 | - IRootFolder $rootFolder) { |
|
| 37 | - parent::__construct($principalBackend, 'principals/users'); |
|
| 35 | + public function __construct(PrincipalBackend\BackendInterface $principalBackend, |
|
| 36 | + IRootFolder $rootFolder) { |
|
| 37 | + parent::__construct($principalBackend, 'principals/users'); |
|
| 38 | 38 | |
| 39 | - $this->rootFolder = $rootFolder; |
|
| 40 | - } |
|
| 39 | + $this->rootFolder = $rootFolder; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * This method returns a node for a principal. |
|
| 44 | - * |
|
| 45 | - * The passed array contains principal information, and is guaranteed to |
|
| 46 | - * at least contain a uri item. Other properties may or may not be |
|
| 47 | - * supplied by the authentication backend. |
|
| 48 | - * |
|
| 49 | - * @param array $principalInfo |
|
| 50 | - * @return INode |
|
| 51 | - */ |
|
| 52 | - public function getChildForPrincipal(array $principalInfo) { |
|
| 53 | - list(,$name) = \Sabre\Uri\split($principalInfo['uri']); |
|
| 54 | - $user = \OC::$server->getUserSession()->getUser(); |
|
| 55 | - if (is_null($user) || $name !== $user->getUID()) { |
|
| 56 | - throw new \Sabre\DAV\Exception\Forbidden(); |
|
| 57 | - } |
|
| 58 | - return new VersionHome($principalInfo, $this->rootFolder); |
|
| 59 | - } |
|
| 42 | + /** |
|
| 43 | + * This method returns a node for a principal. |
|
| 44 | + * |
|
| 45 | + * The passed array contains principal information, and is guaranteed to |
|
| 46 | + * at least contain a uri item. Other properties may or may not be |
|
| 47 | + * supplied by the authentication backend. |
|
| 48 | + * |
|
| 49 | + * @param array $principalInfo |
|
| 50 | + * @return INode |
|
| 51 | + */ |
|
| 52 | + public function getChildForPrincipal(array $principalInfo) { |
|
| 53 | + list(,$name) = \Sabre\Uri\split($principalInfo['uri']); |
|
| 54 | + $user = \OC::$server->getUserSession()->getUser(); |
|
| 55 | + if (is_null($user) || $name !== $user->getUID()) { |
|
| 56 | + throw new \Sabre\DAV\Exception\Forbidden(); |
|
| 57 | + } |
|
| 58 | + return new VersionHome($principalInfo, $this->rootFolder); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function getName() { |
|
| 62 | - return 'versions'; |
|
| 63 | - } |
|
| 61 | + public function getName() { |
|
| 62 | + return 'versions'; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function getChildren(): array { |
| 71 | 71 | $versions = Storage::getVersions($this->userId, $this->userFolder->getRelativePath($this->file->getPath())); |
| 72 | 72 | |
| 73 | - return array_map(function (array $data) { |
|
| 73 | + return array_map(function(array $data) { |
|
| 74 | 74 | return new VersionFile($data, $this->userFolder->getParent()); |
| 75 | 75 | }, $versions); |
| 76 | 76 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public function getName(): string { |
| 89 | - return (string)$this->file->getId(); |
|
| 89 | + return (string) $this->file->getId(); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | public function setName($name) { |
@@ -31,72 +31,72 @@ |
||
| 31 | 31 | use Sabre\DAV\ICollection; |
| 32 | 32 | |
| 33 | 33 | class VersionCollection implements ICollection { |
| 34 | - /** @var Folder */ |
|
| 35 | - private $userFolder; |
|
| 36 | - |
|
| 37 | - /** @var File */ |
|
| 38 | - private $file; |
|
| 39 | - |
|
| 40 | - /** @var string */ |
|
| 41 | - private $userId; |
|
| 42 | - |
|
| 43 | - public function __construct(Folder $userFolder, File $file, string $userId) { |
|
| 44 | - $this->userFolder = $userFolder; |
|
| 45 | - $this->file = $file; |
|
| 46 | - $this->userId = $userId; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - public function createFile($name, $data = null) { |
|
| 50 | - throw new Forbidden(); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function createDirectory($name) { |
|
| 54 | - throw new Forbidden(); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - public function getChild($name) { |
|
| 58 | - /** @var VersionFile[] $versions */ |
|
| 59 | - $versions = $this->getChildren(); |
|
| 60 | - |
|
| 61 | - foreach ($versions as $version) { |
|
| 62 | - if ($version->getName() === $name) { |
|
| 63 | - return $version; |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - throw new NotFound(); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - public function getChildren(): array { |
|
| 71 | - $versions = Storage::getVersions($this->userId, $this->userFolder->getRelativePath($this->file->getPath())); |
|
| 72 | - |
|
| 73 | - return array_map(function (array $data) { |
|
| 74 | - return new VersionFile($data, $this->userFolder->getParent()); |
|
| 75 | - }, $versions); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - public function childExists($name): bool { |
|
| 79 | - try { |
|
| 80 | - $this->getChild($name); |
|
| 81 | - return true; |
|
| 82 | - } catch (NotFound $e) { |
|
| 83 | - return false; |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - public function delete() { |
|
| 88 | - throw new Forbidden(); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - public function getName(): string { |
|
| 92 | - return (string)$this->file->getId(); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function setName($name) { |
|
| 96 | - throw new Forbidden(); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - public function getLastModified(): int { |
|
| 100 | - return 0; |
|
| 101 | - } |
|
| 34 | + /** @var Folder */ |
|
| 35 | + private $userFolder; |
|
| 36 | + |
|
| 37 | + /** @var File */ |
|
| 38 | + private $file; |
|
| 39 | + |
|
| 40 | + /** @var string */ |
|
| 41 | + private $userId; |
|
| 42 | + |
|
| 43 | + public function __construct(Folder $userFolder, File $file, string $userId) { |
|
| 44 | + $this->userFolder = $userFolder; |
|
| 45 | + $this->file = $file; |
|
| 46 | + $this->userId = $userId; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + public function createFile($name, $data = null) { |
|
| 50 | + throw new Forbidden(); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function createDirectory($name) { |
|
| 54 | + throw new Forbidden(); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + public function getChild($name) { |
|
| 58 | + /** @var VersionFile[] $versions */ |
|
| 59 | + $versions = $this->getChildren(); |
|
| 60 | + |
|
| 61 | + foreach ($versions as $version) { |
|
| 62 | + if ($version->getName() === $name) { |
|
| 63 | + return $version; |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + throw new NotFound(); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + public function getChildren(): array { |
|
| 71 | + $versions = Storage::getVersions($this->userId, $this->userFolder->getRelativePath($this->file->getPath())); |
|
| 72 | + |
|
| 73 | + return array_map(function (array $data) { |
|
| 74 | + return new VersionFile($data, $this->userFolder->getParent()); |
|
| 75 | + }, $versions); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + public function childExists($name): bool { |
|
| 79 | + try { |
|
| 80 | + $this->getChild($name); |
|
| 81 | + return true; |
|
| 82 | + } catch (NotFound $e) { |
|
| 83 | + return false; |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + public function delete() { |
|
| 88 | + throw new Forbidden(); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + public function getName(): string { |
|
| 92 | + return (string)$this->file->getId(); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function setName($name) { |
|
| 96 | + throw new Forbidden(); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + public function getLastModified(): int { |
|
| 100 | + return 0; |
|
| 101 | + } |
|
| 102 | 102 | } |
@@ -30,36 +30,36 @@ |
||
| 30 | 30 | use OCA\Files_Versions\Capabilities; |
| 31 | 31 | |
| 32 | 32 | class Application extends App { |
| 33 | - public function __construct(array $urlParams = array()) { |
|
| 34 | - parent::__construct('files_versions', $urlParams); |
|
| 33 | + public function __construct(array $urlParams = array()) { |
|
| 34 | + parent::__construct('files_versions', $urlParams); |
|
| 35 | 35 | |
| 36 | - $container = $this->getContainer(); |
|
| 36 | + $container = $this->getContainer(); |
|
| 37 | 37 | |
| 38 | - /* |
|
| 38 | + /* |
|
| 39 | 39 | * Register capabilities |
| 40 | 40 | */ |
| 41 | - $container->registerCapability(Capabilities::class); |
|
| 41 | + $container->registerCapability(Capabilities::class); |
|
| 42 | 42 | |
| 43 | - /* |
|
| 43 | + /* |
|
| 44 | 44 | * Register expiration |
| 45 | 45 | */ |
| 46 | - $container->registerService('Expiration', function($c) { |
|
| 47 | - return new Expiration( |
|
| 48 | - $c->query('ServerContainer')->getConfig(), |
|
| 49 | - $c->query(ITimeFactory::class) |
|
| 50 | - ); |
|
| 51 | - }); |
|
| 46 | + $container->registerService('Expiration', function($c) { |
|
| 47 | + return new Expiration( |
|
| 48 | + $c->query('ServerContainer')->getConfig(), |
|
| 49 | + $c->query(ITimeFactory::class) |
|
| 50 | + ); |
|
| 51 | + }); |
|
| 52 | 52 | |
| 53 | - /* |
|
| 53 | + /* |
|
| 54 | 54 | * Register $principalBackend for the DAV collection |
| 55 | 55 | */ |
| 56 | - $container->registerService('principalBackend', function () { |
|
| 57 | - return new Principal( |
|
| 58 | - \OC::$server->getUserManager(), |
|
| 59 | - \OC::$server->getGroupManager(), |
|
| 60 | - \OC::$server->getShareManager(), |
|
| 61 | - \OC::$server->getUserSession() |
|
| 62 | - ); |
|
| 63 | - }); |
|
| 64 | - } |
|
| 56 | + $container->registerService('principalBackend', function () { |
|
| 57 | + return new Principal( |
|
| 58 | + \OC::$server->getUserManager(), |
|
| 59 | + \OC::$server->getGroupManager(), |
|
| 60 | + \OC::$server->getShareManager(), |
|
| 61 | + \OC::$server->getUserSession() |
|
| 62 | + ); |
|
| 63 | + }); |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | /* |
| 54 | 54 | * Register $principalBackend for the DAV collection |
| 55 | 55 | */ |
| 56 | - $container->registerService('principalBackend', function () { |
|
| 56 | + $container->registerService('principalBackend', function() { |
|
| 57 | 57 | return new Principal( |
| 58 | 58 | \OC::$server->getUserManager(), |
| 59 | 59 | \OC::$server->getGroupManager(), |
@@ -28,63 +28,63 @@ |
||
| 28 | 28 | |
| 29 | 29 | class VersionHome implements ICollection { |
| 30 | 30 | |
| 31 | - /** @var array */ |
|
| 32 | - private $principalInfo; |
|
| 33 | - |
|
| 34 | - /** @var IRootFolder */ |
|
| 35 | - private $rootFolder; |
|
| 36 | - |
|
| 37 | - public function __construct(array $principalInfo, IRootFolder $rootFolder) { |
|
| 38 | - $this->principalInfo = $principalInfo; |
|
| 39 | - $this->rootFolder = $rootFolder; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - public function delete() { |
|
| 43 | - throw new Forbidden(); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - public function getName(): string { |
|
| 47 | - list(,$name) = \Sabre\Uri\split($this->principalInfo['uri']); |
|
| 48 | - return $name; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function setName($name) { |
|
| 52 | - throw new Forbidden(); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - public function createFile($name, $data = null) { |
|
| 56 | - throw new Forbidden(); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - public function createDirectory($name) { |
|
| 60 | - throw new Forbidden(); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - public function getChild($name) { |
|
| 64 | - list(,$userId) = \Sabre\Uri\split($this->principalInfo['uri']); |
|
| 65 | - |
|
| 66 | - if ($name === 'versions') { |
|
| 67 | - return new VersionRoot($userId, $this->rootFolder); |
|
| 68 | - } |
|
| 69 | - if ($name === 'restore') { |
|
| 70 | - return new RestoreFolder($userId); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - public function getChildren() { |
|
| 75 | - list(,$userId) = \Sabre\Uri\split($this->principalInfo['uri']); |
|
| 76 | - |
|
| 77 | - return [ |
|
| 78 | - new VersionRoot($userId, $this->rootFolder), |
|
| 79 | - new RestoreFolder($userId), |
|
| 80 | - ]; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - public function childExists($name) { |
|
| 84 | - return $name === 'versions' || $name === 'restore'; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - public function getLastModified() { |
|
| 88 | - return 0; |
|
| 89 | - } |
|
| 31 | + /** @var array */ |
|
| 32 | + private $principalInfo; |
|
| 33 | + |
|
| 34 | + /** @var IRootFolder */ |
|
| 35 | + private $rootFolder; |
|
| 36 | + |
|
| 37 | + public function __construct(array $principalInfo, IRootFolder $rootFolder) { |
|
| 38 | + $this->principalInfo = $principalInfo; |
|
| 39 | + $this->rootFolder = $rootFolder; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + public function delete() { |
|
| 43 | + throw new Forbidden(); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + public function getName(): string { |
|
| 47 | + list(,$name) = \Sabre\Uri\split($this->principalInfo['uri']); |
|
| 48 | + return $name; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public function setName($name) { |
|
| 52 | + throw new Forbidden(); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + public function createFile($name, $data = null) { |
|
| 56 | + throw new Forbidden(); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + public function createDirectory($name) { |
|
| 60 | + throw new Forbidden(); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + public function getChild($name) { |
|
| 64 | + list(,$userId) = \Sabre\Uri\split($this->principalInfo['uri']); |
|
| 65 | + |
|
| 66 | + if ($name === 'versions') { |
|
| 67 | + return new VersionRoot($userId, $this->rootFolder); |
|
| 68 | + } |
|
| 69 | + if ($name === 'restore') { |
|
| 70 | + return new RestoreFolder($userId); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + public function getChildren() { |
|
| 75 | + list(,$userId) = \Sabre\Uri\split($this->principalInfo['uri']); |
|
| 76 | + |
|
| 77 | + return [ |
|
| 78 | + new VersionRoot($userId, $this->rootFolder), |
|
| 79 | + new RestoreFolder($userId), |
|
| 80 | + ]; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + public function childExists($name) { |
|
| 84 | + return $name === 'versions' || $name === 'restore'; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + public function getLastModified() { |
|
| 88 | + return 0; |
|
| 89 | + } |
|
| 90 | 90 | } |