@@ -37,24 +37,24 @@ |
||
37 | 37 | * @method string getNodeName() |
38 | 38 | */ |
39 | 39 | class TransferOwnership extends Entity { |
40 | - /** @var string */ |
|
41 | - protected $sourceUser; |
|
40 | + /** @var string */ |
|
41 | + protected $sourceUser; |
|
42 | 42 | |
43 | - /** @var string */ |
|
44 | - protected $targetUser; |
|
43 | + /** @var string */ |
|
44 | + protected $targetUser; |
|
45 | 45 | |
46 | - /** @var integer */ |
|
47 | - protected $fileId; |
|
46 | + /** @var integer */ |
|
47 | + protected $fileId; |
|
48 | 48 | |
49 | - /** @var string */ |
|
50 | - protected $nodeName; |
|
49 | + /** @var string */ |
|
50 | + protected $nodeName; |
|
51 | 51 | |
52 | - public function __construct() { |
|
53 | - $this->addType('sourceUser', 'string'); |
|
54 | - $this->addType('targetUser', 'string'); |
|
55 | - $this->addType('fileId', 'integer'); |
|
56 | - $this->addType('nodeName', 'string'); |
|
57 | - } |
|
52 | + public function __construct() { |
|
53 | + $this->addType('sourceUser', 'string'); |
|
54 | + $this->addType('targetUser', 'string'); |
|
55 | + $this->addType('fileId', 'integer'); |
|
56 | + $this->addType('nodeName', 'string'); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | 60 | } |
@@ -31,41 +31,41 @@ |
||
31 | 31 | */ |
32 | 32 | class UserCreatedEvent extends Event { |
33 | 33 | |
34 | - /** @var IUser */ |
|
35 | - private $user; |
|
34 | + /** @var IUser */ |
|
35 | + private $user; |
|
36 | 36 | |
37 | - /** @var string */ |
|
38 | - private $password; |
|
37 | + /** @var string */ |
|
38 | + private $password; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @since 18.0.0 |
|
42 | - */ |
|
43 | - public function __construct(IUser $user, |
|
44 | - string $password) { |
|
45 | - parent::__construct(); |
|
46 | - $this->user = $user; |
|
47 | - $this->password = $password; |
|
48 | - } |
|
40 | + /** |
|
41 | + * @since 18.0.0 |
|
42 | + */ |
|
43 | + public function __construct(IUser $user, |
|
44 | + string $password) { |
|
45 | + parent::__construct(); |
|
46 | + $this->user = $user; |
|
47 | + $this->password = $password; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @since 18.0.0 |
|
52 | - */ |
|
53 | - public function getUser(): IUser { |
|
54 | - return $this->user; |
|
55 | - } |
|
50 | + /** |
|
51 | + * @since 18.0.0 |
|
52 | + */ |
|
53 | + public function getUser(): IUser { |
|
54 | + return $this->user; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @since 18.0.0 |
|
59 | - */ |
|
60 | - public function getUid(): string { |
|
61 | - return $this->user->getUID(); |
|
62 | - } |
|
57 | + /** |
|
58 | + * @since 18.0.0 |
|
59 | + */ |
|
60 | + public function getUid(): string { |
|
61 | + return $this->user->getUID(); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @since 18.0.0 |
|
66 | - */ |
|
67 | - public function getPassword(): string { |
|
68 | - return $this->password; |
|
69 | - } |
|
64 | + /** |
|
65 | + * @since 18.0.0 |
|
66 | + */ |
|
67 | + public function getPassword(): string { |
|
68 | + return $this->password; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | } |
@@ -35,32 +35,32 @@ |
||
35 | 35 | */ |
36 | 36 | class RegistryEvent extends Event { |
37 | 37 | |
38 | - /** @var IProvider */ |
|
39 | - private $provider; |
|
38 | + /** @var IProvider */ |
|
39 | + private $provider; |
|
40 | 40 | |
41 | - /** @IUser */ |
|
42 | - private $user; |
|
41 | + /** @IUser */ |
|
42 | + private $user; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @since 15.0.0 |
|
46 | - */ |
|
47 | - public function __construct(IProvider $provider, IUser $user) { |
|
48 | - parent::__construct(); |
|
49 | - $this->provider = $provider; |
|
50 | - $this->user = $user; |
|
51 | - } |
|
44 | + /** |
|
45 | + * @since 15.0.0 |
|
46 | + */ |
|
47 | + public function __construct(IProvider $provider, IUser $user) { |
|
48 | + parent::__construct(); |
|
49 | + $this->provider = $provider; |
|
50 | + $this->user = $user; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @since 15.0.0 |
|
55 | - */ |
|
56 | - public function getProvider(): IProvider { |
|
57 | - return $this->provider; |
|
58 | - } |
|
53 | + /** |
|
54 | + * @since 15.0.0 |
|
55 | + */ |
|
56 | + public function getProvider(): IProvider { |
|
57 | + return $this->provider; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @since 15.0.0 |
|
62 | - */ |
|
63 | - public function getUser(): IUser { |
|
64 | - return $this->user; |
|
65 | - } |
|
60 | + /** |
|
61 | + * @since 15.0.0 |
|
62 | + */ |
|
63 | + public function getUser(): IUser { |
|
64 | + return $this->user; |
|
65 | + } |
|
66 | 66 | } |
@@ -32,83 +32,83 @@ |
||
32 | 32 | use OCP\IUser; |
33 | 33 | |
34 | 34 | class VersionManager implements IVersionManager { |
35 | - /** @var (IVersionBackend[])[] */ |
|
36 | - private $backends = []; |
|
37 | - |
|
38 | - public function registerBackend(string $storageType, IVersionBackend $backend) { |
|
39 | - if (!isset($this->backends[$storageType])) { |
|
40 | - $this->backends[$storageType] = []; |
|
41 | - } |
|
42 | - $this->backends[$storageType][] = $backend; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * @return (IVersionBackend[])[] |
|
47 | - */ |
|
48 | - private function getBackends(): array { |
|
49 | - return $this->backends; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @param IStorage $storage |
|
54 | - * @return IVersionBackend |
|
55 | - * @throws BackendNotFoundException |
|
56 | - */ |
|
57 | - public function getBackendForStorage(IStorage $storage): IVersionBackend { |
|
58 | - $fullType = get_class($storage); |
|
59 | - $backends = $this->getBackends(); |
|
60 | - |
|
61 | - $foundType = ''; |
|
62 | - $foundBackend = null; |
|
63 | - |
|
64 | - foreach ($backends as $type => $backendsForType) { |
|
65 | - if ( |
|
66 | - $storage->instanceOfStorage($type) && |
|
67 | - ($foundType === '' || is_subclass_of($type, $foundType)) |
|
68 | - ) { |
|
69 | - foreach ($backendsForType as $backend) { |
|
70 | - /** @var IVersionBackend $backend */ |
|
71 | - if ($backend->useBackendForStorage($storage)) { |
|
72 | - $foundBackend = $backend; |
|
73 | - $foundType = $type; |
|
74 | - } |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - if ($foundType === '' || $foundBackend === null) { |
|
80 | - throw new BackendNotFoundException("Version backend for $fullType not found"); |
|
81 | - } else { |
|
82 | - return $foundBackend; |
|
83 | - } |
|
84 | - } |
|
85 | - |
|
86 | - public function getVersionsForFile(IUser $user, FileInfo $file): array { |
|
87 | - $backend = $this->getBackendForStorage($file->getStorage()); |
|
88 | - return $backend->getVersionsForFile($user, $file); |
|
89 | - } |
|
90 | - |
|
91 | - public function createVersion(IUser $user, FileInfo $file) { |
|
92 | - $backend = $this->getBackendForStorage($file->getStorage()); |
|
93 | - $backend->createVersion($user, $file); |
|
94 | - } |
|
95 | - |
|
96 | - public function rollback(IVersion $version) { |
|
97 | - $backend = $version->getBackend(); |
|
98 | - return $backend->rollback($version); |
|
99 | - } |
|
100 | - |
|
101 | - public function read(IVersion $version) { |
|
102 | - $backend = $version->getBackend(); |
|
103 | - return $backend->read($version); |
|
104 | - } |
|
105 | - |
|
106 | - public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File { |
|
107 | - $backend = $this->getBackendForStorage($sourceFile->getStorage()); |
|
108 | - return $backend->getVersionFile($user, $sourceFile, $revision); |
|
109 | - } |
|
110 | - |
|
111 | - public function useBackendForStorage(IStorage $storage): bool { |
|
112 | - return false; |
|
113 | - } |
|
35 | + /** @var (IVersionBackend[])[] */ |
|
36 | + private $backends = []; |
|
37 | + |
|
38 | + public function registerBackend(string $storageType, IVersionBackend $backend) { |
|
39 | + if (!isset($this->backends[$storageType])) { |
|
40 | + $this->backends[$storageType] = []; |
|
41 | + } |
|
42 | + $this->backends[$storageType][] = $backend; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * @return (IVersionBackend[])[] |
|
47 | + */ |
|
48 | + private function getBackends(): array { |
|
49 | + return $this->backends; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @param IStorage $storage |
|
54 | + * @return IVersionBackend |
|
55 | + * @throws BackendNotFoundException |
|
56 | + */ |
|
57 | + public function getBackendForStorage(IStorage $storage): IVersionBackend { |
|
58 | + $fullType = get_class($storage); |
|
59 | + $backends = $this->getBackends(); |
|
60 | + |
|
61 | + $foundType = ''; |
|
62 | + $foundBackend = null; |
|
63 | + |
|
64 | + foreach ($backends as $type => $backendsForType) { |
|
65 | + if ( |
|
66 | + $storage->instanceOfStorage($type) && |
|
67 | + ($foundType === '' || is_subclass_of($type, $foundType)) |
|
68 | + ) { |
|
69 | + foreach ($backendsForType as $backend) { |
|
70 | + /** @var IVersionBackend $backend */ |
|
71 | + if ($backend->useBackendForStorage($storage)) { |
|
72 | + $foundBackend = $backend; |
|
73 | + $foundType = $type; |
|
74 | + } |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + if ($foundType === '' || $foundBackend === null) { |
|
80 | + throw new BackendNotFoundException("Version backend for $fullType not found"); |
|
81 | + } else { |
|
82 | + return $foundBackend; |
|
83 | + } |
|
84 | + } |
|
85 | + |
|
86 | + public function getVersionsForFile(IUser $user, FileInfo $file): array { |
|
87 | + $backend = $this->getBackendForStorage($file->getStorage()); |
|
88 | + return $backend->getVersionsForFile($user, $file); |
|
89 | + } |
|
90 | + |
|
91 | + public function createVersion(IUser $user, FileInfo $file) { |
|
92 | + $backend = $this->getBackendForStorage($file->getStorage()); |
|
93 | + $backend->createVersion($user, $file); |
|
94 | + } |
|
95 | + |
|
96 | + public function rollback(IVersion $version) { |
|
97 | + $backend = $version->getBackend(); |
|
98 | + return $backend->rollback($version); |
|
99 | + } |
|
100 | + |
|
101 | + public function read(IVersion $version) { |
|
102 | + $backend = $version->getBackend(); |
|
103 | + return $backend->read($version); |
|
104 | + } |
|
105 | + |
|
106 | + public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File { |
|
107 | + $backend = $this->getBackendForStorage($sourceFile->getStorage()); |
|
108 | + return $backend->getVersionFile($user, $sourceFile, $revision); |
|
109 | + } |
|
110 | + |
|
111 | + public function useBackendForStorage(IStorage $storage): bool { |
|
112 | + return false; |
|
113 | + } |
|
114 | 114 | } |
@@ -35,63 +35,63 @@ |
||
35 | 35 | |
36 | 36 | class Notifier implements INotifier { |
37 | 37 | |
38 | - /** @var IFactory */ |
|
39 | - private $factory; |
|
40 | - |
|
41 | - /** @var IURLGenerator */ |
|
42 | - private $url; |
|
43 | - |
|
44 | - public function __construct(IFactory $factory, IURLGenerator $url) { |
|
45 | - $this->factory = $factory; |
|
46 | - $this->url = $url; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Identifier of the notifier, only use [a-z0-9_] |
|
51 | - * |
|
52 | - * @return string |
|
53 | - * @since 17.0.0 |
|
54 | - */ |
|
55 | - public function getID(): string { |
|
56 | - return 'twofactor_backupcodes'; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * Human readable name describing the notifier |
|
61 | - * |
|
62 | - * @return string |
|
63 | - * @since 17.0.0 |
|
64 | - */ |
|
65 | - public function getName(): string { |
|
66 | - return $this->factory->get('twofactor_backupcodes')->t('Second-factor backup codes'); |
|
67 | - } |
|
68 | - |
|
69 | - public function prepare(INotification $notification, string $languageCode): INotification { |
|
70 | - if ($notification->getApp() !== 'twofactor_backupcodes') { |
|
71 | - // Not my app => throw |
|
72 | - throw new \InvalidArgumentException(); |
|
73 | - } |
|
74 | - |
|
75 | - // Read the language from the notification |
|
76 | - $l = $this->factory->get('twofactor_backupcodes', $languageCode); |
|
77 | - |
|
78 | - switch ($notification->getSubject()) { |
|
79 | - case 'create_backupcodes': |
|
80 | - $notification->setParsedSubject( |
|
81 | - $l->t('Generate backup codes') |
|
82 | - )->setParsedMessage( |
|
83 | - $l->t('You enabled two-factor authentication but did not generate backup codes yet. They are needed to restore access to your account in case you lose your second factor.') |
|
84 | - ); |
|
85 | - |
|
86 | - $notification->setLink($this->url->linkToRouteAbsolute('settings.PersonalSettings.index', ['section' => 'security'])); |
|
87 | - |
|
88 | - $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/password.svg'))); |
|
89 | - |
|
90 | - return $notification; |
|
91 | - |
|
92 | - default: |
|
93 | - // Unknown subject => Unknown notification => throw |
|
94 | - throw new \InvalidArgumentException(); |
|
95 | - } |
|
96 | - } |
|
38 | + /** @var IFactory */ |
|
39 | + private $factory; |
|
40 | + |
|
41 | + /** @var IURLGenerator */ |
|
42 | + private $url; |
|
43 | + |
|
44 | + public function __construct(IFactory $factory, IURLGenerator $url) { |
|
45 | + $this->factory = $factory; |
|
46 | + $this->url = $url; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Identifier of the notifier, only use [a-z0-9_] |
|
51 | + * |
|
52 | + * @return string |
|
53 | + * @since 17.0.0 |
|
54 | + */ |
|
55 | + public function getID(): string { |
|
56 | + return 'twofactor_backupcodes'; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * Human readable name describing the notifier |
|
61 | + * |
|
62 | + * @return string |
|
63 | + * @since 17.0.0 |
|
64 | + */ |
|
65 | + public function getName(): string { |
|
66 | + return $this->factory->get('twofactor_backupcodes')->t('Second-factor backup codes'); |
|
67 | + } |
|
68 | + |
|
69 | + public function prepare(INotification $notification, string $languageCode): INotification { |
|
70 | + if ($notification->getApp() !== 'twofactor_backupcodes') { |
|
71 | + // Not my app => throw |
|
72 | + throw new \InvalidArgumentException(); |
|
73 | + } |
|
74 | + |
|
75 | + // Read the language from the notification |
|
76 | + $l = $this->factory->get('twofactor_backupcodes', $languageCode); |
|
77 | + |
|
78 | + switch ($notification->getSubject()) { |
|
79 | + case 'create_backupcodes': |
|
80 | + $notification->setParsedSubject( |
|
81 | + $l->t('Generate backup codes') |
|
82 | + )->setParsedMessage( |
|
83 | + $l->t('You enabled two-factor authentication but did not generate backup codes yet. They are needed to restore access to your account in case you lose your second factor.') |
|
84 | + ); |
|
85 | + |
|
86 | + $notification->setLink($this->url->linkToRouteAbsolute('settings.PersonalSettings.index', ['section' => 'security'])); |
|
87 | + |
|
88 | + $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/password.svg'))); |
|
89 | + |
|
90 | + return $notification; |
|
91 | + |
|
92 | + default: |
|
93 | + // Unknown subject => Unknown notification => throw |
|
94 | + throw new \InvalidArgumentException(); |
|
95 | + } |
|
96 | + } |
|
97 | 97 | } |
@@ -34,94 +34,94 @@ |
||
34 | 34 | */ |
35 | 35 | interface IManager extends IProvider { |
36 | 36 | |
37 | - /** |
|
38 | - * @param int $id |
|
39 | - * @return ICollection |
|
40 | - * @throws CollectionException when the collection could not be found |
|
41 | - * @since 16.0.0 |
|
42 | - */ |
|
43 | - public function getCollection(int $id): ICollection; |
|
44 | - |
|
45 | - /** |
|
46 | - * @param int $id |
|
47 | - * @param IUser|null $user |
|
48 | - * @return ICollection |
|
49 | - * @throws CollectionException when the collection could not be found |
|
50 | - * @since 16.0.0 |
|
51 | - */ |
|
52 | - public function getCollectionForUser(int $id, ?IUser $user): ICollection; |
|
53 | - |
|
54 | - /** |
|
55 | - * @param string $name |
|
56 | - * @return ICollection |
|
57 | - * @since 16.0.0 |
|
58 | - */ |
|
59 | - public function newCollection(string $name): ICollection; |
|
60 | - |
|
61 | - /** |
|
62 | - * Can a user/guest access the collection |
|
63 | - * |
|
64 | - * @param ICollection $collection |
|
65 | - * @param IUser|null $user |
|
66 | - * @return bool |
|
67 | - * @since 16.0.0 |
|
68 | - */ |
|
69 | - public function canAccessCollection(ICollection $collection, ?IUser $user): bool; |
|
70 | - |
|
71 | - /** |
|
72 | - * @param IUser|null $user |
|
73 | - * @since 16.0.0 |
|
74 | - */ |
|
75 | - public function invalidateAccessCacheForUser(?IUser $user): void; |
|
76 | - |
|
77 | - /** |
|
78 | - * @param IResource $resource |
|
79 | - * @since 16.0.0 |
|
80 | - */ |
|
81 | - public function invalidateAccessCacheForResource(IResource $resource): void; |
|
82 | - |
|
83 | - /** |
|
84 | - * @param IResource $resource |
|
85 | - * @param IUser|null $user |
|
86 | - * @since 16.0.0 |
|
87 | - */ |
|
88 | - public function invalidateAccessCacheForResourceByUser(IResource $resource, ?IUser $user): void; |
|
89 | - |
|
90 | - /** |
|
91 | - * @param IProvider $provider |
|
92 | - * @since 16.0.0 |
|
93 | - */ |
|
94 | - public function invalidateAccessCacheForProvider(IProvider $provider): void; |
|
95 | - |
|
96 | - /** |
|
97 | - * @param IProvider $provider |
|
98 | - * @param IUser|null $user |
|
99 | - * @since 16.0.0 |
|
100 | - */ |
|
101 | - public function invalidateAccessCacheForProviderByUser(IProvider $provider, ?IUser $user): void; |
|
102 | - |
|
103 | - /** |
|
104 | - * @param string $type |
|
105 | - * @param string $id |
|
106 | - * @return IResource |
|
107 | - * @since 16.0.0 |
|
108 | - */ |
|
109 | - public function createResource(string $type, string $id): IResource; |
|
110 | - |
|
111 | - /** |
|
112 | - * @param string $type |
|
113 | - * @param string $id |
|
114 | - * @param IUser|null $user |
|
115 | - * @return IResource |
|
116 | - * @throws ResourceException |
|
117 | - * @since 16.0.0 |
|
118 | - */ |
|
119 | - public function getResourceForUser(string $type, string $id, ?IUser $user): IResource; |
|
120 | - |
|
121 | - /** |
|
122 | - * @param string $provider |
|
123 | - * @since 16.0.0 |
|
124 | - * @deprecated 18.0.0 Use IProviderManager::registerResourceProvider instead |
|
125 | - */ |
|
126 | - public function registerResourceProvider(string $provider): void; |
|
37 | + /** |
|
38 | + * @param int $id |
|
39 | + * @return ICollection |
|
40 | + * @throws CollectionException when the collection could not be found |
|
41 | + * @since 16.0.0 |
|
42 | + */ |
|
43 | + public function getCollection(int $id): ICollection; |
|
44 | + |
|
45 | + /** |
|
46 | + * @param int $id |
|
47 | + * @param IUser|null $user |
|
48 | + * @return ICollection |
|
49 | + * @throws CollectionException when the collection could not be found |
|
50 | + * @since 16.0.0 |
|
51 | + */ |
|
52 | + public function getCollectionForUser(int $id, ?IUser $user): ICollection; |
|
53 | + |
|
54 | + /** |
|
55 | + * @param string $name |
|
56 | + * @return ICollection |
|
57 | + * @since 16.0.0 |
|
58 | + */ |
|
59 | + public function newCollection(string $name): ICollection; |
|
60 | + |
|
61 | + /** |
|
62 | + * Can a user/guest access the collection |
|
63 | + * |
|
64 | + * @param ICollection $collection |
|
65 | + * @param IUser|null $user |
|
66 | + * @return bool |
|
67 | + * @since 16.0.0 |
|
68 | + */ |
|
69 | + public function canAccessCollection(ICollection $collection, ?IUser $user): bool; |
|
70 | + |
|
71 | + /** |
|
72 | + * @param IUser|null $user |
|
73 | + * @since 16.0.0 |
|
74 | + */ |
|
75 | + public function invalidateAccessCacheForUser(?IUser $user): void; |
|
76 | + |
|
77 | + /** |
|
78 | + * @param IResource $resource |
|
79 | + * @since 16.0.0 |
|
80 | + */ |
|
81 | + public function invalidateAccessCacheForResource(IResource $resource): void; |
|
82 | + |
|
83 | + /** |
|
84 | + * @param IResource $resource |
|
85 | + * @param IUser|null $user |
|
86 | + * @since 16.0.0 |
|
87 | + */ |
|
88 | + public function invalidateAccessCacheForResourceByUser(IResource $resource, ?IUser $user): void; |
|
89 | + |
|
90 | + /** |
|
91 | + * @param IProvider $provider |
|
92 | + * @since 16.0.0 |
|
93 | + */ |
|
94 | + public function invalidateAccessCacheForProvider(IProvider $provider): void; |
|
95 | + |
|
96 | + /** |
|
97 | + * @param IProvider $provider |
|
98 | + * @param IUser|null $user |
|
99 | + * @since 16.0.0 |
|
100 | + */ |
|
101 | + public function invalidateAccessCacheForProviderByUser(IProvider $provider, ?IUser $user): void; |
|
102 | + |
|
103 | + /** |
|
104 | + * @param string $type |
|
105 | + * @param string $id |
|
106 | + * @return IResource |
|
107 | + * @since 16.0.0 |
|
108 | + */ |
|
109 | + public function createResource(string $type, string $id): IResource; |
|
110 | + |
|
111 | + /** |
|
112 | + * @param string $type |
|
113 | + * @param string $id |
|
114 | + * @param IUser|null $user |
|
115 | + * @return IResource |
|
116 | + * @throws ResourceException |
|
117 | + * @since 16.0.0 |
|
118 | + */ |
|
119 | + public function getResourceForUser(string $type, string $id, ?IUser $user): IResource; |
|
120 | + |
|
121 | + /** |
|
122 | + * @param string $provider |
|
123 | + * @since 16.0.0 |
|
124 | + * @deprecated 18.0.0 Use IProviderManager::registerResourceProvider instead |
|
125 | + */ |
|
126 | + public function registerResourceProvider(string $provider): void; |
|
127 | 127 | } |
@@ -27,15 +27,15 @@ |
||
27 | 27 | */ |
28 | 28 | interface IProviderManager { |
29 | 29 | |
30 | - /** |
|
31 | - * @return IProvider[] list of resource providers |
|
32 | - * @since 18.0.0 |
|
33 | - */ |
|
34 | - public function getResourceProviders(): array; |
|
30 | + /** |
|
31 | + * @return IProvider[] list of resource providers |
|
32 | + * @since 18.0.0 |
|
33 | + */ |
|
34 | + public function getResourceProviders(): array; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param string $provider provider's class name |
|
38 | - * @since 18.0.0 |
|
39 | - */ |
|
40 | - public function registerResourceProvider(string $provider): void; |
|
36 | + /** |
|
37 | + * @param string $provider provider's class name |
|
38 | + * @since 18.0.0 |
|
39 | + */ |
|
40 | + public function registerResourceProvider(string $provider): void; |
|
41 | 41 | } |
@@ -40,90 +40,90 @@ |
||
40 | 40 | use OCP\IUserManager; |
41 | 41 | |
42 | 42 | class LegacyVersionsBackend implements IVersionBackend { |
43 | - /** @var IRootFolder */ |
|
44 | - private $rootFolder; |
|
45 | - /** @var IUserManager */ |
|
46 | - private $userManager; |
|
47 | - |
|
48 | - public function __construct(IRootFolder $rootFolder, IUserManager $userManager) { |
|
49 | - $this->rootFolder = $rootFolder; |
|
50 | - $this->userManager = $userManager; |
|
51 | - } |
|
52 | - |
|
53 | - public function useBackendForStorage(IStorage $storage): bool { |
|
54 | - return true; |
|
55 | - } |
|
56 | - |
|
57 | - public function getVersionsForFile(IUser $user, FileInfo $file): array { |
|
58 | - $storage = $file->getStorage(); |
|
59 | - if ($storage->instanceOfStorage(SharedStorage::class)) { |
|
60 | - $owner = $storage->getOwner(''); |
|
61 | - $user = $this->userManager->get($owner); |
|
62 | - } |
|
63 | - |
|
64 | - $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
65 | - $nodes = $userFolder->getById($file->getId()); |
|
66 | - $file2 = array_pop($nodes); |
|
67 | - $versions = Storage::getVersions($user->getUID(), $userFolder->getRelativePath($file2->getPath())); |
|
68 | - |
|
69 | - return array_map(function (array $data) use ($file, $user) { |
|
70 | - return new Version( |
|
71 | - (int)$data['version'], |
|
72 | - (int)$data['version'], |
|
73 | - $data['name'], |
|
74 | - (int)$data['size'], |
|
75 | - $data['mimetype'], |
|
76 | - $data['path'], |
|
77 | - $file, |
|
78 | - $this, |
|
79 | - $user |
|
80 | - ); |
|
81 | - }, $versions); |
|
82 | - } |
|
83 | - |
|
84 | - public function createVersion(IUser $user, FileInfo $file) { |
|
85 | - $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
86 | - $relativePath = $userFolder->getRelativePath($file->getPath()); |
|
87 | - $userView = new View('/' . $user->getUID()); |
|
88 | - // create all parent folders |
|
89 | - Storage::createMissingDirectories($relativePath, $userView); |
|
90 | - |
|
91 | - Storage::scheduleExpire($user->getUID(), $relativePath); |
|
92 | - |
|
93 | - // store a new version of a file |
|
94 | - $userView->copy('files/' . $relativePath, 'files_versions/' . $relativePath . '.v' . $file->getMtime()); |
|
95 | - // ensure the file is scanned |
|
96 | - $userView->getFileInfo('files_versions/' . $relativePath . '.v' . $file->getMtime()); |
|
97 | - } |
|
98 | - |
|
99 | - public function rollback(IVersion $version) { |
|
100 | - return Storage::rollback($version->getVersionPath(), $version->getRevisionId(), $version->getUser()); |
|
101 | - } |
|
102 | - |
|
103 | - private function getVersionFolder(IUser $user): Folder { |
|
104 | - $userRoot = $this->rootFolder->getUserFolder($user->getUID()) |
|
105 | - ->getParent(); |
|
106 | - try { |
|
107 | - /** @var Folder $folder */ |
|
108 | - $folder = $userRoot->get('files_versions'); |
|
109 | - return $folder; |
|
110 | - } catch (NotFoundException $e) { |
|
111 | - return $userRoot->newFolder('files_versions'); |
|
112 | - } |
|
113 | - } |
|
114 | - |
|
115 | - public function read(IVersion $version) { |
|
116 | - $versions = $this->getVersionFolder($version->getUser()); |
|
117 | - /** @var File $file */ |
|
118 | - $file = $versions->get($version->getVersionPath() . '.v' . $version->getRevisionId()); |
|
119 | - return $file->fopen('r'); |
|
120 | - } |
|
121 | - |
|
122 | - public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File { |
|
123 | - $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
124 | - $versionFolder = $this->getVersionFolder($user); |
|
125 | - /** @var File $file */ |
|
126 | - $file = $versionFolder->get($userFolder->getRelativePath($sourceFile->getPath()) . '.v' . $revision); |
|
127 | - return $file; |
|
128 | - } |
|
43 | + /** @var IRootFolder */ |
|
44 | + private $rootFolder; |
|
45 | + /** @var IUserManager */ |
|
46 | + private $userManager; |
|
47 | + |
|
48 | + public function __construct(IRootFolder $rootFolder, IUserManager $userManager) { |
|
49 | + $this->rootFolder = $rootFolder; |
|
50 | + $this->userManager = $userManager; |
|
51 | + } |
|
52 | + |
|
53 | + public function useBackendForStorage(IStorage $storage): bool { |
|
54 | + return true; |
|
55 | + } |
|
56 | + |
|
57 | + public function getVersionsForFile(IUser $user, FileInfo $file): array { |
|
58 | + $storage = $file->getStorage(); |
|
59 | + if ($storage->instanceOfStorage(SharedStorage::class)) { |
|
60 | + $owner = $storage->getOwner(''); |
|
61 | + $user = $this->userManager->get($owner); |
|
62 | + } |
|
63 | + |
|
64 | + $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
65 | + $nodes = $userFolder->getById($file->getId()); |
|
66 | + $file2 = array_pop($nodes); |
|
67 | + $versions = Storage::getVersions($user->getUID(), $userFolder->getRelativePath($file2->getPath())); |
|
68 | + |
|
69 | + return array_map(function (array $data) use ($file, $user) { |
|
70 | + return new Version( |
|
71 | + (int)$data['version'], |
|
72 | + (int)$data['version'], |
|
73 | + $data['name'], |
|
74 | + (int)$data['size'], |
|
75 | + $data['mimetype'], |
|
76 | + $data['path'], |
|
77 | + $file, |
|
78 | + $this, |
|
79 | + $user |
|
80 | + ); |
|
81 | + }, $versions); |
|
82 | + } |
|
83 | + |
|
84 | + public function createVersion(IUser $user, FileInfo $file) { |
|
85 | + $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
86 | + $relativePath = $userFolder->getRelativePath($file->getPath()); |
|
87 | + $userView = new View('/' . $user->getUID()); |
|
88 | + // create all parent folders |
|
89 | + Storage::createMissingDirectories($relativePath, $userView); |
|
90 | + |
|
91 | + Storage::scheduleExpire($user->getUID(), $relativePath); |
|
92 | + |
|
93 | + // store a new version of a file |
|
94 | + $userView->copy('files/' . $relativePath, 'files_versions/' . $relativePath . '.v' . $file->getMtime()); |
|
95 | + // ensure the file is scanned |
|
96 | + $userView->getFileInfo('files_versions/' . $relativePath . '.v' . $file->getMtime()); |
|
97 | + } |
|
98 | + |
|
99 | + public function rollback(IVersion $version) { |
|
100 | + return Storage::rollback($version->getVersionPath(), $version->getRevisionId(), $version->getUser()); |
|
101 | + } |
|
102 | + |
|
103 | + private function getVersionFolder(IUser $user): Folder { |
|
104 | + $userRoot = $this->rootFolder->getUserFolder($user->getUID()) |
|
105 | + ->getParent(); |
|
106 | + try { |
|
107 | + /** @var Folder $folder */ |
|
108 | + $folder = $userRoot->get('files_versions'); |
|
109 | + return $folder; |
|
110 | + } catch (NotFoundException $e) { |
|
111 | + return $userRoot->newFolder('files_versions'); |
|
112 | + } |
|
113 | + } |
|
114 | + |
|
115 | + public function read(IVersion $version) { |
|
116 | + $versions = $this->getVersionFolder($version->getUser()); |
|
117 | + /** @var File $file */ |
|
118 | + $file = $versions->get($version->getVersionPath() . '.v' . $version->getRevisionId()); |
|
119 | + return $file->fopen('r'); |
|
120 | + } |
|
121 | + |
|
122 | + public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File { |
|
123 | + $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
124 | + $versionFolder = $this->getVersionFolder($user); |
|
125 | + /** @var File $file */ |
|
126 | + $file = $versionFolder->get($userFolder->getRelativePath($sourceFile->getPath()) . '.v' . $revision); |
|
127 | + return $file; |
|
128 | + } |
|
129 | 129 | } |
@@ -35,11 +35,11 @@ |
||
35 | 35 | */ |
36 | 36 | interface IDismissableNotifier extends INotifier { |
37 | 37 | |
38 | - /** |
|
39 | - * @param INotification $notification |
|
40 | - * @throws \InvalidArgumentException In case the handler can't handle the notification |
|
41 | - * |
|
42 | - * @since 18.0.0 |
|
43 | - */ |
|
44 | - public function dismissNotification(INotification $notification): void; |
|
38 | + /** |
|
39 | + * @param INotification $notification |
|
40 | + * @throws \InvalidArgumentException In case the handler can't handle the notification |
|
41 | + * |
|
42 | + * @since 18.0.0 |
|
43 | + */ |
|
44 | + public function dismissNotification(INotification $notification): void; |
|
45 | 45 | } |