@@ -27,101 +27,101 @@ |
||
27 | 27 | use OCP\Files\Search\ISearchQuery; |
28 | 28 | |
29 | 29 | class NullCache implements ICache { |
30 | - public function getNumericStorageId() { |
|
31 | - return -1; |
|
32 | - } |
|
33 | - |
|
34 | - public function get($file) { |
|
35 | - return $file !== '' ? null : |
|
36 | - new CacheEntry([ |
|
37 | - 'fileid' => -1, |
|
38 | - 'parent' => -1, |
|
39 | - 'name' => '', |
|
40 | - 'path' => '', |
|
41 | - 'size' => '0', |
|
42 | - 'mtime' => time(), |
|
43 | - 'storage_mtime' => time(), |
|
44 | - 'etag' => '', |
|
45 | - 'mimetype' => FileInfo::MIMETYPE_FOLDER, |
|
46 | - 'mimepart' => 'httpd', |
|
47 | - 'permissions' => Constants::PERMISSION_READ |
|
48 | - ]); |
|
49 | - } |
|
50 | - |
|
51 | - public function getFolderContents($folder) { |
|
52 | - return []; |
|
53 | - } |
|
54 | - |
|
55 | - public function getFolderContentsById($fileId) { |
|
56 | - return []; |
|
57 | - } |
|
58 | - |
|
59 | - public function put($file, array $data) { |
|
60 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
61 | - } |
|
62 | - |
|
63 | - public function insert($file, array $data) { |
|
64 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
65 | - } |
|
66 | - |
|
67 | - public function update($id, array $data) { |
|
68 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
69 | - } |
|
70 | - |
|
71 | - public function getId($file) { |
|
72 | - return -1; |
|
73 | - } |
|
74 | - |
|
75 | - public function getParentId($file) { |
|
76 | - return -1; |
|
77 | - } |
|
78 | - |
|
79 | - public function inCache($file) { |
|
80 | - return $file === ''; |
|
81 | - } |
|
82 | - |
|
83 | - public function remove($file) { |
|
84 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
85 | - } |
|
86 | - |
|
87 | - public function move($source, $target) { |
|
88 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
89 | - } |
|
90 | - |
|
91 | - public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
92 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
93 | - } |
|
94 | - |
|
95 | - public function getStatus($file) { |
|
96 | - return ICache::COMPLETE; |
|
97 | - } |
|
98 | - |
|
99 | - public function search($pattern) { |
|
100 | - return []; |
|
101 | - } |
|
102 | - |
|
103 | - public function searchByMime($mimetype) { |
|
104 | - return []; |
|
105 | - } |
|
106 | - |
|
107 | - public function searchQuery(ISearchQuery $query) { |
|
108 | - return []; |
|
109 | - } |
|
110 | - |
|
111 | - public function searchByTag($tag, $userId) { |
|
112 | - return []; |
|
113 | - } |
|
114 | - |
|
115 | - public function getIncomplete() { |
|
116 | - return []; |
|
117 | - } |
|
118 | - |
|
119 | - public function getPathById($id) { |
|
120 | - return ''; |
|
121 | - } |
|
122 | - |
|
123 | - public function normalize($path) { |
|
124 | - return $path; |
|
125 | - } |
|
30 | + public function getNumericStorageId() { |
|
31 | + return -1; |
|
32 | + } |
|
33 | + |
|
34 | + public function get($file) { |
|
35 | + return $file !== '' ? null : |
|
36 | + new CacheEntry([ |
|
37 | + 'fileid' => -1, |
|
38 | + 'parent' => -1, |
|
39 | + 'name' => '', |
|
40 | + 'path' => '', |
|
41 | + 'size' => '0', |
|
42 | + 'mtime' => time(), |
|
43 | + 'storage_mtime' => time(), |
|
44 | + 'etag' => '', |
|
45 | + 'mimetype' => FileInfo::MIMETYPE_FOLDER, |
|
46 | + 'mimepart' => 'httpd', |
|
47 | + 'permissions' => Constants::PERMISSION_READ |
|
48 | + ]); |
|
49 | + } |
|
50 | + |
|
51 | + public function getFolderContents($folder) { |
|
52 | + return []; |
|
53 | + } |
|
54 | + |
|
55 | + public function getFolderContentsById($fileId) { |
|
56 | + return []; |
|
57 | + } |
|
58 | + |
|
59 | + public function put($file, array $data) { |
|
60 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
61 | + } |
|
62 | + |
|
63 | + public function insert($file, array $data) { |
|
64 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
65 | + } |
|
66 | + |
|
67 | + public function update($id, array $data) { |
|
68 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
69 | + } |
|
70 | + |
|
71 | + public function getId($file) { |
|
72 | + return -1; |
|
73 | + } |
|
74 | + |
|
75 | + public function getParentId($file) { |
|
76 | + return -1; |
|
77 | + } |
|
78 | + |
|
79 | + public function inCache($file) { |
|
80 | + return $file === ''; |
|
81 | + } |
|
82 | + |
|
83 | + public function remove($file) { |
|
84 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
85 | + } |
|
86 | + |
|
87 | + public function move($source, $target) { |
|
88 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
89 | + } |
|
90 | + |
|
91 | + public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
92 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
93 | + } |
|
94 | + |
|
95 | + public function getStatus($file) { |
|
96 | + return ICache::COMPLETE; |
|
97 | + } |
|
98 | + |
|
99 | + public function search($pattern) { |
|
100 | + return []; |
|
101 | + } |
|
102 | + |
|
103 | + public function searchByMime($mimetype) { |
|
104 | + return []; |
|
105 | + } |
|
106 | + |
|
107 | + public function searchQuery(ISearchQuery $query) { |
|
108 | + return []; |
|
109 | + } |
|
110 | + |
|
111 | + public function searchByTag($tag, $userId) { |
|
112 | + return []; |
|
113 | + } |
|
114 | + |
|
115 | + public function getIncomplete() { |
|
116 | + return []; |
|
117 | + } |
|
118 | + |
|
119 | + public function getPathById($id) { |
|
120 | + return ''; |
|
121 | + } |
|
122 | + |
|
123 | + public function normalize($path) { |
|
124 | + return $path; |
|
125 | + } |
|
126 | 126 | |
127 | 127 | } |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php /** @var $l OC_L10N */ ?> |
2 | 2 | <?php |
3 | 3 | script('core', [ |
4 | - 'jquery-showpassword', |
|
4 | + 'jquery-showpassword', |
|
5 | 5 | ]); |
6 | 6 | script('user_ldap', [ |
7 | - 'renewPassword', |
|
7 | + 'renewPassword', |
|
8 | 8 | ]); |
9 | 9 | style('user_ldap', 'renewPassword'); |
10 | 10 | \OC_Util::addVendorScript('strengthify/jquery.strengthify'); |
@@ -31,82 +31,82 @@ |
||
31 | 31 | |
32 | 32 | class ImageManager { |
33 | 33 | |
34 | - /** @var IConfig */ |
|
35 | - private $config; |
|
36 | - /** @var IAppData */ |
|
37 | - private $appData; |
|
34 | + /** @var IConfig */ |
|
35 | + private $config; |
|
36 | + /** @var IAppData */ |
|
37 | + private $appData; |
|
38 | 38 | |
39 | - /** |
|
40 | - * ImageManager constructor. |
|
41 | - * |
|
42 | - * @param IConfig $config |
|
43 | - * @param IAppData $appData |
|
44 | - */ |
|
45 | - public function __construct(IConfig $config, |
|
46 | - IAppData $appData |
|
47 | - ) { |
|
48 | - $this->config = $config; |
|
49 | - $this->appData = $appData; |
|
50 | - } |
|
39 | + /** |
|
40 | + * ImageManager constructor. |
|
41 | + * |
|
42 | + * @param IConfig $config |
|
43 | + * @param IAppData $appData |
|
44 | + */ |
|
45 | + public function __construct(IConfig $config, |
|
46 | + IAppData $appData |
|
47 | + ) { |
|
48 | + $this->config = $config; |
|
49 | + $this->appData = $appData; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get folder for current theming files |
|
54 | - * |
|
55 | - * @return \OCP\Files\SimpleFS\ISimpleFolder |
|
56 | - * @throws NotPermittedException |
|
57 | - * @throws \RuntimeException |
|
58 | - */ |
|
59 | - public function getCacheFolder() { |
|
60 | - $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
61 | - try { |
|
62 | - $folder = $this->appData->getFolder($cacheBusterValue); |
|
63 | - } catch (NotFoundException $e) { |
|
64 | - $folder = $this->appData->newFolder($cacheBusterValue); |
|
65 | - $this->cleanup(); |
|
66 | - } |
|
67 | - return $folder; |
|
68 | - } |
|
52 | + /** |
|
53 | + * Get folder for current theming files |
|
54 | + * |
|
55 | + * @return \OCP\Files\SimpleFS\ISimpleFolder |
|
56 | + * @throws NotPermittedException |
|
57 | + * @throws \RuntimeException |
|
58 | + */ |
|
59 | + public function getCacheFolder() { |
|
60 | + $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
61 | + try { |
|
62 | + $folder = $this->appData->getFolder($cacheBusterValue); |
|
63 | + } catch (NotFoundException $e) { |
|
64 | + $folder = $this->appData->newFolder($cacheBusterValue); |
|
65 | + $this->cleanup(); |
|
66 | + } |
|
67 | + return $folder; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Get a file from AppData |
|
72 | - * |
|
73 | - * @param string $filename |
|
74 | - * @throws NotFoundException |
|
75 | - * @return \OCP\Files\SimpleFS\ISimpleFile |
|
76 | - */ |
|
77 | - public function getCachedImage($filename) { |
|
78 | - $currentFolder = $this->getCacheFolder(); |
|
79 | - return $currentFolder->getFile($filename); |
|
80 | - } |
|
70 | + /** |
|
71 | + * Get a file from AppData |
|
72 | + * |
|
73 | + * @param string $filename |
|
74 | + * @throws NotFoundException |
|
75 | + * @return \OCP\Files\SimpleFS\ISimpleFile |
|
76 | + */ |
|
77 | + public function getCachedImage($filename) { |
|
78 | + $currentFolder = $this->getCacheFolder(); |
|
79 | + return $currentFolder->getFile($filename); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Store a file for theming in AppData |
|
84 | - * |
|
85 | - * @param string $filename |
|
86 | - * @param string $data |
|
87 | - * @return \OCP\Files\SimpleFS\ISimpleFile |
|
88 | - */ |
|
89 | - public function setCachedImage($filename, $data) { |
|
90 | - $currentFolder = $this->getCacheFolder(); |
|
91 | - if ($currentFolder->fileExists($filename)) { |
|
92 | - $file = $currentFolder->getFile($filename); |
|
93 | - } else { |
|
94 | - $file = $currentFolder->newFile($filename); |
|
95 | - } |
|
96 | - $file->putContent($data); |
|
97 | - return $file; |
|
98 | - } |
|
82 | + /** |
|
83 | + * Store a file for theming in AppData |
|
84 | + * |
|
85 | + * @param string $filename |
|
86 | + * @param string $data |
|
87 | + * @return \OCP\Files\SimpleFS\ISimpleFile |
|
88 | + */ |
|
89 | + public function setCachedImage($filename, $data) { |
|
90 | + $currentFolder = $this->getCacheFolder(); |
|
91 | + if ($currentFolder->fileExists($filename)) { |
|
92 | + $file = $currentFolder->getFile($filename); |
|
93 | + } else { |
|
94 | + $file = $currentFolder->newFile($filename); |
|
95 | + } |
|
96 | + $file->putContent($data); |
|
97 | + return $file; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * remove cached files that are not required any longer |
|
102 | - */ |
|
103 | - public function cleanup() { |
|
104 | - $currentFolder = $this->getCacheFolder(); |
|
105 | - $folders = $this->appData->getDirectoryListing(); |
|
106 | - foreach ($folders as $folder) { |
|
107 | - if ($folder->getName() !== 'images' && $folder->getName() !== $currentFolder->getName()) { |
|
108 | - $folder->delete(); |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
100 | + /** |
|
101 | + * remove cached files that are not required any longer |
|
102 | + */ |
|
103 | + public function cleanup() { |
|
104 | + $currentFolder = $this->getCacheFolder(); |
|
105 | + $folders = $this->appData->getDirectoryListing(); |
|
106 | + foreach ($folders as $folder) { |
|
107 | + if ($folder->getName() !== 'images' && $folder->getName() !== $currentFolder->getName()) { |
|
108 | + $folder->delete(); |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | 112 | } |
@@ -37,179 +37,179 @@ |
||
37 | 37 | */ |
38 | 38 | class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable { |
39 | 39 | |
40 | - /** |
|
41 | - * AddressBook constructor. |
|
42 | - * |
|
43 | - * @param BackendInterface $carddavBackend |
|
44 | - * @param array $addressBookInfo |
|
45 | - * @param IL10N $l10n |
|
46 | - */ |
|
47 | - public function __construct(BackendInterface $carddavBackend, array $addressBookInfo, IL10N $l10n) { |
|
48 | - parent::__construct($carddavBackend, $addressBookInfo); |
|
49 | - |
|
50 | - if ($this->addressBookInfo['{DAV:}displayname'] === CardDavBackend::PERSONAL_ADDRESSBOOK_NAME && |
|
51 | - $this->getName() === CardDavBackend::PERSONAL_ADDRESSBOOK_URI) { |
|
52 | - $this->addressBookInfo['{DAV:}displayname'] = $l10n->t('Contacts'); |
|
53 | - } |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Updates the list of shares. |
|
58 | - * |
|
59 | - * The first array is a list of people that are to be added to the |
|
60 | - * addressbook. |
|
61 | - * |
|
62 | - * Every element in the add array has the following properties: |
|
63 | - * * href - A url. Usually a mailto: address |
|
64 | - * * commonName - Usually a first and last name, or false |
|
65 | - * * summary - A description of the share, can also be false |
|
66 | - * * readOnly - A boolean value |
|
67 | - * |
|
68 | - * Every element in the remove array is just the address string. |
|
69 | - * |
|
70 | - * @param array $add |
|
71 | - * @param array $remove |
|
72 | - * @return void |
|
73 | - * @throws Forbidden |
|
74 | - */ |
|
75 | - public function updateShares(array $add, array $remove) { |
|
76 | - if ($this->isShared()) { |
|
77 | - throw new Forbidden(); |
|
78 | - } |
|
79 | - $this->carddavBackend->updateShares($this, $add, $remove); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Returns the list of people whom this addressbook is shared with. |
|
84 | - * |
|
85 | - * Every element in this array should have the following properties: |
|
86 | - * * href - Often a mailto: address |
|
87 | - * * commonName - Optional, for example a first + last name |
|
88 | - * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. |
|
89 | - * * readOnly - boolean |
|
90 | - * * summary - Optional, a description for the share |
|
91 | - * |
|
92 | - * @return array |
|
93 | - */ |
|
94 | - public function getShares() { |
|
95 | - if ($this->isShared()) { |
|
96 | - return []; |
|
97 | - } |
|
98 | - return $this->carddavBackend->getShares($this->getResourceId()); |
|
99 | - } |
|
100 | - |
|
101 | - public function getACL() { |
|
102 | - $acl = [ |
|
103 | - [ |
|
104 | - 'privilege' => '{DAV:}read', |
|
105 | - 'principal' => $this->getOwner(), |
|
106 | - 'protected' => true, |
|
107 | - ]]; |
|
108 | - $acl[] = [ |
|
109 | - 'privilege' => '{DAV:}write', |
|
110 | - 'principal' => $this->getOwner(), |
|
111 | - 'protected' => true, |
|
112 | - ]; |
|
113 | - if ($this->getOwner() !== parent::getOwner()) { |
|
114 | - $acl[] = [ |
|
115 | - 'privilege' => '{DAV:}read', |
|
116 | - 'principal' => parent::getOwner(), |
|
117 | - 'protected' => true, |
|
118 | - ]; |
|
119 | - if ($this->canWrite()) { |
|
120 | - $acl[] = [ |
|
121 | - 'privilege' => '{DAV:}write', |
|
122 | - 'principal' => parent::getOwner(), |
|
123 | - 'protected' => true, |
|
124 | - ]; |
|
125 | - } |
|
126 | - } |
|
127 | - if ($this->getOwner() === 'principals/system/system') { |
|
128 | - $acl[] = [ |
|
129 | - 'privilege' => '{DAV:}read', |
|
130 | - 'principal' => '{DAV:}authenticated', |
|
131 | - 'protected' => true, |
|
132 | - ]; |
|
133 | - } |
|
134 | - |
|
135 | - if ($this->isShared()) { |
|
136 | - return $acl; |
|
137 | - } |
|
138 | - |
|
139 | - return $this->carddavBackend->applyShareAcl($this->getResourceId(), $acl); |
|
140 | - } |
|
141 | - |
|
142 | - public function getChildACL() { |
|
143 | - return $this->getACL(); |
|
144 | - } |
|
145 | - |
|
146 | - public function getChild($name) { |
|
147 | - |
|
148 | - $obj = $this->carddavBackend->getCard($this->addressBookInfo['id'], $name); |
|
149 | - if (!$obj) { |
|
150 | - throw new NotFound('Card not found'); |
|
151 | - } |
|
152 | - $obj['acl'] = $this->getChildACL(); |
|
153 | - return new Card($this->carddavBackend, $this->addressBookInfo, $obj); |
|
154 | - |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * @return int |
|
159 | - */ |
|
160 | - public function getResourceId() { |
|
161 | - return $this->addressBookInfo['id']; |
|
162 | - } |
|
163 | - |
|
164 | - public function getOwner() { |
|
165 | - if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
166 | - return $this->addressBookInfo['{http://owncloud.org/ns}owner-principal']; |
|
167 | - } |
|
168 | - return parent::getOwner(); |
|
169 | - } |
|
170 | - |
|
171 | - public function delete() { |
|
172 | - if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
173 | - $principal = 'principal:' . parent::getOwner(); |
|
174 | - $shares = $this->carddavBackend->getShares($this->getResourceId()); |
|
175 | - $shares = array_filter($shares, function($share) use ($principal){ |
|
176 | - return $share['href'] === $principal; |
|
177 | - }); |
|
178 | - if (empty($shares)) { |
|
179 | - throw new Forbidden(); |
|
180 | - } |
|
181 | - |
|
182 | - $this->carddavBackend->updateShares($this, [], [ |
|
183 | - 'href' => $principal |
|
184 | - ]); |
|
185 | - return; |
|
186 | - } |
|
187 | - parent::delete(); |
|
188 | - } |
|
189 | - |
|
190 | - public function propPatch(PropPatch $propPatch) { |
|
191 | - if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
192 | - throw new Forbidden(); |
|
193 | - } |
|
194 | - parent::propPatch($propPatch); |
|
195 | - } |
|
196 | - |
|
197 | - public function getContactsGroups() { |
|
198 | - return $this->carddavBackend->collectCardProperties($this->getResourceId(), 'CATEGORIES'); |
|
199 | - } |
|
200 | - |
|
201 | - private function isShared() { |
|
202 | - if (!isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
203 | - return false; |
|
204 | - } |
|
205 | - |
|
206 | - return $this->addressBookInfo['{http://owncloud.org/ns}owner-principal'] !== $this->addressBookInfo['principaluri']; |
|
207 | - } |
|
208 | - |
|
209 | - private function canWrite() { |
|
210 | - if (isset($this->addressBookInfo['{http://owncloud.org/ns}read-only'])) { |
|
211 | - return !$this->addressBookInfo['{http://owncloud.org/ns}read-only']; |
|
212 | - } |
|
213 | - return true; |
|
214 | - } |
|
40 | + /** |
|
41 | + * AddressBook constructor. |
|
42 | + * |
|
43 | + * @param BackendInterface $carddavBackend |
|
44 | + * @param array $addressBookInfo |
|
45 | + * @param IL10N $l10n |
|
46 | + */ |
|
47 | + public function __construct(BackendInterface $carddavBackend, array $addressBookInfo, IL10N $l10n) { |
|
48 | + parent::__construct($carddavBackend, $addressBookInfo); |
|
49 | + |
|
50 | + if ($this->addressBookInfo['{DAV:}displayname'] === CardDavBackend::PERSONAL_ADDRESSBOOK_NAME && |
|
51 | + $this->getName() === CardDavBackend::PERSONAL_ADDRESSBOOK_URI) { |
|
52 | + $this->addressBookInfo['{DAV:}displayname'] = $l10n->t('Contacts'); |
|
53 | + } |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Updates the list of shares. |
|
58 | + * |
|
59 | + * The first array is a list of people that are to be added to the |
|
60 | + * addressbook. |
|
61 | + * |
|
62 | + * Every element in the add array has the following properties: |
|
63 | + * * href - A url. Usually a mailto: address |
|
64 | + * * commonName - Usually a first and last name, or false |
|
65 | + * * summary - A description of the share, can also be false |
|
66 | + * * readOnly - A boolean value |
|
67 | + * |
|
68 | + * Every element in the remove array is just the address string. |
|
69 | + * |
|
70 | + * @param array $add |
|
71 | + * @param array $remove |
|
72 | + * @return void |
|
73 | + * @throws Forbidden |
|
74 | + */ |
|
75 | + public function updateShares(array $add, array $remove) { |
|
76 | + if ($this->isShared()) { |
|
77 | + throw new Forbidden(); |
|
78 | + } |
|
79 | + $this->carddavBackend->updateShares($this, $add, $remove); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Returns the list of people whom this addressbook is shared with. |
|
84 | + * |
|
85 | + * Every element in this array should have the following properties: |
|
86 | + * * href - Often a mailto: address |
|
87 | + * * commonName - Optional, for example a first + last name |
|
88 | + * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. |
|
89 | + * * readOnly - boolean |
|
90 | + * * summary - Optional, a description for the share |
|
91 | + * |
|
92 | + * @return array |
|
93 | + */ |
|
94 | + public function getShares() { |
|
95 | + if ($this->isShared()) { |
|
96 | + return []; |
|
97 | + } |
|
98 | + return $this->carddavBackend->getShares($this->getResourceId()); |
|
99 | + } |
|
100 | + |
|
101 | + public function getACL() { |
|
102 | + $acl = [ |
|
103 | + [ |
|
104 | + 'privilege' => '{DAV:}read', |
|
105 | + 'principal' => $this->getOwner(), |
|
106 | + 'protected' => true, |
|
107 | + ]]; |
|
108 | + $acl[] = [ |
|
109 | + 'privilege' => '{DAV:}write', |
|
110 | + 'principal' => $this->getOwner(), |
|
111 | + 'protected' => true, |
|
112 | + ]; |
|
113 | + if ($this->getOwner() !== parent::getOwner()) { |
|
114 | + $acl[] = [ |
|
115 | + 'privilege' => '{DAV:}read', |
|
116 | + 'principal' => parent::getOwner(), |
|
117 | + 'protected' => true, |
|
118 | + ]; |
|
119 | + if ($this->canWrite()) { |
|
120 | + $acl[] = [ |
|
121 | + 'privilege' => '{DAV:}write', |
|
122 | + 'principal' => parent::getOwner(), |
|
123 | + 'protected' => true, |
|
124 | + ]; |
|
125 | + } |
|
126 | + } |
|
127 | + if ($this->getOwner() === 'principals/system/system') { |
|
128 | + $acl[] = [ |
|
129 | + 'privilege' => '{DAV:}read', |
|
130 | + 'principal' => '{DAV:}authenticated', |
|
131 | + 'protected' => true, |
|
132 | + ]; |
|
133 | + } |
|
134 | + |
|
135 | + if ($this->isShared()) { |
|
136 | + return $acl; |
|
137 | + } |
|
138 | + |
|
139 | + return $this->carddavBackend->applyShareAcl($this->getResourceId(), $acl); |
|
140 | + } |
|
141 | + |
|
142 | + public function getChildACL() { |
|
143 | + return $this->getACL(); |
|
144 | + } |
|
145 | + |
|
146 | + public function getChild($name) { |
|
147 | + |
|
148 | + $obj = $this->carddavBackend->getCard($this->addressBookInfo['id'], $name); |
|
149 | + if (!$obj) { |
|
150 | + throw new NotFound('Card not found'); |
|
151 | + } |
|
152 | + $obj['acl'] = $this->getChildACL(); |
|
153 | + return new Card($this->carddavBackend, $this->addressBookInfo, $obj); |
|
154 | + |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * @return int |
|
159 | + */ |
|
160 | + public function getResourceId() { |
|
161 | + return $this->addressBookInfo['id']; |
|
162 | + } |
|
163 | + |
|
164 | + public function getOwner() { |
|
165 | + if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
166 | + return $this->addressBookInfo['{http://owncloud.org/ns}owner-principal']; |
|
167 | + } |
|
168 | + return parent::getOwner(); |
|
169 | + } |
|
170 | + |
|
171 | + public function delete() { |
|
172 | + if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
173 | + $principal = 'principal:' . parent::getOwner(); |
|
174 | + $shares = $this->carddavBackend->getShares($this->getResourceId()); |
|
175 | + $shares = array_filter($shares, function($share) use ($principal){ |
|
176 | + return $share['href'] === $principal; |
|
177 | + }); |
|
178 | + if (empty($shares)) { |
|
179 | + throw new Forbidden(); |
|
180 | + } |
|
181 | + |
|
182 | + $this->carddavBackend->updateShares($this, [], [ |
|
183 | + 'href' => $principal |
|
184 | + ]); |
|
185 | + return; |
|
186 | + } |
|
187 | + parent::delete(); |
|
188 | + } |
|
189 | + |
|
190 | + public function propPatch(PropPatch $propPatch) { |
|
191 | + if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
192 | + throw new Forbidden(); |
|
193 | + } |
|
194 | + parent::propPatch($propPatch); |
|
195 | + } |
|
196 | + |
|
197 | + public function getContactsGroups() { |
|
198 | + return $this->carddavBackend->collectCardProperties($this->getResourceId(), 'CATEGORIES'); |
|
199 | + } |
|
200 | + |
|
201 | + private function isShared() { |
|
202 | + if (!isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
203 | + return false; |
|
204 | + } |
|
205 | + |
|
206 | + return $this->addressBookInfo['{http://owncloud.org/ns}owner-principal'] !== $this->addressBookInfo['principaluri']; |
|
207 | + } |
|
208 | + |
|
209 | + private function canWrite() { |
|
210 | + if (isset($this->addressBookInfo['{http://owncloud.org/ns}read-only'])) { |
|
211 | + return !$this->addressBookInfo['{http://owncloud.org/ns}read-only']; |
|
212 | + } |
|
213 | + return true; |
|
214 | + } |
|
215 | 215 | } |
@@ -38,139 +38,139 @@ |
||
38 | 38 | |
39 | 39 | class DecryptAll extends Command { |
40 | 40 | |
41 | - /** @var IManager */ |
|
42 | - protected $encryptionManager; |
|
43 | - |
|
44 | - /** @var IAppManager */ |
|
45 | - protected $appManager; |
|
46 | - |
|
47 | - /** @var IConfig */ |
|
48 | - protected $config; |
|
49 | - |
|
50 | - /** @var QuestionHelper */ |
|
51 | - protected $questionHelper; |
|
52 | - |
|
53 | - /** @var bool */ |
|
54 | - protected $wasTrashbinEnabled; |
|
55 | - |
|
56 | - /** @var bool */ |
|
57 | - protected $wasMaintenanceModeEnabled; |
|
58 | - |
|
59 | - /** @var \OC\Encryption\DecryptAll */ |
|
60 | - protected $decryptAll; |
|
61 | - |
|
62 | - /** |
|
63 | - * @param IManager $encryptionManager |
|
64 | - * @param IAppManager $appManager |
|
65 | - * @param IConfig $config |
|
66 | - * @param \OC\Encryption\DecryptAll $decryptAll |
|
67 | - * @param QuestionHelper $questionHelper |
|
68 | - */ |
|
69 | - public function __construct( |
|
70 | - IManager $encryptionManager, |
|
71 | - IAppManager $appManager, |
|
72 | - IConfig $config, |
|
73 | - \OC\Encryption\DecryptAll $decryptAll, |
|
74 | - QuestionHelper $questionHelper |
|
75 | - ) { |
|
76 | - parent::__construct(); |
|
77 | - |
|
78 | - $this->appManager = $appManager; |
|
79 | - $this->encryptionManager = $encryptionManager; |
|
80 | - $this->config = $config; |
|
81 | - $this->decryptAll = $decryptAll; |
|
82 | - $this->questionHelper = $questionHelper; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Set maintenance mode and disable the trashbin app |
|
87 | - */ |
|
88 | - protected function forceMaintenanceAndTrashbin() { |
|
89 | - $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin'); |
|
90 | - $this->wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
91 | - $this->config->setSystemValue('maintenance', true); |
|
92 | - $this->appManager->disableApp('files_trashbin'); |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Reset the maintenance mode and re-enable the trashbin app |
|
97 | - */ |
|
98 | - protected function resetMaintenanceAndTrashbin() { |
|
99 | - $this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled); |
|
100 | - if ($this->wasTrashbinEnabled) { |
|
101 | - $this->appManager->enableApp('files_trashbin'); |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - protected function configure() { |
|
106 | - parent::configure(); |
|
107 | - |
|
108 | - $this->setName('encryption:decrypt-all'); |
|
109 | - $this->setDescription('Disable server-side encryption and decrypt all files'); |
|
110 | - $this->setHelp( |
|
111 | - 'This will disable server-side encryption and decrypt all files for ' |
|
112 | - . 'all users if it is supported by your encryption module. ' |
|
113 | - . 'Please make sure that no user access his files during this process!' |
|
114 | - ); |
|
115 | - $this->addArgument( |
|
116 | - 'user', |
|
117 | - InputArgument::OPTIONAL, |
|
118 | - 'user for which you want to decrypt all files (optional)', |
|
119 | - '' |
|
120 | - ); |
|
121 | - } |
|
122 | - |
|
123 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
124 | - |
|
125 | - try { |
|
126 | - if ($this->encryptionManager->isEnabled() === true) { |
|
127 | - $output->write('Disable server side encryption... '); |
|
128 | - $this->config->setAppValue('core', 'encryption_enabled', 'no'); |
|
129 | - $output->writeln('done.'); |
|
130 | - } else { |
|
131 | - $output->writeln('Server side encryption not enabled. Nothing to do.'); |
|
132 | - return; |
|
133 | - } |
|
134 | - |
|
135 | - $uid = $input->getArgument('user'); |
|
136 | - if ($uid === '') { |
|
137 | - $message = 'your Nextcloud'; |
|
138 | - } else { |
|
139 | - $message = "$uid's account"; |
|
140 | - } |
|
141 | - |
|
142 | - $output->writeln("\n"); |
|
143 | - $output->writeln("You are about to start to decrypt all files stored in $message."); |
|
144 | - $output->writeln('It will depend on the encryption module and your setup if this is possible.'); |
|
145 | - $output->writeln('Depending on the number and size of your files this can take some time'); |
|
146 | - $output->writeln('Please make sure that no user access his files during this process!'); |
|
147 | - $output->writeln(''); |
|
148 | - $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false); |
|
149 | - if ($this->questionHelper->ask($input, $output, $question)) { |
|
150 | - $this->forceMaintenanceAndTrashbin(); |
|
151 | - $user = $input->getArgument('user'); |
|
152 | - $result = $this->decryptAll->decryptAll($input, $output, $user); |
|
153 | - if ($result === false) { |
|
154 | - $output->writeln(' aborted.'); |
|
155 | - $output->writeln('Server side encryption remains enabled'); |
|
156 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
157 | - } else if ($uid !== '') { |
|
158 | - $output->writeln('Server side encryption remains enabled'); |
|
159 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
160 | - } |
|
161 | - $this->resetMaintenanceAndTrashbin(); |
|
162 | - } else { |
|
163 | - $output->write('Enable server side encryption... '); |
|
164 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
165 | - $output->writeln('done.'); |
|
166 | - $output->writeln('aborted'); |
|
167 | - } |
|
168 | - } catch (\Exception $e) { |
|
169 | - // enable server side encryption again if something went wrong |
|
170 | - $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
171 | - $this->resetMaintenanceAndTrashbin(); |
|
172 | - throw $e; |
|
173 | - } |
|
174 | - |
|
175 | - } |
|
41 | + /** @var IManager */ |
|
42 | + protected $encryptionManager; |
|
43 | + |
|
44 | + /** @var IAppManager */ |
|
45 | + protected $appManager; |
|
46 | + |
|
47 | + /** @var IConfig */ |
|
48 | + protected $config; |
|
49 | + |
|
50 | + /** @var QuestionHelper */ |
|
51 | + protected $questionHelper; |
|
52 | + |
|
53 | + /** @var bool */ |
|
54 | + protected $wasTrashbinEnabled; |
|
55 | + |
|
56 | + /** @var bool */ |
|
57 | + protected $wasMaintenanceModeEnabled; |
|
58 | + |
|
59 | + /** @var \OC\Encryption\DecryptAll */ |
|
60 | + protected $decryptAll; |
|
61 | + |
|
62 | + /** |
|
63 | + * @param IManager $encryptionManager |
|
64 | + * @param IAppManager $appManager |
|
65 | + * @param IConfig $config |
|
66 | + * @param \OC\Encryption\DecryptAll $decryptAll |
|
67 | + * @param QuestionHelper $questionHelper |
|
68 | + */ |
|
69 | + public function __construct( |
|
70 | + IManager $encryptionManager, |
|
71 | + IAppManager $appManager, |
|
72 | + IConfig $config, |
|
73 | + \OC\Encryption\DecryptAll $decryptAll, |
|
74 | + QuestionHelper $questionHelper |
|
75 | + ) { |
|
76 | + parent::__construct(); |
|
77 | + |
|
78 | + $this->appManager = $appManager; |
|
79 | + $this->encryptionManager = $encryptionManager; |
|
80 | + $this->config = $config; |
|
81 | + $this->decryptAll = $decryptAll; |
|
82 | + $this->questionHelper = $questionHelper; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Set maintenance mode and disable the trashbin app |
|
87 | + */ |
|
88 | + protected function forceMaintenanceAndTrashbin() { |
|
89 | + $this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin'); |
|
90 | + $this->wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
91 | + $this->config->setSystemValue('maintenance', true); |
|
92 | + $this->appManager->disableApp('files_trashbin'); |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Reset the maintenance mode and re-enable the trashbin app |
|
97 | + */ |
|
98 | + protected function resetMaintenanceAndTrashbin() { |
|
99 | + $this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled); |
|
100 | + if ($this->wasTrashbinEnabled) { |
|
101 | + $this->appManager->enableApp('files_trashbin'); |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + protected function configure() { |
|
106 | + parent::configure(); |
|
107 | + |
|
108 | + $this->setName('encryption:decrypt-all'); |
|
109 | + $this->setDescription('Disable server-side encryption and decrypt all files'); |
|
110 | + $this->setHelp( |
|
111 | + 'This will disable server-side encryption and decrypt all files for ' |
|
112 | + . 'all users if it is supported by your encryption module. ' |
|
113 | + . 'Please make sure that no user access his files during this process!' |
|
114 | + ); |
|
115 | + $this->addArgument( |
|
116 | + 'user', |
|
117 | + InputArgument::OPTIONAL, |
|
118 | + 'user for which you want to decrypt all files (optional)', |
|
119 | + '' |
|
120 | + ); |
|
121 | + } |
|
122 | + |
|
123 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
124 | + |
|
125 | + try { |
|
126 | + if ($this->encryptionManager->isEnabled() === true) { |
|
127 | + $output->write('Disable server side encryption... '); |
|
128 | + $this->config->setAppValue('core', 'encryption_enabled', 'no'); |
|
129 | + $output->writeln('done.'); |
|
130 | + } else { |
|
131 | + $output->writeln('Server side encryption not enabled. Nothing to do.'); |
|
132 | + return; |
|
133 | + } |
|
134 | + |
|
135 | + $uid = $input->getArgument('user'); |
|
136 | + if ($uid === '') { |
|
137 | + $message = 'your Nextcloud'; |
|
138 | + } else { |
|
139 | + $message = "$uid's account"; |
|
140 | + } |
|
141 | + |
|
142 | + $output->writeln("\n"); |
|
143 | + $output->writeln("You are about to start to decrypt all files stored in $message."); |
|
144 | + $output->writeln('It will depend on the encryption module and your setup if this is possible.'); |
|
145 | + $output->writeln('Depending on the number and size of your files this can take some time'); |
|
146 | + $output->writeln('Please make sure that no user access his files during this process!'); |
|
147 | + $output->writeln(''); |
|
148 | + $question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false); |
|
149 | + if ($this->questionHelper->ask($input, $output, $question)) { |
|
150 | + $this->forceMaintenanceAndTrashbin(); |
|
151 | + $user = $input->getArgument('user'); |
|
152 | + $result = $this->decryptAll->decryptAll($input, $output, $user); |
|
153 | + if ($result === false) { |
|
154 | + $output->writeln(' aborted.'); |
|
155 | + $output->writeln('Server side encryption remains enabled'); |
|
156 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
157 | + } else if ($uid !== '') { |
|
158 | + $output->writeln('Server side encryption remains enabled'); |
|
159 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
160 | + } |
|
161 | + $this->resetMaintenanceAndTrashbin(); |
|
162 | + } else { |
|
163 | + $output->write('Enable server side encryption... '); |
|
164 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
165 | + $output->writeln('done.'); |
|
166 | + $output->writeln('aborted'); |
|
167 | + } |
|
168 | + } catch (\Exception $e) { |
|
169 | + // enable server side encryption again if something went wrong |
|
170 | + $this->config->setAppValue('core', 'encryption_enabled', 'yes'); |
|
171 | + $this->resetMaintenanceAndTrashbin(); |
|
172 | + throw $e; |
|
173 | + } |
|
174 | + |
|
175 | + } |
|
176 | 176 | } |
@@ -30,172 +30,172 @@ |
||
30 | 30 | |
31 | 31 | class GroupPrincipalBackend implements BackendInterface { |
32 | 32 | |
33 | - const PRINCIPAL_PREFIX = 'principals/groups'; |
|
34 | - |
|
35 | - /** @var IGroupManager */ |
|
36 | - private $groupManager; |
|
37 | - |
|
38 | - /** |
|
39 | - * @param IGroupManager $IGroupManager |
|
40 | - */ |
|
41 | - public function __construct(IGroupManager $IGroupManager) { |
|
42 | - $this->groupManager = $IGroupManager; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * Returns a list of principals based on a prefix. |
|
47 | - * |
|
48 | - * This prefix will often contain something like 'principals'. You are only |
|
49 | - * expected to return principals that are in this base path. |
|
50 | - * |
|
51 | - * You are expected to return at least a 'uri' for every user, you can |
|
52 | - * return any additional properties if you wish so. Common properties are: |
|
53 | - * {DAV:}displayname |
|
54 | - * |
|
55 | - * @param string $prefixPath |
|
56 | - * @return string[] |
|
57 | - */ |
|
58 | - public function getPrincipalsByPrefix($prefixPath) { |
|
59 | - $principals = []; |
|
60 | - |
|
61 | - if ($prefixPath === self::PRINCIPAL_PREFIX) { |
|
62 | - foreach($this->groupManager->search('') as $user) { |
|
63 | - $principals[] = $this->groupToPrincipal($user); |
|
64 | - } |
|
65 | - } |
|
66 | - |
|
67 | - return $principals; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Returns a specific principal, specified by it's path. |
|
72 | - * The returned structure should be the exact same as from |
|
73 | - * getPrincipalsByPrefix. |
|
74 | - * |
|
75 | - * @param string $path |
|
76 | - * @return array |
|
77 | - */ |
|
78 | - public function getPrincipalByPath($path) { |
|
79 | - $elements = explode('/', $path, 3); |
|
80 | - if ($elements[0] !== 'principals') { |
|
81 | - return null; |
|
82 | - } |
|
83 | - if ($elements[1] !== 'groups') { |
|
84 | - return null; |
|
85 | - } |
|
86 | - $name = urldecode($elements[2]); |
|
87 | - $group = $this->groupManager->get($name); |
|
88 | - |
|
89 | - if (!is_null($group)) { |
|
90 | - return $this->groupToPrincipal($group); |
|
91 | - } |
|
92 | - |
|
93 | - return null; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Returns the list of members for a group-principal |
|
98 | - * |
|
99 | - * @param string $principal |
|
100 | - * @return string[] |
|
101 | - * @throws Exception |
|
102 | - */ |
|
103 | - public function getGroupMemberSet($principal) { |
|
104 | - $elements = explode('/', $principal); |
|
105 | - if ($elements[0] !== 'principals') { |
|
106 | - return []; |
|
107 | - } |
|
108 | - if ($elements[1] !== 'groups') { |
|
109 | - return []; |
|
110 | - } |
|
111 | - $name = $elements[2]; |
|
112 | - $group = $this->groupManager->get($name); |
|
113 | - |
|
114 | - if (is_null($group)) { |
|
115 | - return []; |
|
116 | - } |
|
117 | - |
|
118 | - return array_map(function($user) { |
|
119 | - return $this->userToPrincipal($user); |
|
120 | - }, $group->getUsers()); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Returns the list of groups a principal is a member of |
|
125 | - * |
|
126 | - * @param string $principal |
|
127 | - * @return array |
|
128 | - * @throws Exception |
|
129 | - */ |
|
130 | - public function getGroupMembership($principal) { |
|
131 | - return []; |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * Updates the list of group members for a group principal. |
|
136 | - * |
|
137 | - * The principals should be passed as a list of uri's. |
|
138 | - * |
|
139 | - * @param string $principal |
|
140 | - * @param string[] $members |
|
141 | - * @throws Exception |
|
142 | - */ |
|
143 | - public function setGroupMemberSet($principal, array $members) { |
|
144 | - throw new Exception('Setting members of the group is not supported yet'); |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * @param string $path |
|
149 | - * @param PropPatch $propPatch |
|
150 | - * @return int |
|
151 | - */ |
|
152 | - function updatePrincipal($path, PropPatch $propPatch) { |
|
153 | - return 0; |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @param string $prefixPath |
|
158 | - * @param array $searchProperties |
|
159 | - * @param string $test |
|
160 | - * @return array |
|
161 | - */ |
|
162 | - function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') { |
|
163 | - return []; |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * @param string $uri |
|
168 | - * @param string $principalPrefix |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - function findByUri($uri, $principalPrefix) { |
|
172 | - return ''; |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * @param IGroup $group |
|
177 | - * @return array |
|
178 | - */ |
|
179 | - protected function groupToPrincipal($group) { |
|
180 | - $groupId = $group->getGID(); |
|
181 | - $principal = [ |
|
182 | - 'uri' => 'principals/groups/' . urlencode($groupId), |
|
183 | - '{DAV:}displayname' => $groupId, |
|
184 | - ]; |
|
185 | - |
|
186 | - return $principal; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * @param IUser $user |
|
191 | - * @return array |
|
192 | - */ |
|
193 | - protected function userToPrincipal($user) { |
|
194 | - $principal = [ |
|
195 | - 'uri' => 'principals/users/' . $user->getUID(), |
|
196 | - '{DAV:}displayname' => $user->getDisplayName(), |
|
197 | - ]; |
|
198 | - |
|
199 | - return $principal; |
|
200 | - } |
|
33 | + const PRINCIPAL_PREFIX = 'principals/groups'; |
|
34 | + |
|
35 | + /** @var IGroupManager */ |
|
36 | + private $groupManager; |
|
37 | + |
|
38 | + /** |
|
39 | + * @param IGroupManager $IGroupManager |
|
40 | + */ |
|
41 | + public function __construct(IGroupManager $IGroupManager) { |
|
42 | + $this->groupManager = $IGroupManager; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * Returns a list of principals based on a prefix. |
|
47 | + * |
|
48 | + * This prefix will often contain something like 'principals'. You are only |
|
49 | + * expected to return principals that are in this base path. |
|
50 | + * |
|
51 | + * You are expected to return at least a 'uri' for every user, you can |
|
52 | + * return any additional properties if you wish so. Common properties are: |
|
53 | + * {DAV:}displayname |
|
54 | + * |
|
55 | + * @param string $prefixPath |
|
56 | + * @return string[] |
|
57 | + */ |
|
58 | + public function getPrincipalsByPrefix($prefixPath) { |
|
59 | + $principals = []; |
|
60 | + |
|
61 | + if ($prefixPath === self::PRINCIPAL_PREFIX) { |
|
62 | + foreach($this->groupManager->search('') as $user) { |
|
63 | + $principals[] = $this->groupToPrincipal($user); |
|
64 | + } |
|
65 | + } |
|
66 | + |
|
67 | + return $principals; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Returns a specific principal, specified by it's path. |
|
72 | + * The returned structure should be the exact same as from |
|
73 | + * getPrincipalsByPrefix. |
|
74 | + * |
|
75 | + * @param string $path |
|
76 | + * @return array |
|
77 | + */ |
|
78 | + public function getPrincipalByPath($path) { |
|
79 | + $elements = explode('/', $path, 3); |
|
80 | + if ($elements[0] !== 'principals') { |
|
81 | + return null; |
|
82 | + } |
|
83 | + if ($elements[1] !== 'groups') { |
|
84 | + return null; |
|
85 | + } |
|
86 | + $name = urldecode($elements[2]); |
|
87 | + $group = $this->groupManager->get($name); |
|
88 | + |
|
89 | + if (!is_null($group)) { |
|
90 | + return $this->groupToPrincipal($group); |
|
91 | + } |
|
92 | + |
|
93 | + return null; |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Returns the list of members for a group-principal |
|
98 | + * |
|
99 | + * @param string $principal |
|
100 | + * @return string[] |
|
101 | + * @throws Exception |
|
102 | + */ |
|
103 | + public function getGroupMemberSet($principal) { |
|
104 | + $elements = explode('/', $principal); |
|
105 | + if ($elements[0] !== 'principals') { |
|
106 | + return []; |
|
107 | + } |
|
108 | + if ($elements[1] !== 'groups') { |
|
109 | + return []; |
|
110 | + } |
|
111 | + $name = $elements[2]; |
|
112 | + $group = $this->groupManager->get($name); |
|
113 | + |
|
114 | + if (is_null($group)) { |
|
115 | + return []; |
|
116 | + } |
|
117 | + |
|
118 | + return array_map(function($user) { |
|
119 | + return $this->userToPrincipal($user); |
|
120 | + }, $group->getUsers()); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Returns the list of groups a principal is a member of |
|
125 | + * |
|
126 | + * @param string $principal |
|
127 | + * @return array |
|
128 | + * @throws Exception |
|
129 | + */ |
|
130 | + public function getGroupMembership($principal) { |
|
131 | + return []; |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * Updates the list of group members for a group principal. |
|
136 | + * |
|
137 | + * The principals should be passed as a list of uri's. |
|
138 | + * |
|
139 | + * @param string $principal |
|
140 | + * @param string[] $members |
|
141 | + * @throws Exception |
|
142 | + */ |
|
143 | + public function setGroupMemberSet($principal, array $members) { |
|
144 | + throw new Exception('Setting members of the group is not supported yet'); |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * @param string $path |
|
149 | + * @param PropPatch $propPatch |
|
150 | + * @return int |
|
151 | + */ |
|
152 | + function updatePrincipal($path, PropPatch $propPatch) { |
|
153 | + return 0; |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * @param string $prefixPath |
|
158 | + * @param array $searchProperties |
|
159 | + * @param string $test |
|
160 | + * @return array |
|
161 | + */ |
|
162 | + function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') { |
|
163 | + return []; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * @param string $uri |
|
168 | + * @param string $principalPrefix |
|
169 | + * @return string |
|
170 | + */ |
|
171 | + function findByUri($uri, $principalPrefix) { |
|
172 | + return ''; |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * @param IGroup $group |
|
177 | + * @return array |
|
178 | + */ |
|
179 | + protected function groupToPrincipal($group) { |
|
180 | + $groupId = $group->getGID(); |
|
181 | + $principal = [ |
|
182 | + 'uri' => 'principals/groups/' . urlencode($groupId), |
|
183 | + '{DAV:}displayname' => $groupId, |
|
184 | + ]; |
|
185 | + |
|
186 | + return $principal; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * @param IUser $user |
|
191 | + * @return array |
|
192 | + */ |
|
193 | + protected function userToPrincipal($user) { |
|
194 | + $principal = [ |
|
195 | + 'uri' => 'principals/users/' . $user->getUID(), |
|
196 | + '{DAV:}displayname' => $user->getDisplayName(), |
|
197 | + ]; |
|
198 | + |
|
199 | + return $principal; |
|
200 | + } |
|
201 | 201 | } |
@@ -33,170 +33,170 @@ |
||
33 | 33 | |
34 | 34 | class File implements ICache { |
35 | 35 | |
36 | - /** @var View */ |
|
37 | - protected $storage; |
|
36 | + /** @var View */ |
|
37 | + protected $storage; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Returns the cache storage for the logged in user |
|
41 | - * |
|
42 | - * @return \OC\Files\View cache storage |
|
43 | - * @throws \OC\ForbiddenException |
|
44 | - * @throws \OC\User\NoUserException |
|
45 | - */ |
|
46 | - protected function getStorage() { |
|
47 | - if (isset($this->storage)) { |
|
48 | - return $this->storage; |
|
49 | - } |
|
50 | - if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
51 | - $rootView = new View(); |
|
52 | - $user = \OC::$server->getUserSession()->getUser(); |
|
53 | - Filesystem::initMountPoints($user->getUID()); |
|
54 | - if (!$rootView->file_exists('/' . $user->getUID() . '/cache')) { |
|
55 | - $rootView->mkdir('/' . $user->getUID() . '/cache'); |
|
56 | - } |
|
57 | - $this->storage = new View('/' . $user->getUID() . '/cache'); |
|
58 | - return $this->storage; |
|
59 | - } else { |
|
60 | - \OCP\Util::writeLog('core', 'Can\'t get cache storage, user not logged in', \OCP\Util::ERROR); |
|
61 | - throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in'); |
|
62 | - } |
|
63 | - } |
|
39 | + /** |
|
40 | + * Returns the cache storage for the logged in user |
|
41 | + * |
|
42 | + * @return \OC\Files\View cache storage |
|
43 | + * @throws \OC\ForbiddenException |
|
44 | + * @throws \OC\User\NoUserException |
|
45 | + */ |
|
46 | + protected function getStorage() { |
|
47 | + if (isset($this->storage)) { |
|
48 | + return $this->storage; |
|
49 | + } |
|
50 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
51 | + $rootView = new View(); |
|
52 | + $user = \OC::$server->getUserSession()->getUser(); |
|
53 | + Filesystem::initMountPoints($user->getUID()); |
|
54 | + if (!$rootView->file_exists('/' . $user->getUID() . '/cache')) { |
|
55 | + $rootView->mkdir('/' . $user->getUID() . '/cache'); |
|
56 | + } |
|
57 | + $this->storage = new View('/' . $user->getUID() . '/cache'); |
|
58 | + return $this->storage; |
|
59 | + } else { |
|
60 | + \OCP\Util::writeLog('core', 'Can\'t get cache storage, user not logged in', \OCP\Util::ERROR); |
|
61 | + throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in'); |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @param string $key |
|
67 | - * @return mixed|null |
|
68 | - * @throws \OC\ForbiddenException |
|
69 | - */ |
|
70 | - public function get($key) { |
|
71 | - $result = null; |
|
72 | - if ($this->hasKey($key)) { |
|
73 | - $storage = $this->getStorage(); |
|
74 | - $result = $storage->file_get_contents($key); |
|
75 | - } |
|
76 | - return $result; |
|
77 | - } |
|
65 | + /** |
|
66 | + * @param string $key |
|
67 | + * @return mixed|null |
|
68 | + * @throws \OC\ForbiddenException |
|
69 | + */ |
|
70 | + public function get($key) { |
|
71 | + $result = null; |
|
72 | + if ($this->hasKey($key)) { |
|
73 | + $storage = $this->getStorage(); |
|
74 | + $result = $storage->file_get_contents($key); |
|
75 | + } |
|
76 | + return $result; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Returns the size of the stored/cached data |
|
81 | - * |
|
82 | - * @param string $key |
|
83 | - * @return int |
|
84 | - */ |
|
85 | - public function size($key) { |
|
86 | - $result = 0; |
|
87 | - if ($this->hasKey($key)) { |
|
88 | - $storage = $this->getStorage(); |
|
89 | - $result = $storage->filesize($key); |
|
90 | - } |
|
91 | - return $result; |
|
92 | - } |
|
79 | + /** |
|
80 | + * Returns the size of the stored/cached data |
|
81 | + * |
|
82 | + * @param string $key |
|
83 | + * @return int |
|
84 | + */ |
|
85 | + public function size($key) { |
|
86 | + $result = 0; |
|
87 | + if ($this->hasKey($key)) { |
|
88 | + $storage = $this->getStorage(); |
|
89 | + $result = $storage->filesize($key); |
|
90 | + } |
|
91 | + return $result; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @param string $key |
|
96 | - * @param mixed $value |
|
97 | - * @param int $ttl |
|
98 | - * @return bool|mixed |
|
99 | - * @throws \OC\ForbiddenException |
|
100 | - */ |
|
101 | - public function set($key, $value, $ttl = 0) { |
|
102 | - $storage = $this->getStorage(); |
|
103 | - $result = false; |
|
104 | - // unique id to avoid chunk collision, just in case |
|
105 | - $uniqueId = \OC::$server->getSecureRandom()->generate( |
|
106 | - 16, |
|
107 | - ISecureRandom::CHAR_DIGITS . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER |
|
108 | - ); |
|
94 | + /** |
|
95 | + * @param string $key |
|
96 | + * @param mixed $value |
|
97 | + * @param int $ttl |
|
98 | + * @return bool|mixed |
|
99 | + * @throws \OC\ForbiddenException |
|
100 | + */ |
|
101 | + public function set($key, $value, $ttl = 0) { |
|
102 | + $storage = $this->getStorage(); |
|
103 | + $result = false; |
|
104 | + // unique id to avoid chunk collision, just in case |
|
105 | + $uniqueId = \OC::$server->getSecureRandom()->generate( |
|
106 | + 16, |
|
107 | + ISecureRandom::CHAR_DIGITS . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER |
|
108 | + ); |
|
109 | 109 | |
110 | - // use part file to prevent hasKey() to find the key |
|
111 | - // while it is being written |
|
112 | - $keyPart = $key . '.' . $uniqueId . '.part'; |
|
113 | - if ($storage and $storage->file_put_contents($keyPart, $value)) { |
|
114 | - if ($ttl === 0) { |
|
115 | - $ttl = 86400; // 60*60*24 |
|
116 | - } |
|
117 | - $result = $storage->touch($keyPart, time() + $ttl); |
|
118 | - $result &= $storage->rename($keyPart, $key); |
|
119 | - } |
|
120 | - return $result; |
|
121 | - } |
|
110 | + // use part file to prevent hasKey() to find the key |
|
111 | + // while it is being written |
|
112 | + $keyPart = $key . '.' . $uniqueId . '.part'; |
|
113 | + if ($storage and $storage->file_put_contents($keyPart, $value)) { |
|
114 | + if ($ttl === 0) { |
|
115 | + $ttl = 86400; // 60*60*24 |
|
116 | + } |
|
117 | + $result = $storage->touch($keyPart, time() + $ttl); |
|
118 | + $result &= $storage->rename($keyPart, $key); |
|
119 | + } |
|
120 | + return $result; |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @param string $key |
|
125 | - * @return bool |
|
126 | - * @throws \OC\ForbiddenException |
|
127 | - */ |
|
128 | - public function hasKey($key) { |
|
129 | - $storage = $this->getStorage(); |
|
130 | - if ($storage && $storage->is_file($key) && $storage->isReadable($key)) { |
|
131 | - return true; |
|
132 | - } |
|
133 | - return false; |
|
134 | - } |
|
123 | + /** |
|
124 | + * @param string $key |
|
125 | + * @return bool |
|
126 | + * @throws \OC\ForbiddenException |
|
127 | + */ |
|
128 | + public function hasKey($key) { |
|
129 | + $storage = $this->getStorage(); |
|
130 | + if ($storage && $storage->is_file($key) && $storage->isReadable($key)) { |
|
131 | + return true; |
|
132 | + } |
|
133 | + return false; |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * @param string $key |
|
138 | - * @return bool|mixed |
|
139 | - * @throws \OC\ForbiddenException |
|
140 | - */ |
|
141 | - public function remove($key) { |
|
142 | - $storage = $this->getStorage(); |
|
143 | - if (!$storage) { |
|
144 | - return false; |
|
145 | - } |
|
146 | - return $storage->unlink($key); |
|
147 | - } |
|
136 | + /** |
|
137 | + * @param string $key |
|
138 | + * @return bool|mixed |
|
139 | + * @throws \OC\ForbiddenException |
|
140 | + */ |
|
141 | + public function remove($key) { |
|
142 | + $storage = $this->getStorage(); |
|
143 | + if (!$storage) { |
|
144 | + return false; |
|
145 | + } |
|
146 | + return $storage->unlink($key); |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * @param string $prefix |
|
151 | - * @return bool |
|
152 | - * @throws \OC\ForbiddenException |
|
153 | - */ |
|
154 | - public function clear($prefix = '') { |
|
155 | - $storage = $this->getStorage(); |
|
156 | - if ($storage and $storage->is_dir('/')) { |
|
157 | - $dh = $storage->opendir('/'); |
|
158 | - if (is_resource($dh)) { |
|
159 | - while (($file = readdir($dh)) !== false) { |
|
160 | - if ($file != '.' and $file != '..' and ($prefix === '' || strpos($file, $prefix) === 0)) { |
|
161 | - $storage->unlink('/' . $file); |
|
162 | - } |
|
163 | - } |
|
164 | - } |
|
165 | - } |
|
166 | - return true; |
|
167 | - } |
|
149 | + /** |
|
150 | + * @param string $prefix |
|
151 | + * @return bool |
|
152 | + * @throws \OC\ForbiddenException |
|
153 | + */ |
|
154 | + public function clear($prefix = '') { |
|
155 | + $storage = $this->getStorage(); |
|
156 | + if ($storage and $storage->is_dir('/')) { |
|
157 | + $dh = $storage->opendir('/'); |
|
158 | + if (is_resource($dh)) { |
|
159 | + while (($file = readdir($dh)) !== false) { |
|
160 | + if ($file != '.' and $file != '..' and ($prefix === '' || strpos($file, $prefix) === 0)) { |
|
161 | + $storage->unlink('/' . $file); |
|
162 | + } |
|
163 | + } |
|
164 | + } |
|
165 | + } |
|
166 | + return true; |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * Runs GC |
|
171 | - * @throws \OC\ForbiddenException |
|
172 | - */ |
|
173 | - public function gc() { |
|
174 | - $storage = $this->getStorage(); |
|
175 | - if ($storage and $storage->is_dir('/')) { |
|
176 | - // extra hour safety, in case of stray part chunks that take longer to write, |
|
177 | - // because touch() is only called after the chunk was finished |
|
178 | - $now = time() - 3600; |
|
179 | - $dh = $storage->opendir('/'); |
|
180 | - if (!is_resource($dh)) { |
|
181 | - return null; |
|
182 | - } |
|
183 | - while (($file = readdir($dh)) !== false) { |
|
184 | - if ($file != '.' and $file != '..') { |
|
185 | - try { |
|
186 | - $mtime = $storage->filemtime('/' . $file); |
|
187 | - if ($mtime < $now) { |
|
188 | - $storage->unlink('/' . $file); |
|
189 | - } |
|
190 | - } catch (\OCP\Lock\LockedException $e) { |
|
191 | - // ignore locked chunks |
|
192 | - \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', array('app' => 'core')); |
|
193 | - } catch (\OCP\Files\ForbiddenException $e) { |
|
194 | - \OC::$server->getLogger()->debug('Could not cleanup forbidden chunk "' . $file . '"', array('app' => 'core')); |
|
195 | - } catch (\OCP\Files\LockNotAcquiredException $e) { |
|
196 | - \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', array('app' => 'core')); |
|
197 | - } |
|
198 | - } |
|
199 | - } |
|
200 | - } |
|
201 | - } |
|
169 | + /** |
|
170 | + * Runs GC |
|
171 | + * @throws \OC\ForbiddenException |
|
172 | + */ |
|
173 | + public function gc() { |
|
174 | + $storage = $this->getStorage(); |
|
175 | + if ($storage and $storage->is_dir('/')) { |
|
176 | + // extra hour safety, in case of stray part chunks that take longer to write, |
|
177 | + // because touch() is only called after the chunk was finished |
|
178 | + $now = time() - 3600; |
|
179 | + $dh = $storage->opendir('/'); |
|
180 | + if (!is_resource($dh)) { |
|
181 | + return null; |
|
182 | + } |
|
183 | + while (($file = readdir($dh)) !== false) { |
|
184 | + if ($file != '.' and $file != '..') { |
|
185 | + try { |
|
186 | + $mtime = $storage->filemtime('/' . $file); |
|
187 | + if ($mtime < $now) { |
|
188 | + $storage->unlink('/' . $file); |
|
189 | + } |
|
190 | + } catch (\OCP\Lock\LockedException $e) { |
|
191 | + // ignore locked chunks |
|
192 | + \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', array('app' => 'core')); |
|
193 | + } catch (\OCP\Files\ForbiddenException $e) { |
|
194 | + \OC::$server->getLogger()->debug('Could not cleanup forbidden chunk "' . $file . '"', array('app' => 'core')); |
|
195 | + } catch (\OCP\Files\LockNotAcquiredException $e) { |
|
196 | + \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', array('app' => 'core')); |
|
197 | + } |
|
198 | + } |
|
199 | + } |
|
200 | + } |
|
201 | + } |
|
202 | 202 | } |
@@ -45,114 +45,114 @@ |
||
45 | 45 | * @package OCA\DAV\Connector\Sabre |
46 | 46 | */ |
47 | 47 | class FakeLockerPlugin extends ServerPlugin { |
48 | - /** @var \Sabre\DAV\Server */ |
|
49 | - private $server; |
|
48 | + /** @var \Sabre\DAV\Server */ |
|
49 | + private $server; |
|
50 | 50 | |
51 | - /** {@inheritDoc} */ |
|
52 | - public function initialize(\Sabre\DAV\Server $server) { |
|
53 | - $this->server = $server; |
|
54 | - $this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1); |
|
55 | - $this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1); |
|
56 | - $server->on('propFind', [$this, 'propFind']); |
|
57 | - $server->on('validateTokens', [$this, 'validateTokens']); |
|
58 | - } |
|
51 | + /** {@inheritDoc} */ |
|
52 | + public function initialize(\Sabre\DAV\Server $server) { |
|
53 | + $this->server = $server; |
|
54 | + $this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1); |
|
55 | + $this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1); |
|
56 | + $server->on('propFind', [$this, 'propFind']); |
|
57 | + $server->on('validateTokens', [$this, 'validateTokens']); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Indicate that we support LOCK and UNLOCK |
|
62 | - * |
|
63 | - * @param string $path |
|
64 | - * @return string[] |
|
65 | - */ |
|
66 | - public function getHTTPMethods($path) { |
|
67 | - return [ |
|
68 | - 'LOCK', |
|
69 | - 'UNLOCK', |
|
70 | - ]; |
|
71 | - } |
|
60 | + /** |
|
61 | + * Indicate that we support LOCK and UNLOCK |
|
62 | + * |
|
63 | + * @param string $path |
|
64 | + * @return string[] |
|
65 | + */ |
|
66 | + public function getHTTPMethods($path) { |
|
67 | + return [ |
|
68 | + 'LOCK', |
|
69 | + 'UNLOCK', |
|
70 | + ]; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Indicate that we support locking |
|
75 | - * |
|
76 | - * @return integer[] |
|
77 | - */ |
|
78 | - function getFeatures() { |
|
79 | - return [2]; |
|
80 | - } |
|
73 | + /** |
|
74 | + * Indicate that we support locking |
|
75 | + * |
|
76 | + * @return integer[] |
|
77 | + */ |
|
78 | + function getFeatures() { |
|
79 | + return [2]; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Return some dummy response for PROPFIND requests with regard to locking |
|
84 | - * |
|
85 | - * @param PropFind $propFind |
|
86 | - * @param INode $node |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - function propFind(PropFind $propFind, INode $node) { |
|
90 | - $propFind->handle('{DAV:}supportedlock', function() { |
|
91 | - return new SupportedLock(true); |
|
92 | - }); |
|
93 | - $propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) { |
|
94 | - return new LockDiscovery([]); |
|
95 | - }); |
|
96 | - } |
|
82 | + /** |
|
83 | + * Return some dummy response for PROPFIND requests with regard to locking |
|
84 | + * |
|
85 | + * @param PropFind $propFind |
|
86 | + * @param INode $node |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + function propFind(PropFind $propFind, INode $node) { |
|
90 | + $propFind->handle('{DAV:}supportedlock', function() { |
|
91 | + return new SupportedLock(true); |
|
92 | + }); |
|
93 | + $propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) { |
|
94 | + return new LockDiscovery([]); |
|
95 | + }); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Mark a locking token always as valid |
|
100 | - * |
|
101 | - * @param RequestInterface $request |
|
102 | - * @param array $conditions |
|
103 | - */ |
|
104 | - public function validateTokens(RequestInterface $request, &$conditions) { |
|
105 | - foreach($conditions as &$fileCondition) { |
|
106 | - if(isset($fileCondition['tokens'])) { |
|
107 | - foreach($fileCondition['tokens'] as &$token) { |
|
108 | - if(isset($token['token'])) { |
|
109 | - if(substr($token['token'], 0, 16) === 'opaquelocktoken:') { |
|
110 | - $token['validToken'] = true; |
|
111 | - } |
|
112 | - } |
|
113 | - } |
|
114 | - } |
|
115 | - } |
|
116 | - } |
|
98 | + /** |
|
99 | + * Mark a locking token always as valid |
|
100 | + * |
|
101 | + * @param RequestInterface $request |
|
102 | + * @param array $conditions |
|
103 | + */ |
|
104 | + public function validateTokens(RequestInterface $request, &$conditions) { |
|
105 | + foreach($conditions as &$fileCondition) { |
|
106 | + if(isset($fileCondition['tokens'])) { |
|
107 | + foreach($fileCondition['tokens'] as &$token) { |
|
108 | + if(isset($token['token'])) { |
|
109 | + if(substr($token['token'], 0, 16) === 'opaquelocktoken:') { |
|
110 | + $token['validToken'] = true; |
|
111 | + } |
|
112 | + } |
|
113 | + } |
|
114 | + } |
|
115 | + } |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Fakes a successful LOCK |
|
120 | - * |
|
121 | - * @param RequestInterface $request |
|
122 | - * @param ResponseInterface $response |
|
123 | - * @return bool |
|
124 | - */ |
|
125 | - public function fakeLockProvider(RequestInterface $request, |
|
126 | - ResponseInterface $response) { |
|
118 | + /** |
|
119 | + * Fakes a successful LOCK |
|
120 | + * |
|
121 | + * @param RequestInterface $request |
|
122 | + * @param ResponseInterface $response |
|
123 | + * @return bool |
|
124 | + */ |
|
125 | + public function fakeLockProvider(RequestInterface $request, |
|
126 | + ResponseInterface $response) { |
|
127 | 127 | |
128 | - $lockInfo = new LockInfo(); |
|
129 | - $lockInfo->token = md5($request->getPath()); |
|
130 | - $lockInfo->uri = $request->getPath(); |
|
131 | - $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
132 | - $lockInfo->timeout = 1800; |
|
128 | + $lockInfo = new LockInfo(); |
|
129 | + $lockInfo->token = md5($request->getPath()); |
|
130 | + $lockInfo->uri = $request->getPath(); |
|
131 | + $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
132 | + $lockInfo->timeout = 1800; |
|
133 | 133 | |
134 | - $body = $this->server->xml->write('{DAV:}prop', [ |
|
135 | - '{DAV:}lockdiscovery' => |
|
136 | - new LockDiscovery([$lockInfo]) |
|
137 | - ]); |
|
134 | + $body = $this->server->xml->write('{DAV:}prop', [ |
|
135 | + '{DAV:}lockdiscovery' => |
|
136 | + new LockDiscovery([$lockInfo]) |
|
137 | + ]); |
|
138 | 138 | |
139 | - $response->setStatus(200); |
|
140 | - $response->setBody($body); |
|
139 | + $response->setStatus(200); |
|
140 | + $response->setBody($body); |
|
141 | 141 | |
142 | - return false; |
|
143 | - } |
|
142 | + return false; |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Fakes a successful LOCK |
|
147 | - * |
|
148 | - * @param RequestInterface $request |
|
149 | - * @param ResponseInterface $response |
|
150 | - * @return bool |
|
151 | - */ |
|
152 | - public function fakeUnlockProvider(RequestInterface $request, |
|
153 | - ResponseInterface $response) { |
|
154 | - $response->setStatus(204); |
|
155 | - $response->setHeader('Content-Length', '0'); |
|
156 | - return false; |
|
157 | - } |
|
145 | + /** |
|
146 | + * Fakes a successful LOCK |
|
147 | + * |
|
148 | + * @param RequestInterface $request |
|
149 | + * @param ResponseInterface $response |
|
150 | + * @return bool |
|
151 | + */ |
|
152 | + public function fakeUnlockProvider(RequestInterface $request, |
|
153 | + ResponseInterface $response) { |
|
154 | + $response->setStatus(204); |
|
155 | + $response->setHeader('Content-Length', '0'); |
|
156 | + return false; |
|
157 | + } |
|
158 | 158 | } |
@@ -27,41 +27,41 @@ |
||
27 | 27 | * @since 12.0.0 |
28 | 28 | */ |
29 | 29 | interface ISearchQuery { |
30 | - /** |
|
31 | - * @return ISearchOperator |
|
32 | - * @since 12.0.0 |
|
33 | - */ |
|
34 | - public function getSearchOperation(); |
|
30 | + /** |
|
31 | + * @return ISearchOperator |
|
32 | + * @since 12.0.0 |
|
33 | + */ |
|
34 | + public function getSearchOperation(); |
|
35 | 35 | |
36 | - /** |
|
37 | - * Get the maximum number of results to return |
|
38 | - * |
|
39 | - * @return integer |
|
40 | - * @since 12.0.0 |
|
41 | - */ |
|
42 | - public function getLimit(); |
|
36 | + /** |
|
37 | + * Get the maximum number of results to return |
|
38 | + * |
|
39 | + * @return integer |
|
40 | + * @since 12.0.0 |
|
41 | + */ |
|
42 | + public function getLimit(); |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get the offset for returned results |
|
46 | - * |
|
47 | - * @return integer |
|
48 | - * @since 12.0.0 |
|
49 | - */ |
|
50 | - public function getOffset(); |
|
44 | + /** |
|
45 | + * Get the offset for returned results |
|
46 | + * |
|
47 | + * @return integer |
|
48 | + * @since 12.0.0 |
|
49 | + */ |
|
50 | + public function getOffset(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * The fields and directions to order by |
|
54 | - * |
|
55 | - * @return ISearchOrder[] |
|
56 | - * @since 12.0.0 |
|
57 | - */ |
|
58 | - public function getOrder(); |
|
52 | + /** |
|
53 | + * The fields and directions to order by |
|
54 | + * |
|
55 | + * @return ISearchOrder[] |
|
56 | + * @since 12.0.0 |
|
57 | + */ |
|
58 | + public function getOrder(); |
|
59 | 59 | |
60 | - /** |
|
61 | - * The user that issued the search |
|
62 | - * |
|
63 | - * @return IUser |
|
64 | - * @since 12.0.0 |
|
65 | - */ |
|
66 | - public function getUser(); |
|
60 | + /** |
|
61 | + * The user that issued the search |
|
62 | + * |
|
63 | + * @return IUser |
|
64 | + * @since 12.0.0 |
|
65 | + */ |
|
66 | + public function getUser(); |
|
67 | 67 | } |