@@ -32,11 +32,11 @@ |
||
32 | 32 | */ |
33 | 33 | interface IDataLogger { |
34 | 34 | |
35 | - /** |
|
36 | - * allows to log custom data, similar to how logException works |
|
37 | - * |
|
38 | - * @since 18.0.1 |
|
39 | - */ |
|
40 | - public function logData(string $message, array $data, array $context = []): void; |
|
35 | + /** |
|
36 | + * allows to log custom data, similar to how logException works |
|
37 | + * |
|
38 | + * @since 18.0.1 |
|
39 | + */ |
|
40 | + public function logData(string $message, array $data, array $context = []): void; |
|
41 | 41 | |
42 | 42 | } |
@@ -32,15 +32,15 @@ |
||
32 | 32 | use Doctrine\DBAL\TransactionIsolationLevel; |
33 | 33 | |
34 | 34 | class SetTransactionIsolationLevel implements EventSubscriber { |
35 | - /** |
|
36 | - * @param ConnectionEventArgs $args |
|
37 | - * @return void |
|
38 | - */ |
|
39 | - public function postConnect(ConnectionEventArgs $args) { |
|
40 | - $args->getConnection()->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @param ConnectionEventArgs $args |
|
37 | + * @return void |
|
38 | + */ |
|
39 | + public function postConnect(ConnectionEventArgs $args) { |
|
40 | + $args->getConnection()->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED); |
|
41 | + } |
|
42 | 42 | |
43 | - public function getSubscribedEvents() { |
|
44 | - return [Events::postConnect]; |
|
45 | - } |
|
43 | + public function getSubscribedEvents() { |
|
44 | + return [Events::postConnect]; |
|
45 | + } |
|
46 | 46 | } |
@@ -32,42 +32,42 @@ |
||
32 | 32 | */ |
33 | 33 | interface ICalendarProvider { |
34 | 34 | |
35 | - /** |
|
36 | - * Provides the appId of the plugin |
|
37 | - * |
|
38 | - * @since 19.0.0 |
|
39 | - * @return string AppId |
|
40 | - */ |
|
41 | - public function getAppId(): string; |
|
35 | + /** |
|
36 | + * Provides the appId of the plugin |
|
37 | + * |
|
38 | + * @since 19.0.0 |
|
39 | + * @return string AppId |
|
40 | + */ |
|
41 | + public function getAppId(): string; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Fetches all calendars for a given principal uri |
|
45 | - * |
|
46 | - * @since 19.0.0 |
|
47 | - * @param string $principalUri E.g. principals/users/user1 |
|
48 | - * @return ExternalCalendar[] Array of all calendars |
|
49 | - */ |
|
50 | - public function fetchAllForCalendarHome(string $principalUri): array; |
|
43 | + /** |
|
44 | + * Fetches all calendars for a given principal uri |
|
45 | + * |
|
46 | + * @since 19.0.0 |
|
47 | + * @param string $principalUri E.g. principals/users/user1 |
|
48 | + * @return ExternalCalendar[] Array of all calendars |
|
49 | + */ |
|
50 | + public function fetchAllForCalendarHome(string $principalUri): array; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Checks whether plugin has a calendar for a given principalUri and calendarUri |
|
54 | - * |
|
55 | - * @since 19.0.0 |
|
56 | - * @param string $principalUri E.g. principals/users/user1 |
|
57 | - * @param string $calendarUri E.g. personal |
|
58 | - * @return bool True if calendar for principalUri and calendarUri exists, false otherwise |
|
59 | - */ |
|
60 | - public function hasCalendarInCalendarHome(string $principalUri, string $calendarUri): bool; |
|
52 | + /** |
|
53 | + * Checks whether plugin has a calendar for a given principalUri and calendarUri |
|
54 | + * |
|
55 | + * @since 19.0.0 |
|
56 | + * @param string $principalUri E.g. principals/users/user1 |
|
57 | + * @param string $calendarUri E.g. personal |
|
58 | + * @return bool True if calendar for principalUri and calendarUri exists, false otherwise |
|
59 | + */ |
|
60 | + public function hasCalendarInCalendarHome(string $principalUri, string $calendarUri): bool; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Fetches a calendar for a given principalUri and calendarUri |
|
64 | - * Returns null if calendar does not exist |
|
65 | - * |
|
66 | - * @since 19.0.0 |
|
67 | - * @param string $principalUri E.g. principals/users/user1 |
|
68 | - * @param string $calendarUri E.g. personal |
|
69 | - * @return ExternalCalendar|null Calendar if it exists, null otherwise |
|
70 | - */ |
|
71 | - public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar; |
|
62 | + /** |
|
63 | + * Fetches a calendar for a given principalUri and calendarUri |
|
64 | + * Returns null if calendar does not exist |
|
65 | + * |
|
66 | + * @since 19.0.0 |
|
67 | + * @param string $principalUri E.g. principals/users/user1 |
|
68 | + * @param string $calendarUri E.g. personal |
|
69 | + * @return ExternalCalendar|null Calendar if it exists, null otherwise |
|
70 | + */ |
|
71 | + public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar; |
|
72 | 72 | |
73 | 73 | } |
@@ -27,147 +27,147 @@ |
||
27 | 27 | use OCP\Files\NotFoundException; |
28 | 28 | |
29 | 29 | class NonExistingFolder extends Folder { |
30 | - /** |
|
31 | - * @param string $newPath |
|
32 | - * @throws \OCP\Files\NotFoundException |
|
33 | - */ |
|
34 | - public function rename($newPath) { |
|
35 | - throw new NotFoundException(); |
|
36 | - } |
|
37 | - |
|
38 | - public function delete() { |
|
39 | - throw new NotFoundException(); |
|
40 | - } |
|
41 | - |
|
42 | - public function copy($newPath) { |
|
43 | - throw new NotFoundException(); |
|
44 | - } |
|
45 | - |
|
46 | - public function touch($mtime = null) { |
|
47 | - throw new NotFoundException(); |
|
48 | - } |
|
49 | - |
|
50 | - public function getId() { |
|
51 | - if ($this->fileInfo) { |
|
52 | - return parent::getId(); |
|
53 | - } else { |
|
54 | - throw new NotFoundException(); |
|
55 | - } |
|
56 | - } |
|
57 | - |
|
58 | - public function stat() { |
|
59 | - throw new NotFoundException(); |
|
60 | - } |
|
61 | - |
|
62 | - public function getMTime() { |
|
63 | - if ($this->fileInfo) { |
|
64 | - return parent::getMTime(); |
|
65 | - } else { |
|
66 | - throw new NotFoundException(); |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - public function getSize($includeMounts = true) { |
|
71 | - if ($this->fileInfo) { |
|
72 | - return parent::getSize($includeMounts); |
|
73 | - } else { |
|
74 | - throw new NotFoundException(); |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - public function getEtag() { |
|
79 | - if ($this->fileInfo) { |
|
80 | - return parent::getEtag(); |
|
81 | - } else { |
|
82 | - throw new NotFoundException(); |
|
83 | - } |
|
84 | - } |
|
85 | - |
|
86 | - public function getPermissions() { |
|
87 | - if ($this->fileInfo) { |
|
88 | - return parent::getPermissions(); |
|
89 | - } else { |
|
90 | - throw new NotFoundException(); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - public function isReadable() { |
|
95 | - if ($this->fileInfo) { |
|
96 | - return parent::isReadable(); |
|
97 | - } else { |
|
98 | - throw new NotFoundException(); |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - public function isUpdateable() { |
|
103 | - if ($this->fileInfo) { |
|
104 | - return parent::isUpdateable(); |
|
105 | - } else { |
|
106 | - throw new NotFoundException(); |
|
107 | - } |
|
108 | - } |
|
109 | - |
|
110 | - public function isDeletable() { |
|
111 | - if ($this->fileInfo) { |
|
112 | - return parent::isDeletable(); |
|
113 | - } else { |
|
114 | - throw new NotFoundException(); |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - public function isShareable() { |
|
119 | - if ($this->fileInfo) { |
|
120 | - return parent::isShareable(); |
|
121 | - } else { |
|
122 | - throw new NotFoundException(); |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - public function get($path) { |
|
127 | - throw new NotFoundException(); |
|
128 | - } |
|
129 | - |
|
130 | - public function getDirectoryListing() { |
|
131 | - throw new NotFoundException(); |
|
132 | - } |
|
133 | - |
|
134 | - public function nodeExists($path) { |
|
135 | - return false; |
|
136 | - } |
|
137 | - |
|
138 | - public function newFolder($path) { |
|
139 | - throw new NotFoundException(); |
|
140 | - } |
|
141 | - |
|
142 | - public function newFile($path, $content = null) { |
|
143 | - throw new NotFoundException(); |
|
144 | - } |
|
145 | - |
|
146 | - public function search($pattern) { |
|
147 | - throw new NotFoundException(); |
|
148 | - } |
|
149 | - |
|
150 | - public function searchByMime($mime) { |
|
151 | - throw new NotFoundException(); |
|
152 | - } |
|
153 | - |
|
154 | - public function searchByTag($tag, $userId) { |
|
155 | - throw new NotFoundException(); |
|
156 | - } |
|
157 | - |
|
158 | - public function getById($id) { |
|
159 | - throw new NotFoundException(); |
|
160 | - } |
|
161 | - |
|
162 | - public function getFreeSpace() { |
|
163 | - throw new NotFoundException(); |
|
164 | - } |
|
165 | - |
|
166 | - public function isCreatable() { |
|
167 | - if ($this->fileInfo) { |
|
168 | - return parent::isCreatable(); |
|
169 | - } else { |
|
170 | - throw new NotFoundException(); |
|
171 | - } |
|
172 | - } |
|
30 | + /** |
|
31 | + * @param string $newPath |
|
32 | + * @throws \OCP\Files\NotFoundException |
|
33 | + */ |
|
34 | + public function rename($newPath) { |
|
35 | + throw new NotFoundException(); |
|
36 | + } |
|
37 | + |
|
38 | + public function delete() { |
|
39 | + throw new NotFoundException(); |
|
40 | + } |
|
41 | + |
|
42 | + public function copy($newPath) { |
|
43 | + throw new NotFoundException(); |
|
44 | + } |
|
45 | + |
|
46 | + public function touch($mtime = null) { |
|
47 | + throw new NotFoundException(); |
|
48 | + } |
|
49 | + |
|
50 | + public function getId() { |
|
51 | + if ($this->fileInfo) { |
|
52 | + return parent::getId(); |
|
53 | + } else { |
|
54 | + throw new NotFoundException(); |
|
55 | + } |
|
56 | + } |
|
57 | + |
|
58 | + public function stat() { |
|
59 | + throw new NotFoundException(); |
|
60 | + } |
|
61 | + |
|
62 | + public function getMTime() { |
|
63 | + if ($this->fileInfo) { |
|
64 | + return parent::getMTime(); |
|
65 | + } else { |
|
66 | + throw new NotFoundException(); |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + public function getSize($includeMounts = true) { |
|
71 | + if ($this->fileInfo) { |
|
72 | + return parent::getSize($includeMounts); |
|
73 | + } else { |
|
74 | + throw new NotFoundException(); |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + public function getEtag() { |
|
79 | + if ($this->fileInfo) { |
|
80 | + return parent::getEtag(); |
|
81 | + } else { |
|
82 | + throw new NotFoundException(); |
|
83 | + } |
|
84 | + } |
|
85 | + |
|
86 | + public function getPermissions() { |
|
87 | + if ($this->fileInfo) { |
|
88 | + return parent::getPermissions(); |
|
89 | + } else { |
|
90 | + throw new NotFoundException(); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + public function isReadable() { |
|
95 | + if ($this->fileInfo) { |
|
96 | + return parent::isReadable(); |
|
97 | + } else { |
|
98 | + throw new NotFoundException(); |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + public function isUpdateable() { |
|
103 | + if ($this->fileInfo) { |
|
104 | + return parent::isUpdateable(); |
|
105 | + } else { |
|
106 | + throw new NotFoundException(); |
|
107 | + } |
|
108 | + } |
|
109 | + |
|
110 | + public function isDeletable() { |
|
111 | + if ($this->fileInfo) { |
|
112 | + return parent::isDeletable(); |
|
113 | + } else { |
|
114 | + throw new NotFoundException(); |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + public function isShareable() { |
|
119 | + if ($this->fileInfo) { |
|
120 | + return parent::isShareable(); |
|
121 | + } else { |
|
122 | + throw new NotFoundException(); |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + public function get($path) { |
|
127 | + throw new NotFoundException(); |
|
128 | + } |
|
129 | + |
|
130 | + public function getDirectoryListing() { |
|
131 | + throw new NotFoundException(); |
|
132 | + } |
|
133 | + |
|
134 | + public function nodeExists($path) { |
|
135 | + return false; |
|
136 | + } |
|
137 | + |
|
138 | + public function newFolder($path) { |
|
139 | + throw new NotFoundException(); |
|
140 | + } |
|
141 | + |
|
142 | + public function newFile($path, $content = null) { |
|
143 | + throw new NotFoundException(); |
|
144 | + } |
|
145 | + |
|
146 | + public function search($pattern) { |
|
147 | + throw new NotFoundException(); |
|
148 | + } |
|
149 | + |
|
150 | + public function searchByMime($mime) { |
|
151 | + throw new NotFoundException(); |
|
152 | + } |
|
153 | + |
|
154 | + public function searchByTag($tag, $userId) { |
|
155 | + throw new NotFoundException(); |
|
156 | + } |
|
157 | + |
|
158 | + public function getById($id) { |
|
159 | + throw new NotFoundException(); |
|
160 | + } |
|
161 | + |
|
162 | + public function getFreeSpace() { |
|
163 | + throw new NotFoundException(); |
|
164 | + } |
|
165 | + |
|
166 | + public function isCreatable() { |
|
167 | + if ($this->fileInfo) { |
|
168 | + return parent::isCreatable(); |
|
169 | + } else { |
|
170 | + throw new NotFoundException(); |
|
171 | + } |
|
172 | + } |
|
173 | 173 | } |
@@ -33,51 +33,51 @@ |
||
33 | 33 | */ |
34 | 34 | class VerifyMountPointEvent extends Event { |
35 | 35 | |
36 | - /** @var IShare */ |
|
37 | - private $share; |
|
38 | - /** @var View */ |
|
39 | - private $view; |
|
40 | - /** @var string */ |
|
41 | - private $parent; |
|
36 | + /** @var IShare */ |
|
37 | + private $share; |
|
38 | + /** @var View */ |
|
39 | + private $view; |
|
40 | + /** @var string */ |
|
41 | + private $parent; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @since 19.0.0 |
|
45 | - */ |
|
46 | - public function __construct(IShare $share, |
|
47 | - View $view, |
|
48 | - string $parent) { |
|
49 | - parent::__construct(); |
|
43 | + /** |
|
44 | + * @since 19.0.0 |
|
45 | + */ |
|
46 | + public function __construct(IShare $share, |
|
47 | + View $view, |
|
48 | + string $parent) { |
|
49 | + parent::__construct(); |
|
50 | 50 | |
51 | - $this->share = $share; |
|
52 | - $this->view = $view; |
|
53 | - $this->parent = $parent; |
|
54 | - } |
|
51 | + $this->share = $share; |
|
52 | + $this->view = $view; |
|
53 | + $this->parent = $parent; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @since 19.0.0 |
|
58 | - */ |
|
59 | - public function getShare(): IShare { |
|
60 | - return $this->share; |
|
61 | - } |
|
56 | + /** |
|
57 | + * @since 19.0.0 |
|
58 | + */ |
|
59 | + public function getShare(): IShare { |
|
60 | + return $this->share; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @since 19.0.0 |
|
65 | - */ |
|
66 | - public function getView(): View { |
|
67 | - return $this->view; |
|
68 | - } |
|
63 | + /** |
|
64 | + * @since 19.0.0 |
|
65 | + */ |
|
66 | + public function getView(): View { |
|
67 | + return $this->view; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @since 19.0.0 |
|
72 | - */ |
|
73 | - public function getParent(): string { |
|
74 | - return $this->parent; |
|
75 | - } |
|
70 | + /** |
|
71 | + * @since 19.0.0 |
|
72 | + */ |
|
73 | + public function getParent(): string { |
|
74 | + return $this->parent; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @since 19.0.0 |
|
79 | - */ |
|
80 | - public function setParent(string $parent): void { |
|
81 | - $this->parent = $parent; |
|
82 | - } |
|
77 | + /** |
|
78 | + * @since 19.0.0 |
|
79 | + */ |
|
80 | + public function setParent(string $parent): void { |
|
81 | + $this->parent = $parent; |
|
82 | + } |
|
83 | 83 | } |
@@ -33,57 +33,57 @@ |
||
33 | 33 | * @since 11.0.0 |
34 | 34 | */ |
35 | 35 | interface ISimpleFolder { |
36 | - /** |
|
37 | - * Get all the files in a folder |
|
38 | - * |
|
39 | - * @return ISimpleFile[] |
|
40 | - * @since 11.0.0 |
|
41 | - */ |
|
42 | - public function getDirectoryListing(); |
|
36 | + /** |
|
37 | + * Get all the files in a folder |
|
38 | + * |
|
39 | + * @return ISimpleFile[] |
|
40 | + * @since 11.0.0 |
|
41 | + */ |
|
42 | + public function getDirectoryListing(); |
|
43 | 43 | |
44 | - /** |
|
45 | - * Check if a file with $name exists |
|
46 | - * |
|
47 | - * @param string $name |
|
48 | - * @return bool |
|
49 | - * @since 11.0.0 |
|
50 | - */ |
|
51 | - public function fileExists($name); |
|
44 | + /** |
|
45 | + * Check if a file with $name exists |
|
46 | + * |
|
47 | + * @param string $name |
|
48 | + * @return bool |
|
49 | + * @since 11.0.0 |
|
50 | + */ |
|
51 | + public function fileExists($name); |
|
52 | 52 | |
53 | - /** |
|
54 | - * Get the file named $name from the folder |
|
55 | - * |
|
56 | - * @param string $name |
|
57 | - * @return ISimpleFile |
|
58 | - * @throws NotFoundException |
|
59 | - * @since 11.0.0 |
|
60 | - */ |
|
61 | - public function getFile($name); |
|
53 | + /** |
|
54 | + * Get the file named $name from the folder |
|
55 | + * |
|
56 | + * @param string $name |
|
57 | + * @return ISimpleFile |
|
58 | + * @throws NotFoundException |
|
59 | + * @since 11.0.0 |
|
60 | + */ |
|
61 | + public function getFile($name); |
|
62 | 62 | |
63 | - /** |
|
64 | - * Creates a new file with $name in the folder |
|
65 | - * |
|
66 | - * @param string $name |
|
67 | - * @param string|resource|null $content @since 19.0.0 |
|
68 | - * @return ISimpleFile |
|
69 | - * @throws NotPermittedException |
|
70 | - * @since 11.0.0 |
|
71 | - */ |
|
72 | - public function newFile($name, $content = null); |
|
63 | + /** |
|
64 | + * Creates a new file with $name in the folder |
|
65 | + * |
|
66 | + * @param string $name |
|
67 | + * @param string|resource|null $content @since 19.0.0 |
|
68 | + * @return ISimpleFile |
|
69 | + * @throws NotPermittedException |
|
70 | + * @since 11.0.0 |
|
71 | + */ |
|
72 | + public function newFile($name, $content = null); |
|
73 | 73 | |
74 | - /** |
|
75 | - * Remove the folder and all the files in it |
|
76 | - * |
|
77 | - * @throws NotPermittedException |
|
78 | - * @since 11.0.0 |
|
79 | - */ |
|
80 | - public function delete(); |
|
74 | + /** |
|
75 | + * Remove the folder and all the files in it |
|
76 | + * |
|
77 | + * @throws NotPermittedException |
|
78 | + * @since 11.0.0 |
|
79 | + */ |
|
80 | + public function delete(); |
|
81 | 81 | |
82 | - /** |
|
83 | - * Get the folder name |
|
84 | - * |
|
85 | - * @return string |
|
86 | - * @since 11.0.0 |
|
87 | - */ |
|
88 | - public function getName(); |
|
82 | + /** |
|
83 | + * Get the folder name |
|
84 | + * |
|
85 | + * @return string |
|
86 | + * @since 11.0.0 |
|
87 | + */ |
|
88 | + public function getName(); |
|
89 | 89 | } |
@@ -42,154 +42,154 @@ |
||
42 | 42 | |
43 | 43 | class TransferOwnershipController extends OCSController { |
44 | 44 | |
45 | - /** @var string */ |
|
46 | - private $userId; |
|
47 | - /** @var NotificationManager */ |
|
48 | - private $notificationManager; |
|
49 | - /** @var ITimeFactory */ |
|
50 | - private $timeFactory; |
|
51 | - /** @var IJobList */ |
|
52 | - private $jobList; |
|
53 | - /** @var TransferOwnershipMapper */ |
|
54 | - private $mapper; |
|
55 | - /** @var IUserManager */ |
|
56 | - private $userManager; |
|
57 | - /** @var IRootFolder */ |
|
58 | - private $rootFolder; |
|
59 | - |
|
60 | - public function __construct(string $appName, |
|
61 | - IRequest $request, |
|
62 | - string $userId, |
|
63 | - NotificationManager $notificationManager, |
|
64 | - ITimeFactory $timeFactory, |
|
65 | - IJobList $jobList, |
|
66 | - TransferOwnershipMapper $mapper, |
|
67 | - IUserManager $userManager, |
|
68 | - IRootFolder $rootFolder) { |
|
69 | - parent::__construct($appName, $request); |
|
70 | - |
|
71 | - $this->userId = $userId; |
|
72 | - $this->notificationManager = $notificationManager; |
|
73 | - $this->timeFactory = $timeFactory; |
|
74 | - $this->jobList = $jobList; |
|
75 | - $this->mapper = $mapper; |
|
76 | - $this->userManager = $userManager; |
|
77 | - $this->rootFolder = $rootFolder; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * @NoAdminRequired |
|
83 | - */ |
|
84 | - public function transfer(string $recipient, string $path): DataResponse { |
|
85 | - $recipientUser = $this->userManager->get($recipient); |
|
86 | - |
|
87 | - if ($recipientUser === null) { |
|
88 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
89 | - } |
|
90 | - |
|
91 | - $userRoot = $this->rootFolder->getUserFolder($this->userId); |
|
92 | - |
|
93 | - try { |
|
94 | - $node = $userRoot->get($path); |
|
95 | - } catch (\Exception $e) { |
|
96 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
97 | - } |
|
98 | - |
|
99 | - if ($node->getOwner()->getUID() !== $this->userId) { |
|
100 | - return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
101 | - } |
|
102 | - |
|
103 | - $transferOwnership = new TransferOwnershipEntity(); |
|
104 | - $transferOwnership->setSourceUser($this->userId); |
|
105 | - $transferOwnership->setTargetUser($recipient); |
|
106 | - $transferOwnership->setFileId($node->getId()); |
|
107 | - $transferOwnership->setNodeName($node->getName()); |
|
108 | - $transferOwnership = $this->mapper->insert($transferOwnership); |
|
109 | - |
|
110 | - $notification = $this->notificationManager->createNotification(); |
|
111 | - $notification->setUser($recipient) |
|
112 | - ->setApp($this->appName) |
|
113 | - ->setDateTime($this->timeFactory->getDateTime()) |
|
114 | - ->setSubject('transferownershipRequest', [ |
|
115 | - 'sourceUser' => $this->userId, |
|
116 | - 'targetUser' => $recipient, |
|
117 | - 'nodeName' => $node->getName(), |
|
118 | - ]) |
|
119 | - ->setObject('transfer', (string)$transferOwnership->getId()); |
|
120 | - |
|
121 | - $this->notificationManager->notify($notification); |
|
122 | - |
|
123 | - return new DataResponse([]); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * @NoAdminRequired |
|
128 | - */ |
|
129 | - public function accept(int $id): DataResponse { |
|
130 | - try { |
|
131 | - $transferOwnership = $this->mapper->getById($id); |
|
132 | - } catch (DoesNotExistException $e) { |
|
133 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
134 | - } |
|
135 | - |
|
136 | - if ($transferOwnership->getTargetUser() !== $this->userId) { |
|
137 | - return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
138 | - } |
|
139 | - |
|
140 | - $notification = $this->notificationManager->createNotification(); |
|
141 | - $notification->setApp('files') |
|
142 | - ->setObject('transfer', (string)$id); |
|
143 | - $this->notificationManager->markProcessed($notification); |
|
144 | - |
|
145 | - $newTransferOwnership = new TransferOwnershipEntity(); |
|
146 | - $newTransferOwnership->setNodeName($transferOwnership->getNodeName()); |
|
147 | - $newTransferOwnership->setFileId($transferOwnership->getFileId()); |
|
148 | - $newTransferOwnership->setSourceUser($transferOwnership->getSourceUser()); |
|
149 | - $newTransferOwnership->setTargetUser($transferOwnership->getTargetUser()); |
|
150 | - $this->mapper->insert($newTransferOwnership); |
|
151 | - |
|
152 | - $this->jobList->add(TransferOwnership::class, [ |
|
153 | - 'id' => $newTransferOwnership->getId(), |
|
154 | - ]); |
|
155 | - |
|
156 | - return new DataResponse([], Http::STATUS_OK); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * @NoAdminRequired |
|
161 | - */ |
|
162 | - public function reject(int $id): DataResponse { |
|
163 | - try { |
|
164 | - $transferOwnership = $this->mapper->getById($id); |
|
165 | - } catch (DoesNotExistException $e) { |
|
166 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
167 | - } |
|
168 | - |
|
169 | - if ($transferOwnership->getTargetUser() !== $this->userId) { |
|
170 | - return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
171 | - } |
|
172 | - |
|
173 | - $notification = $this->notificationManager->createNotification(); |
|
174 | - $notification->setApp('files') |
|
175 | - ->setObject('transfer', (string)$id); |
|
176 | - $this->notificationManager->markProcessed($notification); |
|
177 | - |
|
178 | - $notification = $this->notificationManager->createNotification(); |
|
179 | - $notification->setUser($transferOwnership->getSourceUser()) |
|
180 | - ->setApp($this->appName) |
|
181 | - ->setDateTime($this->timeFactory->getDateTime()) |
|
182 | - ->setSubject('transferownershipRequestDenied', [ |
|
183 | - 'sourceUser' => $transferOwnership->getSourceUser(), |
|
184 | - 'targetUser' => $transferOwnership->getTargetUser(), |
|
185 | - 'nodeName' => $transferOwnership->getNodeName() |
|
186 | - ]) |
|
187 | - ->setObject('transfer', (string)$transferOwnership->getId()); |
|
188 | - $this->notificationManager->notify($notification); |
|
189 | - |
|
190 | - $this->mapper->delete($transferOwnership); |
|
191 | - |
|
192 | - return new DataResponse([], Http::STATUS_OK); |
|
193 | - } |
|
45 | + /** @var string */ |
|
46 | + private $userId; |
|
47 | + /** @var NotificationManager */ |
|
48 | + private $notificationManager; |
|
49 | + /** @var ITimeFactory */ |
|
50 | + private $timeFactory; |
|
51 | + /** @var IJobList */ |
|
52 | + private $jobList; |
|
53 | + /** @var TransferOwnershipMapper */ |
|
54 | + private $mapper; |
|
55 | + /** @var IUserManager */ |
|
56 | + private $userManager; |
|
57 | + /** @var IRootFolder */ |
|
58 | + private $rootFolder; |
|
59 | + |
|
60 | + public function __construct(string $appName, |
|
61 | + IRequest $request, |
|
62 | + string $userId, |
|
63 | + NotificationManager $notificationManager, |
|
64 | + ITimeFactory $timeFactory, |
|
65 | + IJobList $jobList, |
|
66 | + TransferOwnershipMapper $mapper, |
|
67 | + IUserManager $userManager, |
|
68 | + IRootFolder $rootFolder) { |
|
69 | + parent::__construct($appName, $request); |
|
70 | + |
|
71 | + $this->userId = $userId; |
|
72 | + $this->notificationManager = $notificationManager; |
|
73 | + $this->timeFactory = $timeFactory; |
|
74 | + $this->jobList = $jobList; |
|
75 | + $this->mapper = $mapper; |
|
76 | + $this->userManager = $userManager; |
|
77 | + $this->rootFolder = $rootFolder; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * @NoAdminRequired |
|
83 | + */ |
|
84 | + public function transfer(string $recipient, string $path): DataResponse { |
|
85 | + $recipientUser = $this->userManager->get($recipient); |
|
86 | + |
|
87 | + if ($recipientUser === null) { |
|
88 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
89 | + } |
|
90 | + |
|
91 | + $userRoot = $this->rootFolder->getUserFolder($this->userId); |
|
92 | + |
|
93 | + try { |
|
94 | + $node = $userRoot->get($path); |
|
95 | + } catch (\Exception $e) { |
|
96 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
97 | + } |
|
98 | + |
|
99 | + if ($node->getOwner()->getUID() !== $this->userId) { |
|
100 | + return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
101 | + } |
|
102 | + |
|
103 | + $transferOwnership = new TransferOwnershipEntity(); |
|
104 | + $transferOwnership->setSourceUser($this->userId); |
|
105 | + $transferOwnership->setTargetUser($recipient); |
|
106 | + $transferOwnership->setFileId($node->getId()); |
|
107 | + $transferOwnership->setNodeName($node->getName()); |
|
108 | + $transferOwnership = $this->mapper->insert($transferOwnership); |
|
109 | + |
|
110 | + $notification = $this->notificationManager->createNotification(); |
|
111 | + $notification->setUser($recipient) |
|
112 | + ->setApp($this->appName) |
|
113 | + ->setDateTime($this->timeFactory->getDateTime()) |
|
114 | + ->setSubject('transferownershipRequest', [ |
|
115 | + 'sourceUser' => $this->userId, |
|
116 | + 'targetUser' => $recipient, |
|
117 | + 'nodeName' => $node->getName(), |
|
118 | + ]) |
|
119 | + ->setObject('transfer', (string)$transferOwnership->getId()); |
|
120 | + |
|
121 | + $this->notificationManager->notify($notification); |
|
122 | + |
|
123 | + return new DataResponse([]); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * @NoAdminRequired |
|
128 | + */ |
|
129 | + public function accept(int $id): DataResponse { |
|
130 | + try { |
|
131 | + $transferOwnership = $this->mapper->getById($id); |
|
132 | + } catch (DoesNotExistException $e) { |
|
133 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
134 | + } |
|
135 | + |
|
136 | + if ($transferOwnership->getTargetUser() !== $this->userId) { |
|
137 | + return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
138 | + } |
|
139 | + |
|
140 | + $notification = $this->notificationManager->createNotification(); |
|
141 | + $notification->setApp('files') |
|
142 | + ->setObject('transfer', (string)$id); |
|
143 | + $this->notificationManager->markProcessed($notification); |
|
144 | + |
|
145 | + $newTransferOwnership = new TransferOwnershipEntity(); |
|
146 | + $newTransferOwnership->setNodeName($transferOwnership->getNodeName()); |
|
147 | + $newTransferOwnership->setFileId($transferOwnership->getFileId()); |
|
148 | + $newTransferOwnership->setSourceUser($transferOwnership->getSourceUser()); |
|
149 | + $newTransferOwnership->setTargetUser($transferOwnership->getTargetUser()); |
|
150 | + $this->mapper->insert($newTransferOwnership); |
|
151 | + |
|
152 | + $this->jobList->add(TransferOwnership::class, [ |
|
153 | + 'id' => $newTransferOwnership->getId(), |
|
154 | + ]); |
|
155 | + |
|
156 | + return new DataResponse([], Http::STATUS_OK); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * @NoAdminRequired |
|
161 | + */ |
|
162 | + public function reject(int $id): DataResponse { |
|
163 | + try { |
|
164 | + $transferOwnership = $this->mapper->getById($id); |
|
165 | + } catch (DoesNotExistException $e) { |
|
166 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
167 | + } |
|
168 | + |
|
169 | + if ($transferOwnership->getTargetUser() !== $this->userId) { |
|
170 | + return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
171 | + } |
|
172 | + |
|
173 | + $notification = $this->notificationManager->createNotification(); |
|
174 | + $notification->setApp('files') |
|
175 | + ->setObject('transfer', (string)$id); |
|
176 | + $this->notificationManager->markProcessed($notification); |
|
177 | + |
|
178 | + $notification = $this->notificationManager->createNotification(); |
|
179 | + $notification->setUser($transferOwnership->getSourceUser()) |
|
180 | + ->setApp($this->appName) |
|
181 | + ->setDateTime($this->timeFactory->getDateTime()) |
|
182 | + ->setSubject('transferownershipRequestDenied', [ |
|
183 | + 'sourceUser' => $transferOwnership->getSourceUser(), |
|
184 | + 'targetUser' => $transferOwnership->getTargetUser(), |
|
185 | + 'nodeName' => $transferOwnership->getNodeName() |
|
186 | + ]) |
|
187 | + ->setObject('transfer', (string)$transferOwnership->getId()); |
|
188 | + $this->notificationManager->notify($notification); |
|
189 | + |
|
190 | + $this->mapper->delete($transferOwnership); |
|
191 | + |
|
192 | + return new DataResponse([], Http::STATUS_OK); |
|
193 | + } |
|
194 | 194 | |
195 | 195 | } |
@@ -37,64 +37,64 @@ |
||
37 | 37 | * @since 15.0.0 |
38 | 38 | */ |
39 | 39 | interface IVersionBackend { |
40 | - /** |
|
41 | - * Whether or not this version backend should be used for a storage |
|
42 | - * |
|
43 | - * If false is returned then the next applicable backend will be used |
|
44 | - * |
|
45 | - * @param IStorage $storage |
|
46 | - * @return bool |
|
47 | - * @since 17.0.0 |
|
48 | - */ |
|
49 | - public function useBackendForStorage(IStorage $storage): bool; |
|
40 | + /** |
|
41 | + * Whether or not this version backend should be used for a storage |
|
42 | + * |
|
43 | + * If false is returned then the next applicable backend will be used |
|
44 | + * |
|
45 | + * @param IStorage $storage |
|
46 | + * @return bool |
|
47 | + * @since 17.0.0 |
|
48 | + */ |
|
49 | + public function useBackendForStorage(IStorage $storage): bool; |
|
50 | 50 | |
51 | - /** |
|
52 | - * Get all versions for a file |
|
53 | - * |
|
54 | - * @param IUser $user |
|
55 | - * @param FileInfo $file |
|
56 | - * @return IVersion[] |
|
57 | - * @since 15.0.0 |
|
58 | - */ |
|
59 | - public function getVersionsForFile(IUser $user, FileInfo $file): array; |
|
51 | + /** |
|
52 | + * Get all versions for a file |
|
53 | + * |
|
54 | + * @param IUser $user |
|
55 | + * @param FileInfo $file |
|
56 | + * @return IVersion[] |
|
57 | + * @since 15.0.0 |
|
58 | + */ |
|
59 | + public function getVersionsForFile(IUser $user, FileInfo $file): array; |
|
60 | 60 | |
61 | - /** |
|
62 | - * Create a new version for a file |
|
63 | - * |
|
64 | - * @param IUser $user |
|
65 | - * @param FileInfo $file |
|
66 | - * @since 15.0.0 |
|
67 | - */ |
|
68 | - public function createVersion(IUser $user, FileInfo $file); |
|
61 | + /** |
|
62 | + * Create a new version for a file |
|
63 | + * |
|
64 | + * @param IUser $user |
|
65 | + * @param FileInfo $file |
|
66 | + * @since 15.0.0 |
|
67 | + */ |
|
68 | + public function createVersion(IUser $user, FileInfo $file); |
|
69 | 69 | |
70 | - /** |
|
71 | - * Restore this version |
|
72 | - * |
|
73 | - * @param IVersion $version |
|
74 | - * @since 15.0.0 |
|
75 | - */ |
|
76 | - public function rollback(IVersion $version); |
|
70 | + /** |
|
71 | + * Restore this version |
|
72 | + * |
|
73 | + * @param IVersion $version |
|
74 | + * @since 15.0.0 |
|
75 | + */ |
|
76 | + public function rollback(IVersion $version); |
|
77 | 77 | |
78 | - /** |
|
79 | - * Open the file for reading |
|
80 | - * |
|
81 | - * @param IVersion $version |
|
82 | - * @return resource |
|
83 | - * @throws NotFoundException |
|
84 | - * @since 15.0.0 |
|
85 | - */ |
|
86 | - public function read(IVersion $version); |
|
78 | + /** |
|
79 | + * Open the file for reading |
|
80 | + * |
|
81 | + * @param IVersion $version |
|
82 | + * @return resource |
|
83 | + * @throws NotFoundException |
|
84 | + * @since 15.0.0 |
|
85 | + */ |
|
86 | + public function read(IVersion $version); |
|
87 | 87 | |
88 | - /** |
|
89 | - * Get the preview for a specific version of a file |
|
90 | - * |
|
91 | - * @param IUser $user |
|
92 | - * @param FileInfo $sourceFile |
|
93 | - * @param int|string $revision |
|
94 | - * |
|
95 | - * @return File |
|
96 | - * |
|
97 | - * @since 15.0.0 |
|
98 | - */ |
|
99 | - public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File; |
|
88 | + /** |
|
89 | + * Get the preview for a specific version of a file |
|
90 | + * |
|
91 | + * @param IUser $user |
|
92 | + * @param FileInfo $sourceFile |
|
93 | + * @param int|string $revision |
|
94 | + * |
|
95 | + * @return File |
|
96 | + * |
|
97 | + * @since 15.0.0 |
|
98 | + */ |
|
99 | + public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File; |
|
100 | 100 | } |
@@ -30,57 +30,57 @@ |
||
30 | 30 | |
31 | 31 | class EnforcementState implements JsonSerializable { |
32 | 32 | |
33 | - /** @var bool */ |
|
34 | - private $enforced; |
|
33 | + /** @var bool */ |
|
34 | + private $enforced; |
|
35 | 35 | |
36 | - /** @var array */ |
|
37 | - private $enforcedGroups; |
|
36 | + /** @var array */ |
|
37 | + private $enforcedGroups; |
|
38 | 38 | |
39 | - /** @var array */ |
|
40 | - private $excludedGroups; |
|
39 | + /** @var array */ |
|
40 | + private $excludedGroups; |
|
41 | 41 | |
42 | - /** |
|
43 | - * EnforcementState constructor. |
|
44 | - * |
|
45 | - * @param bool $enforced |
|
46 | - * @param string[] $enforcedGroups |
|
47 | - * @param string[] $excludedGroups |
|
48 | - */ |
|
49 | - public function __construct(bool $enforced, |
|
50 | - array $enforcedGroups = [], |
|
51 | - array $excludedGroups = []) { |
|
52 | - $this->enforced = $enforced; |
|
53 | - $this->enforcedGroups = $enforcedGroups; |
|
54 | - $this->excludedGroups = $excludedGroups; |
|
55 | - } |
|
42 | + /** |
|
43 | + * EnforcementState constructor. |
|
44 | + * |
|
45 | + * @param bool $enforced |
|
46 | + * @param string[] $enforcedGroups |
|
47 | + * @param string[] $excludedGroups |
|
48 | + */ |
|
49 | + public function __construct(bool $enforced, |
|
50 | + array $enforcedGroups = [], |
|
51 | + array $excludedGroups = []) { |
|
52 | + $this->enforced = $enforced; |
|
53 | + $this->enforcedGroups = $enforcedGroups; |
|
54 | + $this->excludedGroups = $excludedGroups; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - public function isEnforced(): bool { |
|
61 | - return $this->enforced; |
|
62 | - } |
|
57 | + /** |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + public function isEnforced(): bool { |
|
61 | + return $this->enforced; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return string[] |
|
66 | - */ |
|
67 | - public function getEnforcedGroups(): array { |
|
68 | - return $this->enforcedGroups; |
|
69 | - } |
|
64 | + /** |
|
65 | + * @return string[] |
|
66 | + */ |
|
67 | + public function getEnforcedGroups(): array { |
|
68 | + return $this->enforcedGroups; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return string[] |
|
73 | - */ |
|
74 | - public function getExcludedGroups(): array { |
|
75 | - return $this->excludedGroups; |
|
76 | - } |
|
71 | + /** |
|
72 | + * @return string[] |
|
73 | + */ |
|
74 | + public function getExcludedGroups(): array { |
|
75 | + return $this->excludedGroups; |
|
76 | + } |
|
77 | 77 | |
78 | - public function jsonSerialize(): array { |
|
79 | - return [ |
|
80 | - 'enforced' => $this->enforced, |
|
81 | - 'enforcedGroups' => $this->enforcedGroups, |
|
82 | - 'excludedGroups' => $this->excludedGroups, |
|
83 | - ]; |
|
84 | - } |
|
78 | + public function jsonSerialize(): array { |
|
79 | + return [ |
|
80 | + 'enforced' => $this->enforced, |
|
81 | + 'enforcedGroups' => $this->enforcedGroups, |
|
82 | + 'excludedGroups' => $this->excludedGroups, |
|
83 | + ]; |
|
84 | + } |
|
85 | 85 | |
86 | 86 | } |