@@ -29,14 +29,14 @@ |
||
| 29 | 29 | use OCP\Files\FileInfo; |
| 30 | 30 | |
| 31 | 31 | class WebP extends Image { |
| 32 | - /** |
|
| 33 | - * {@inheritDoc} |
|
| 34 | - */ |
|
| 35 | - public function getMimeType(): string { |
|
| 36 | - return '/image\/webp/'; |
|
| 37 | - } |
|
| 32 | + /** |
|
| 33 | + * {@inheritDoc} |
|
| 34 | + */ |
|
| 35 | + public function getMimeType(): string { |
|
| 36 | + return '/image\/webp/'; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public function isAvailable(FileInfo $file): bool { |
|
| 40 | - return (bool)(imagetypes() & IMG_WEBP); |
|
| 41 | - } |
|
| 39 | + public function isAvailable(FileInfo $file): bool { |
|
| 40 | + return (bool)(imagetypes() & IMG_WEBP); |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -37,6 +37,6 @@ |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function isAvailable(FileInfo $file): bool { |
| 40 | - return (bool)(imagetypes() & IMG_WEBP); |
|
| 40 | + return (bool) (imagetypes() & IMG_WEBP); |
|
| 41 | 41 | } |
| 42 | 42 | } |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - throw new \Exception('Could not load ' . $className, 0, $e); |
|
| 264 | + throw new \Exception('Could not load '.$className, 0, $e); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | * @throws \Exception |
| 272 | 272 | */ |
| 273 | 273 | private function loadSabrePluginsFromInfoXml(array $classes): array { |
| 274 | - return array_map(function (string $className): ServerPlugin { |
|
| 274 | + return array_map(function(string $className): ServerPlugin { |
|
| 275 | 275 | $instance = $this->createClass($className); |
| 276 | 276 | if (!($instance instanceof ServerPlugin)) { |
| 277 | - throw new \Exception('Sabre server plugin ' . $className . ' does not implement the ' . ServerPlugin::class . ' interface'); |
|
| 277 | + throw new \Exception('Sabre server plugin '.$className.' does not implement the '.ServerPlugin::class.' interface'); |
|
| 278 | 278 | } |
| 279 | 279 | return $instance; |
| 280 | 280 | }, $classes); |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | * @return Collection[] |
| 286 | 286 | */ |
| 287 | 287 | private function loadSabreCollectionsFromInfoXml(array $classes): array { |
| 288 | - return array_map(function (string $className): Collection { |
|
| 288 | + return array_map(function(string $className): Collection { |
|
| 289 | 289 | $instance = $this->createClass($className); |
| 290 | 290 | if (!($instance instanceof Collection)) { |
| 291 | - throw new \Exception('Sabre collection plugin ' . $className . ' does not implement the ' . Collection::class . ' interface'); |
|
| 291 | + throw new \Exception('Sabre collection plugin '.$className.' does not implement the '.Collection::class.' interface'); |
|
| 292 | 292 | } |
| 293 | 293 | return $instance; |
| 294 | 294 | }, $classes); |
@@ -299,10 +299,10 @@ discard block |
||
| 299 | 299 | * @return IAddressBookProvider[] |
| 300 | 300 | */ |
| 301 | 301 | private function loadSabreAddressBookPluginsFromInfoXml(array $classes): array { |
| 302 | - return array_map(function (string $className): IAddressBookProvider { |
|
| 302 | + return array_map(function(string $className): IAddressBookProvider { |
|
| 303 | 303 | $instance = $this->createClass($className); |
| 304 | 304 | if (!($instance instanceof IAddressBookProvider)) { |
| 305 | - throw new \Exception('Sabre address book plugin class ' . $className . ' does not implement the ' . IAddressBookProvider::class . ' interface'); |
|
| 305 | + throw new \Exception('Sabre address book plugin class '.$className.' does not implement the '.IAddressBookProvider::class.' interface'); |
|
| 306 | 306 | } |
| 307 | 307 | return $instance; |
| 308 | 308 | }, $classes); |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | * @return ICalendarProvider[] |
| 314 | 314 | */ |
| 315 | 315 | private function loadSabreCalendarPluginsFromInfoXml(array $classes): array { |
| 316 | - return array_map(function (string $className): ICalendarProvider { |
|
| 316 | + return array_map(function(string $className): ICalendarProvider { |
|
| 317 | 317 | $instance = $this->createClass($className); |
| 318 | 318 | if (!($instance instanceof ICalendarProvider)) { |
| 319 | - throw new \Exception('Sabre calendar plugin class ' . $className . ' does not implement the ' . ICalendarProvider::class . ' interface'); |
|
| 319 | + throw new \Exception('Sabre calendar plugin class '.$className.' does not implement the '.ICalendarProvider::class.' interface'); |
|
| 320 | 320 | } |
| 321 | 321 | return $instance; |
| 322 | 322 | }, $classes); |
@@ -27,272 +27,272 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class PluginManager { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * App plugins |
|
| 32 | - * |
|
| 33 | - * @var ServerPlugin[] |
|
| 34 | - */ |
|
| 35 | - private $plugins = []; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * App collections |
|
| 39 | - * |
|
| 40 | - * @var Collection[] |
|
| 41 | - */ |
|
| 42 | - private $collections = []; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Address book plugins |
|
| 46 | - * |
|
| 47 | - * @var IAddressBookProvider[] |
|
| 48 | - */ |
|
| 49 | - private $addressBookPlugins = []; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Calendar plugins |
|
| 53 | - * |
|
| 54 | - * @var ICalendarProvider[] |
|
| 55 | - */ |
|
| 56 | - private $calendarPlugins = []; |
|
| 57 | - |
|
| 58 | - /** @var bool */ |
|
| 59 | - private $populated = false; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Contstruct a PluginManager |
|
| 63 | - * |
|
| 64 | - * @param ServerContainer $container server container for resolving plugin classes |
|
| 65 | - * @param IAppManager $appManager app manager to loading apps and their info |
|
| 66 | - */ |
|
| 67 | - public function __construct( |
|
| 68 | - private ServerContainer $container, |
|
| 69 | - private IAppManager $appManager, |
|
| 70 | - ) { |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Returns an array of app-registered plugins |
|
| 75 | - * |
|
| 76 | - * @return ServerPlugin[] |
|
| 77 | - */ |
|
| 78 | - public function getAppPlugins() { |
|
| 79 | - $this->populate(); |
|
| 80 | - return $this->plugins; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Returns an array of app-registered collections |
|
| 85 | - * |
|
| 86 | - * @return array |
|
| 87 | - */ |
|
| 88 | - public function getAppCollections() { |
|
| 89 | - $this->populate(); |
|
| 90 | - return $this->collections; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @return IAddressBookProvider[] |
|
| 95 | - */ |
|
| 96 | - public function getAddressBookPlugins(): array { |
|
| 97 | - $this->populate(); |
|
| 98 | - return $this->addressBookPlugins; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Returns an array of app-registered calendar plugins |
|
| 103 | - * |
|
| 104 | - * @return ICalendarProvider[] |
|
| 105 | - */ |
|
| 106 | - public function getCalendarPlugins():array { |
|
| 107 | - $this->populate(); |
|
| 108 | - return $this->calendarPlugins; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Retrieve plugin and collection list and populate attributes |
|
| 113 | - */ |
|
| 114 | - private function populate(): void { |
|
| 115 | - if ($this->populated) { |
|
| 116 | - return; |
|
| 117 | - } |
|
| 118 | - $this->populated = true; |
|
| 119 | - |
|
| 120 | - $this->calendarPlugins[] = $this->container->get(AppCalendarPlugin::class); |
|
| 121 | - |
|
| 122 | - foreach ($this->appManager->getEnabledApps() as $app) { |
|
| 123 | - // load plugins and collections from info.xml |
|
| 124 | - $info = $this->appManager->getAppInfo($app); |
|
| 125 | - if (!isset($info['types']) || !in_array('dav', $info['types'], true)) { |
|
| 126 | - continue; |
|
| 127 | - } |
|
| 128 | - $plugins = $this->loadSabrePluginsFromInfoXml($this->extractPluginList($info)); |
|
| 129 | - foreach ($plugins as $plugin) { |
|
| 130 | - $this->plugins[] = $plugin; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - $collections = $this->loadSabreCollectionsFromInfoXml($this->extractCollectionList($info)); |
|
| 134 | - foreach ($collections as $collection) { |
|
| 135 | - $this->collections[] = $collection; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $addresbookPlugins = $this->loadSabreAddressBookPluginsFromInfoXml($this->extractAddressBookPluginList($info)); |
|
| 139 | - foreach ($addresbookPlugins as $addresbookPlugin) { |
|
| 140 | - $this->addressBookPlugins[] = $addresbookPlugin; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - $calendarPlugins = $this->loadSabreCalendarPluginsFromInfoXml($this->extractCalendarPluginList($info)); |
|
| 144 | - foreach ($calendarPlugins as $calendarPlugin) { |
|
| 145 | - $this->calendarPlugins[] = $calendarPlugin; |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @param array $array |
|
| 152 | - * @return string[] |
|
| 153 | - */ |
|
| 154 | - private function extractPluginList(array $array): array { |
|
| 155 | - if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 156 | - if (isset($array['sabre']['plugins']) && is_array($array['sabre']['plugins'])) { |
|
| 157 | - if (isset($array['sabre']['plugins']['plugin'])) { |
|
| 158 | - $items = $array['sabre']['plugins']['plugin']; |
|
| 159 | - if (!is_array($items)) { |
|
| 160 | - $items = [$items]; |
|
| 161 | - } |
|
| 162 | - return $items; |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - return []; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * @param array $array |
|
| 171 | - * @return string[] |
|
| 172 | - */ |
|
| 173 | - private function extractCollectionList(array $array): array { |
|
| 174 | - if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 175 | - if (isset($array['sabre']['collections']) && is_array($array['sabre']['collections'])) { |
|
| 176 | - if (isset($array['sabre']['collections']['collection'])) { |
|
| 177 | - $items = $array['sabre']['collections']['collection']; |
|
| 178 | - if (!is_array($items)) { |
|
| 179 | - $items = [$items]; |
|
| 180 | - } |
|
| 181 | - return $items; |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - return []; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * @param array $array |
|
| 190 | - * @return string[] |
|
| 191 | - */ |
|
| 192 | - private function extractAddressBookPluginList(array $array): array { |
|
| 193 | - if (!isset($array['sabre']) || !is_array($array['sabre'])) { |
|
| 194 | - return []; |
|
| 195 | - } |
|
| 196 | - if (!isset($array['sabre']['address-book-plugins']) || !is_array($array['sabre']['address-book-plugins'])) { |
|
| 197 | - return []; |
|
| 198 | - } |
|
| 199 | - if (!isset($array['sabre']['address-book-plugins']['plugin'])) { |
|
| 200 | - return []; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - $items = $array['sabre']['address-book-plugins']['plugin']; |
|
| 204 | - if (!is_array($items)) { |
|
| 205 | - $items = [$items]; |
|
| 206 | - } |
|
| 207 | - return $items; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * @param array $array |
|
| 212 | - * @return string[] |
|
| 213 | - */ |
|
| 214 | - private function extractCalendarPluginList(array $array): array { |
|
| 215 | - if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 216 | - if (isset($array['sabre']['calendar-plugins']) && is_array($array['sabre']['calendar-plugins'])) { |
|
| 217 | - if (isset($array['sabre']['calendar-plugins']['plugin'])) { |
|
| 218 | - $items = $array['sabre']['calendar-plugins']['plugin']; |
|
| 219 | - if (!is_array($items)) { |
|
| 220 | - $items = [$items]; |
|
| 221 | - } |
|
| 222 | - return $items; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - return []; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - private function createClass(string $className): object { |
|
| 230 | - try { |
|
| 231 | - return $this->container->get($className); |
|
| 232 | - } catch (QueryException $e) { |
|
| 233 | - if (class_exists($className)) { |
|
| 234 | - return new $className(); |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - throw new \Exception('Could not load ' . $className, 0, $e); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * @param string[] $classes |
|
| 244 | - * @return ServerPlugin[] |
|
| 245 | - * @throws \Exception |
|
| 246 | - */ |
|
| 247 | - private function loadSabrePluginsFromInfoXml(array $classes): array { |
|
| 248 | - return array_map(function (string $className): ServerPlugin { |
|
| 249 | - $instance = $this->createClass($className); |
|
| 250 | - if (!($instance instanceof ServerPlugin)) { |
|
| 251 | - throw new \Exception('Sabre server plugin ' . $className . ' does not implement the ' . ServerPlugin::class . ' interface'); |
|
| 252 | - } |
|
| 253 | - return $instance; |
|
| 254 | - }, $classes); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * @param string[] $classes |
|
| 259 | - * @return Collection[] |
|
| 260 | - */ |
|
| 261 | - private function loadSabreCollectionsFromInfoXml(array $classes): array { |
|
| 262 | - return array_map(function (string $className): Collection { |
|
| 263 | - $instance = $this->createClass($className); |
|
| 264 | - if (!($instance instanceof Collection)) { |
|
| 265 | - throw new \Exception('Sabre collection plugin ' . $className . ' does not implement the ' . Collection::class . ' interface'); |
|
| 266 | - } |
|
| 267 | - return $instance; |
|
| 268 | - }, $classes); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * @param string[] $classes |
|
| 273 | - * @return IAddressBookProvider[] |
|
| 274 | - */ |
|
| 275 | - private function loadSabreAddressBookPluginsFromInfoXml(array $classes): array { |
|
| 276 | - return array_map(function (string $className): IAddressBookProvider { |
|
| 277 | - $instance = $this->createClass($className); |
|
| 278 | - if (!($instance instanceof IAddressBookProvider)) { |
|
| 279 | - throw new \Exception('Sabre address book plugin class ' . $className . ' does not implement the ' . IAddressBookProvider::class . ' interface'); |
|
| 280 | - } |
|
| 281 | - return $instance; |
|
| 282 | - }, $classes); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * @param string[] $classes |
|
| 287 | - * @return ICalendarProvider[] |
|
| 288 | - */ |
|
| 289 | - private function loadSabreCalendarPluginsFromInfoXml(array $classes): array { |
|
| 290 | - return array_map(function (string $className): ICalendarProvider { |
|
| 291 | - $instance = $this->createClass($className); |
|
| 292 | - if (!($instance instanceof ICalendarProvider)) { |
|
| 293 | - throw new \Exception('Sabre calendar plugin class ' . $className . ' does not implement the ' . ICalendarProvider::class . ' interface'); |
|
| 294 | - } |
|
| 295 | - return $instance; |
|
| 296 | - }, $classes); |
|
| 297 | - } |
|
| 30 | + /** |
|
| 31 | + * App plugins |
|
| 32 | + * |
|
| 33 | + * @var ServerPlugin[] |
|
| 34 | + */ |
|
| 35 | + private $plugins = []; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * App collections |
|
| 39 | + * |
|
| 40 | + * @var Collection[] |
|
| 41 | + */ |
|
| 42 | + private $collections = []; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Address book plugins |
|
| 46 | + * |
|
| 47 | + * @var IAddressBookProvider[] |
|
| 48 | + */ |
|
| 49 | + private $addressBookPlugins = []; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Calendar plugins |
|
| 53 | + * |
|
| 54 | + * @var ICalendarProvider[] |
|
| 55 | + */ |
|
| 56 | + private $calendarPlugins = []; |
|
| 57 | + |
|
| 58 | + /** @var bool */ |
|
| 59 | + private $populated = false; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Contstruct a PluginManager |
|
| 63 | + * |
|
| 64 | + * @param ServerContainer $container server container for resolving plugin classes |
|
| 65 | + * @param IAppManager $appManager app manager to loading apps and their info |
|
| 66 | + */ |
|
| 67 | + public function __construct( |
|
| 68 | + private ServerContainer $container, |
|
| 69 | + private IAppManager $appManager, |
|
| 70 | + ) { |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Returns an array of app-registered plugins |
|
| 75 | + * |
|
| 76 | + * @return ServerPlugin[] |
|
| 77 | + */ |
|
| 78 | + public function getAppPlugins() { |
|
| 79 | + $this->populate(); |
|
| 80 | + return $this->plugins; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Returns an array of app-registered collections |
|
| 85 | + * |
|
| 86 | + * @return array |
|
| 87 | + */ |
|
| 88 | + public function getAppCollections() { |
|
| 89 | + $this->populate(); |
|
| 90 | + return $this->collections; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @return IAddressBookProvider[] |
|
| 95 | + */ |
|
| 96 | + public function getAddressBookPlugins(): array { |
|
| 97 | + $this->populate(); |
|
| 98 | + return $this->addressBookPlugins; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Returns an array of app-registered calendar plugins |
|
| 103 | + * |
|
| 104 | + * @return ICalendarProvider[] |
|
| 105 | + */ |
|
| 106 | + public function getCalendarPlugins():array { |
|
| 107 | + $this->populate(); |
|
| 108 | + return $this->calendarPlugins; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Retrieve plugin and collection list and populate attributes |
|
| 113 | + */ |
|
| 114 | + private function populate(): void { |
|
| 115 | + if ($this->populated) { |
|
| 116 | + return; |
|
| 117 | + } |
|
| 118 | + $this->populated = true; |
|
| 119 | + |
|
| 120 | + $this->calendarPlugins[] = $this->container->get(AppCalendarPlugin::class); |
|
| 121 | + |
|
| 122 | + foreach ($this->appManager->getEnabledApps() as $app) { |
|
| 123 | + // load plugins and collections from info.xml |
|
| 124 | + $info = $this->appManager->getAppInfo($app); |
|
| 125 | + if (!isset($info['types']) || !in_array('dav', $info['types'], true)) { |
|
| 126 | + continue; |
|
| 127 | + } |
|
| 128 | + $plugins = $this->loadSabrePluginsFromInfoXml($this->extractPluginList($info)); |
|
| 129 | + foreach ($plugins as $plugin) { |
|
| 130 | + $this->plugins[] = $plugin; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + $collections = $this->loadSabreCollectionsFromInfoXml($this->extractCollectionList($info)); |
|
| 134 | + foreach ($collections as $collection) { |
|
| 135 | + $this->collections[] = $collection; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $addresbookPlugins = $this->loadSabreAddressBookPluginsFromInfoXml($this->extractAddressBookPluginList($info)); |
|
| 139 | + foreach ($addresbookPlugins as $addresbookPlugin) { |
|
| 140 | + $this->addressBookPlugins[] = $addresbookPlugin; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + $calendarPlugins = $this->loadSabreCalendarPluginsFromInfoXml($this->extractCalendarPluginList($info)); |
|
| 144 | + foreach ($calendarPlugins as $calendarPlugin) { |
|
| 145 | + $this->calendarPlugins[] = $calendarPlugin; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @param array $array |
|
| 152 | + * @return string[] |
|
| 153 | + */ |
|
| 154 | + private function extractPluginList(array $array): array { |
|
| 155 | + if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 156 | + if (isset($array['sabre']['plugins']) && is_array($array['sabre']['plugins'])) { |
|
| 157 | + if (isset($array['sabre']['plugins']['plugin'])) { |
|
| 158 | + $items = $array['sabre']['plugins']['plugin']; |
|
| 159 | + if (!is_array($items)) { |
|
| 160 | + $items = [$items]; |
|
| 161 | + } |
|
| 162 | + return $items; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + return []; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * @param array $array |
|
| 171 | + * @return string[] |
|
| 172 | + */ |
|
| 173 | + private function extractCollectionList(array $array): array { |
|
| 174 | + if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 175 | + if (isset($array['sabre']['collections']) && is_array($array['sabre']['collections'])) { |
|
| 176 | + if (isset($array['sabre']['collections']['collection'])) { |
|
| 177 | + $items = $array['sabre']['collections']['collection']; |
|
| 178 | + if (!is_array($items)) { |
|
| 179 | + $items = [$items]; |
|
| 180 | + } |
|
| 181 | + return $items; |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + return []; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * @param array $array |
|
| 190 | + * @return string[] |
|
| 191 | + */ |
|
| 192 | + private function extractAddressBookPluginList(array $array): array { |
|
| 193 | + if (!isset($array['sabre']) || !is_array($array['sabre'])) { |
|
| 194 | + return []; |
|
| 195 | + } |
|
| 196 | + if (!isset($array['sabre']['address-book-plugins']) || !is_array($array['sabre']['address-book-plugins'])) { |
|
| 197 | + return []; |
|
| 198 | + } |
|
| 199 | + if (!isset($array['sabre']['address-book-plugins']['plugin'])) { |
|
| 200 | + return []; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + $items = $array['sabre']['address-book-plugins']['plugin']; |
|
| 204 | + if (!is_array($items)) { |
|
| 205 | + $items = [$items]; |
|
| 206 | + } |
|
| 207 | + return $items; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * @param array $array |
|
| 212 | + * @return string[] |
|
| 213 | + */ |
|
| 214 | + private function extractCalendarPluginList(array $array): array { |
|
| 215 | + if (isset($array['sabre']) && is_array($array['sabre'])) { |
|
| 216 | + if (isset($array['sabre']['calendar-plugins']) && is_array($array['sabre']['calendar-plugins'])) { |
|
| 217 | + if (isset($array['sabre']['calendar-plugins']['plugin'])) { |
|
| 218 | + $items = $array['sabre']['calendar-plugins']['plugin']; |
|
| 219 | + if (!is_array($items)) { |
|
| 220 | + $items = [$items]; |
|
| 221 | + } |
|
| 222 | + return $items; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + return []; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + private function createClass(string $className): object { |
|
| 230 | + try { |
|
| 231 | + return $this->container->get($className); |
|
| 232 | + } catch (QueryException $e) { |
|
| 233 | + if (class_exists($className)) { |
|
| 234 | + return new $className(); |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + throw new \Exception('Could not load ' . $className, 0, $e); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * @param string[] $classes |
|
| 244 | + * @return ServerPlugin[] |
|
| 245 | + * @throws \Exception |
|
| 246 | + */ |
|
| 247 | + private function loadSabrePluginsFromInfoXml(array $classes): array { |
|
| 248 | + return array_map(function (string $className): ServerPlugin { |
|
| 249 | + $instance = $this->createClass($className); |
|
| 250 | + if (!($instance instanceof ServerPlugin)) { |
|
| 251 | + throw new \Exception('Sabre server plugin ' . $className . ' does not implement the ' . ServerPlugin::class . ' interface'); |
|
| 252 | + } |
|
| 253 | + return $instance; |
|
| 254 | + }, $classes); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * @param string[] $classes |
|
| 259 | + * @return Collection[] |
|
| 260 | + */ |
|
| 261 | + private function loadSabreCollectionsFromInfoXml(array $classes): array { |
|
| 262 | + return array_map(function (string $className): Collection { |
|
| 263 | + $instance = $this->createClass($className); |
|
| 264 | + if (!($instance instanceof Collection)) { |
|
| 265 | + throw new \Exception('Sabre collection plugin ' . $className . ' does not implement the ' . Collection::class . ' interface'); |
|
| 266 | + } |
|
| 267 | + return $instance; |
|
| 268 | + }, $classes); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * @param string[] $classes |
|
| 273 | + * @return IAddressBookProvider[] |
|
| 274 | + */ |
|
| 275 | + private function loadSabreAddressBookPluginsFromInfoXml(array $classes): array { |
|
| 276 | + return array_map(function (string $className): IAddressBookProvider { |
|
| 277 | + $instance = $this->createClass($className); |
|
| 278 | + if (!($instance instanceof IAddressBookProvider)) { |
|
| 279 | + throw new \Exception('Sabre address book plugin class ' . $className . ' does not implement the ' . IAddressBookProvider::class . ' interface'); |
|
| 280 | + } |
|
| 281 | + return $instance; |
|
| 282 | + }, $classes); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * @param string[] $classes |
|
| 287 | + * @return ICalendarProvider[] |
|
| 288 | + */ |
|
| 289 | + private function loadSabreCalendarPluginsFromInfoXml(array $classes): array { |
|
| 290 | + return array_map(function (string $className): ICalendarProvider { |
|
| 291 | + $instance = $this->createClass($className); |
|
| 292 | + if (!($instance instanceof ICalendarProvider)) { |
|
| 293 | + throw new \Exception('Sabre calendar plugin class ' . $className . ' does not implement the ' . ICalendarProvider::class . ' interface'); |
|
| 294 | + } |
|
| 295 | + return $instance; |
|
| 296 | + }, $classes); |
|
| 297 | + } |
|
| 298 | 298 | } |
@@ -35,61 +35,61 @@ |
||
| 35 | 35 | * @since 22.0.0 |
| 36 | 36 | */ |
| 37 | 37 | class AbstractCacheEvent extends Event implements ICacheEvent { |
| 38 | - protected $storage; |
|
| 39 | - protected $path; |
|
| 40 | - protected $fileId; |
|
| 41 | - protected $storageId; |
|
| 38 | + protected $storage; |
|
| 39 | + protected $path; |
|
| 40 | + protected $fileId; |
|
| 41 | + protected $storageId; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param IStorage $storage |
|
| 45 | - * @param string $path |
|
| 46 | - * @param int $fileId |
|
| 47 | - * @since 22.0.0 |
|
| 48 | - */ |
|
| 49 | - public function __construct(IStorage $storage, string $path, int $fileId, int $storageId) { |
|
| 50 | - $this->storage = $storage; |
|
| 51 | - $this->path = $path; |
|
| 52 | - $this->fileId = $fileId; |
|
| 53 | - $this->storageId = $storageId; |
|
| 54 | - } |
|
| 43 | + /** |
|
| 44 | + * @param IStorage $storage |
|
| 45 | + * @param string $path |
|
| 46 | + * @param int $fileId |
|
| 47 | + * @since 22.0.0 |
|
| 48 | + */ |
|
| 49 | + public function __construct(IStorage $storage, string $path, int $fileId, int $storageId) { |
|
| 50 | + $this->storage = $storage; |
|
| 51 | + $this->path = $path; |
|
| 52 | + $this->fileId = $fileId; |
|
| 53 | + $this->storageId = $storageId; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @return IStorage |
|
| 58 | - * @since 22.0.0 |
|
| 59 | - */ |
|
| 60 | - public function getStorage(): IStorage { |
|
| 61 | - return $this->storage; |
|
| 62 | - } |
|
| 56 | + /** |
|
| 57 | + * @return IStorage |
|
| 58 | + * @since 22.0.0 |
|
| 59 | + */ |
|
| 60 | + public function getStorage(): IStorage { |
|
| 61 | + return $this->storage; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @return string |
|
| 66 | - * @since 22.0.0 |
|
| 67 | - */ |
|
| 68 | - public function getPath(): string { |
|
| 69 | - return $this->path; |
|
| 70 | - } |
|
| 64 | + /** |
|
| 65 | + * @return string |
|
| 66 | + * @since 22.0.0 |
|
| 67 | + */ |
|
| 68 | + public function getPath(): string { |
|
| 69 | + return $this->path; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @param string $path |
|
| 74 | - * @since 22.0.0 |
|
| 75 | - */ |
|
| 76 | - public function setPath(string $path): void { |
|
| 77 | - $this->path = $path; |
|
| 78 | - } |
|
| 72 | + /** |
|
| 73 | + * @param string $path |
|
| 74 | + * @since 22.0.0 |
|
| 75 | + */ |
|
| 76 | + public function setPath(string $path): void { |
|
| 77 | + $this->path = $path; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @return int |
|
| 82 | - * @since 22.0.0 |
|
| 83 | - */ |
|
| 84 | - public function getFileId(): int { |
|
| 85 | - return $this->fileId; |
|
| 86 | - } |
|
| 80 | + /** |
|
| 81 | + * @return int |
|
| 82 | + * @since 22.0.0 |
|
| 83 | + */ |
|
| 84 | + public function getFileId(): int { |
|
| 85 | + return $this->fileId; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @return int |
|
| 90 | - * @since 22.0.0 |
|
| 91 | - */ |
|
| 92 | - public function getStorageId(): int { |
|
| 93 | - return $this->storageId; |
|
| 94 | - } |
|
| 88 | + /** |
|
| 89 | + * @return int |
|
| 90 | + * @since 22.0.0 |
|
| 91 | + */ |
|
| 92 | + public function getStorageId(): int { |
|
| 93 | + return $this->storageId; |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -38,41 +38,41 @@ |
||
| 38 | 38 | * Auto-generated migration step: Please modify to your needs! |
| 39 | 39 | */ |
| 40 | 40 | class Version1011Date20190806104428 extends SimpleMigrationStep { |
| 41 | - /** |
|
| 42 | - * @param IOutput $output |
|
| 43 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 44 | - * @param array $options |
|
| 45 | - * @return null|ISchemaWrapper |
|
| 46 | - */ |
|
| 47 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 48 | - /** @var ISchemaWrapper $schema */ |
|
| 49 | - $schema = $schemaClosure(); |
|
| 41 | + /** |
|
| 42 | + * @param IOutput $output |
|
| 43 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 44 | + * @param array $options |
|
| 45 | + * @return null|ISchemaWrapper |
|
| 46 | + */ |
|
| 47 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 48 | + /** @var ISchemaWrapper $schema */ |
|
| 49 | + $schema = $schemaClosure(); |
|
| 50 | 50 | |
| 51 | - $table = $schema->createTable('dav_cal_proxy'); |
|
| 52 | - $table->addColumn('id', Types::BIGINT, [ |
|
| 53 | - 'autoincrement' => true, |
|
| 54 | - 'notnull' => true, |
|
| 55 | - 'length' => 11, |
|
| 56 | - 'unsigned' => true, |
|
| 57 | - ]); |
|
| 58 | - $table->addColumn('owner_id', Types::STRING, [ |
|
| 59 | - 'notnull' => true, |
|
| 60 | - 'length' => 64, |
|
| 61 | - ]); |
|
| 62 | - $table->addColumn('proxy_id', Types::STRING, [ |
|
| 63 | - 'notnull' => true, |
|
| 64 | - 'length' => 64, |
|
| 65 | - ]); |
|
| 66 | - $table->addColumn('permissions', Types::INTEGER, [ |
|
| 67 | - 'notnull' => false, |
|
| 68 | - 'length' => 4, |
|
| 69 | - 'unsigned' => true, |
|
| 70 | - ]); |
|
| 51 | + $table = $schema->createTable('dav_cal_proxy'); |
|
| 52 | + $table->addColumn('id', Types::BIGINT, [ |
|
| 53 | + 'autoincrement' => true, |
|
| 54 | + 'notnull' => true, |
|
| 55 | + 'length' => 11, |
|
| 56 | + 'unsigned' => true, |
|
| 57 | + ]); |
|
| 58 | + $table->addColumn('owner_id', Types::STRING, [ |
|
| 59 | + 'notnull' => true, |
|
| 60 | + 'length' => 64, |
|
| 61 | + ]); |
|
| 62 | + $table->addColumn('proxy_id', Types::STRING, [ |
|
| 63 | + 'notnull' => true, |
|
| 64 | + 'length' => 64, |
|
| 65 | + ]); |
|
| 66 | + $table->addColumn('permissions', Types::INTEGER, [ |
|
| 67 | + 'notnull' => false, |
|
| 68 | + 'length' => 4, |
|
| 69 | + 'unsigned' => true, |
|
| 70 | + ]); |
|
| 71 | 71 | |
| 72 | - $table->setPrimaryKey(['id']); |
|
| 73 | - $table->addUniqueIndex(['owner_id', 'proxy_id', 'permissions'], 'dav_cal_proxy_uidx'); |
|
| 74 | - $table->addIndex(['proxy_id'], 'dav_cal_proxy_ipid'); |
|
| 72 | + $table->setPrimaryKey(['id']); |
|
| 73 | + $table->addUniqueIndex(['owner_id', 'proxy_id', 'permissions'], 'dav_cal_proxy_uidx'); |
|
| 74 | + $table->addIndex(['proxy_id'], 'dav_cal_proxy_ipid'); |
|
| 75 | 75 | |
| 76 | - return $schema; |
|
| 77 | - } |
|
| 76 | + return $schema; |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -35,21 +35,21 @@ |
||
| 35 | 35 | * Auto-generated migration step: Please modify to your needs! |
| 36 | 36 | */ |
| 37 | 37 | class Version1017Date20210216083742 extends SimpleMigrationStep { |
| 38 | - /** |
|
| 39 | - * @param IOutput $output |
|
| 40 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | - * @param array $options |
|
| 42 | - * @return null|ISchemaWrapper |
|
| 43 | - */ |
|
| 44 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 45 | - /** @var ISchemaWrapper $schema */ |
|
| 46 | - $schema = $schemaClosure(); |
|
| 38 | + /** |
|
| 39 | + * @param IOutput $output |
|
| 40 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | + * @param array $options |
|
| 42 | + * @return null|ISchemaWrapper |
|
| 43 | + */ |
|
| 44 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 45 | + /** @var ISchemaWrapper $schema */ |
|
| 46 | + $schema = $schemaClosure(); |
|
| 47 | 47 | |
| 48 | - $table = $schema->getTable('dav_cal_proxy'); |
|
| 49 | - if ($table->hasIndex('dav_cal_proxy_ioid')) { |
|
| 50 | - $table->dropIndex('dav_cal_proxy_ioid'); |
|
| 51 | - } |
|
| 48 | + $table = $schema->getTable('dav_cal_proxy'); |
|
| 49 | + if ($table->hasIndex('dav_cal_proxy_ioid')) { |
|
| 50 | + $table->dropIndex('dav_cal_proxy_ioid'); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - return $schema; |
|
| 54 | - } |
|
| 53 | + return $schema; |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -35,21 +35,21 @@ |
||
| 35 | 35 | * Auto-generated migration step: Please modify to your needs! |
| 36 | 36 | */ |
| 37 | 37 | class Version22000Date20210216084241 extends SimpleMigrationStep { |
| 38 | - /** |
|
| 39 | - * @param IOutput $output |
|
| 40 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | - * @param array $options |
|
| 42 | - * @return null|ISchemaWrapper |
|
| 43 | - */ |
|
| 44 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 45 | - /** @var ISchemaWrapper $schema */ |
|
| 46 | - $schema = $schemaClosure(); |
|
| 38 | + /** |
|
| 39 | + * @param IOutput $output |
|
| 40 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | + * @param array $options |
|
| 42 | + * @return null|ISchemaWrapper |
|
| 43 | + */ |
|
| 44 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 45 | + /** @var ISchemaWrapper $schema */ |
|
| 46 | + $schema = $schemaClosure(); |
|
| 47 | 47 | |
| 48 | - $table = $schema->getTable('share_external'); |
|
| 49 | - if ($table->hasIndex('sh_external_user')) { |
|
| 50 | - $table->dropIndex('sh_external_user'); |
|
| 51 | - } |
|
| 48 | + $table = $schema->getTable('share_external'); |
|
| 49 | + if ($table->hasIndex('sh_external_user')) { |
|
| 50 | + $table->dropIndex('sh_external_user'); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - return $schema; |
|
| 54 | - } |
|
| 53 | + return $schema; |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | if ($this->enabled && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) { |
| 62 | 62 | [$remoteGroup, $serverUrl] = $this->splitGroupRemote($search); |
| 63 | 63 | $result['exact'][] = [ |
| 64 | - 'label' => $remoteGroup . " ($serverUrl)", |
|
| 64 | + 'label' => $remoteGroup." ($serverUrl)", |
|
| 65 | 65 | 'guid' => $remoteGroup, |
| 66 | 66 | 'name' => $remoteGroup, |
| 67 | 67 | 'value' => [ |
@@ -14,59 +14,59 @@ |
||
| 14 | 14 | use OCP\Share\IShare; |
| 15 | 15 | |
| 16 | 16 | class RemoteGroupPlugin implements ISearchPlugin { |
| 17 | - private bool $enabled = false; |
|
| 17 | + private bool $enabled = false; |
|
| 18 | 18 | |
| 19 | - public function __construct( |
|
| 20 | - ICloudFederationProviderManager $cloudFederationProviderManager, |
|
| 21 | - private ICloudIdManager $cloudIdManager, |
|
| 22 | - ) { |
|
| 23 | - try { |
|
| 24 | - $fileSharingProvider = $cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 25 | - $supportedShareTypes = $fileSharingProvider->getSupportedShareTypes(); |
|
| 26 | - if (in_array('group', $supportedShareTypes)) { |
|
| 27 | - $this->enabled = true; |
|
| 28 | - } |
|
| 29 | - } catch (\Exception $e) { |
|
| 30 | - // do nothing, just don't enable federated group shares |
|
| 31 | - } |
|
| 32 | - } |
|
| 19 | + public function __construct( |
|
| 20 | + ICloudFederationProviderManager $cloudFederationProviderManager, |
|
| 21 | + private ICloudIdManager $cloudIdManager, |
|
| 22 | + ) { |
|
| 23 | + try { |
|
| 24 | + $fileSharingProvider = $cloudFederationProviderManager->getCloudFederationProvider('file'); |
|
| 25 | + $supportedShareTypes = $fileSharingProvider->getSupportedShareTypes(); |
|
| 26 | + if (in_array('group', $supportedShareTypes)) { |
|
| 27 | + $this->enabled = true; |
|
| 28 | + } |
|
| 29 | + } catch (\Exception $e) { |
|
| 30 | + // do nothing, just don't enable federated group shares |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - public function search($search, $limit, $offset, ISearchResult $searchResult): bool { |
|
| 35 | - $result = ['wide' => [], 'exact' => []]; |
|
| 36 | - $resultType = new SearchResultType('remote_groups'); |
|
| 34 | + public function search($search, $limit, $offset, ISearchResult $searchResult): bool { |
|
| 35 | + $result = ['wide' => [], 'exact' => []]; |
|
| 36 | + $resultType = new SearchResultType('remote_groups'); |
|
| 37 | 37 | |
| 38 | - if ($this->enabled && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) { |
|
| 39 | - [$remoteGroup, $serverUrl] = $this->splitGroupRemote($search); |
|
| 40 | - $result['exact'][] = [ |
|
| 41 | - 'label' => $remoteGroup . " ($serverUrl)", |
|
| 42 | - 'guid' => $remoteGroup, |
|
| 43 | - 'name' => $remoteGroup, |
|
| 44 | - 'value' => [ |
|
| 45 | - 'shareType' => IShare::TYPE_REMOTE_GROUP, |
|
| 46 | - 'shareWith' => $search, |
|
| 47 | - 'server' => $serverUrl, |
|
| 48 | - ], |
|
| 49 | - ]; |
|
| 50 | - } |
|
| 38 | + if ($this->enabled && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) { |
|
| 39 | + [$remoteGroup, $serverUrl] = $this->splitGroupRemote($search); |
|
| 40 | + $result['exact'][] = [ |
|
| 41 | + 'label' => $remoteGroup . " ($serverUrl)", |
|
| 42 | + 'guid' => $remoteGroup, |
|
| 43 | + 'name' => $remoteGroup, |
|
| 44 | + 'value' => [ |
|
| 45 | + 'shareType' => IShare::TYPE_REMOTE_GROUP, |
|
| 46 | + 'shareWith' => $search, |
|
| 47 | + 'server' => $serverUrl, |
|
| 48 | + ], |
|
| 49 | + ]; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $searchResult->addResultSet($resultType, $result['wide'], $result['exact']); |
|
| 52 | + $searchResult->addResultSet($resultType, $result['wide'], $result['exact']); |
|
| 53 | 53 | |
| 54 | - return true; |
|
| 55 | - } |
|
| 54 | + return true; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * split group and remote from federated cloud id |
|
| 59 | - * |
|
| 60 | - * @param string $address federated share address |
|
| 61 | - * @return array [user, remoteURL] |
|
| 62 | - * @throws \InvalidArgumentException |
|
| 63 | - */ |
|
| 64 | - public function splitGroupRemote($address): array { |
|
| 65 | - try { |
|
| 66 | - $cloudId = $this->cloudIdManager->resolveCloudId($address); |
|
| 67 | - return [$cloudId->getUser(), $cloudId->getRemote()]; |
|
| 68 | - } catch (\InvalidArgumentException $e) { |
|
| 69 | - throw new \InvalidArgumentException('Invalid Federated Cloud ID', 0, $e); |
|
| 70 | - } |
|
| 71 | - } |
|
| 57 | + /** |
|
| 58 | + * split group and remote from federated cloud id |
|
| 59 | + * |
|
| 60 | + * @param string $address federated share address |
|
| 61 | + * @return array [user, remoteURL] |
|
| 62 | + * @throws \InvalidArgumentException |
|
| 63 | + */ |
|
| 64 | + public function splitGroupRemote($address): array { |
|
| 65 | + try { |
|
| 66 | + $cloudId = $this->cloudIdManager->resolveCloudId($address); |
|
| 67 | + return [$cloudId->getUser(), $cloudId->getRemote()]; |
|
| 68 | + } catch (\InvalidArgumentException $e) { |
|
| 69 | + throw new \InvalidArgumentException('Invalid Federated Cloud ID', 0, $e); |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -31,46 +31,46 @@ |
||
| 31 | 31 | use Sabre\DAV\Server; |
| 32 | 32 | |
| 33 | 33 | class Plugin extends \Sabre\CardDAV\Plugin { |
| 34 | - public function initialize(Server $server) { |
|
| 35 | - $server->on('propFind', [$this, 'propFind']); |
|
| 36 | - parent::initialize($server); |
|
| 37 | - } |
|
| 34 | + public function initialize(Server $server) { |
|
| 35 | + $server->on('propFind', [$this, 'propFind']); |
|
| 36 | + parent::initialize($server); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Returns the addressbook home for a given principal |
|
| 41 | - * |
|
| 42 | - * @param string $principal |
|
| 43 | - * @return string|null |
|
| 44 | - */ |
|
| 45 | - protected function getAddressbookHomeForPrincipal($principal) { |
|
| 46 | - if (strrpos($principal, 'principals/users', -strlen($principal)) !== false) { |
|
| 47 | - [, $principalId] = \Sabre\Uri\split($principal); |
|
| 48 | - return self::ADDRESSBOOK_ROOT . '/users/' . $principalId; |
|
| 49 | - } |
|
| 50 | - if (strrpos($principal, 'principals/groups', -strlen($principal)) !== false) { |
|
| 51 | - [, $principalId] = \Sabre\Uri\split($principal); |
|
| 52 | - return self::ADDRESSBOOK_ROOT . '/groups/' . $principalId; |
|
| 53 | - } |
|
| 54 | - if (strrpos($principal, 'principals/system', -strlen($principal)) !== false) { |
|
| 55 | - [, $principalId] = \Sabre\Uri\split($principal); |
|
| 56 | - return self::ADDRESSBOOK_ROOT . '/system/' . $principalId; |
|
| 57 | - } |
|
| 58 | - } |
|
| 39 | + /** |
|
| 40 | + * Returns the addressbook home for a given principal |
|
| 41 | + * |
|
| 42 | + * @param string $principal |
|
| 43 | + * @return string|null |
|
| 44 | + */ |
|
| 45 | + protected function getAddressbookHomeForPrincipal($principal) { |
|
| 46 | + if (strrpos($principal, 'principals/users', -strlen($principal)) !== false) { |
|
| 47 | + [, $principalId] = \Sabre\Uri\split($principal); |
|
| 48 | + return self::ADDRESSBOOK_ROOT . '/users/' . $principalId; |
|
| 49 | + } |
|
| 50 | + if (strrpos($principal, 'principals/groups', -strlen($principal)) !== false) { |
|
| 51 | + [, $principalId] = \Sabre\Uri\split($principal); |
|
| 52 | + return self::ADDRESSBOOK_ROOT . '/groups/' . $principalId; |
|
| 53 | + } |
|
| 54 | + if (strrpos($principal, 'principals/system', -strlen($principal)) !== false) { |
|
| 55 | + [, $principalId] = \Sabre\Uri\split($principal); |
|
| 56 | + return self::ADDRESSBOOK_ROOT . '/system/' . $principalId; |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Adds all CardDAV-specific properties |
|
| 62 | - * |
|
| 63 | - * @param PropFind $propFind |
|
| 64 | - * @param INode $node |
|
| 65 | - * @return void |
|
| 66 | - */ |
|
| 67 | - public function propFind(PropFind $propFind, INode $node) { |
|
| 68 | - $ns = '{http://owncloud.org/ns}'; |
|
| 60 | + /** |
|
| 61 | + * Adds all CardDAV-specific properties |
|
| 62 | + * |
|
| 63 | + * @param PropFind $propFind |
|
| 64 | + * @param INode $node |
|
| 65 | + * @return void |
|
| 66 | + */ |
|
| 67 | + public function propFind(PropFind $propFind, INode $node) { |
|
| 68 | + $ns = '{http://owncloud.org/ns}'; |
|
| 69 | 69 | |
| 70 | - if ($node instanceof AddressBook) { |
|
| 71 | - $propFind->handle($ns . 'groups', function () use ($node) { |
|
| 72 | - return new Groups($node->getContactsGroups()); |
|
| 73 | - }); |
|
| 74 | - } |
|
| 75 | - } |
|
| 70 | + if ($node instanceof AddressBook) { |
|
| 71 | + $propFind->handle($ns . 'groups', function () use ($node) { |
|
| 72 | + return new Groups($node->getContactsGroups()); |
|
| 73 | + }); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -45,15 +45,15 @@ discard block |
||
| 45 | 45 | protected function getAddressbookHomeForPrincipal($principal) { |
| 46 | 46 | if (strrpos($principal, 'principals/users', -strlen($principal)) !== false) { |
| 47 | 47 | [, $principalId] = \Sabre\Uri\split($principal); |
| 48 | - return self::ADDRESSBOOK_ROOT . '/users/' . $principalId; |
|
| 48 | + return self::ADDRESSBOOK_ROOT.'/users/'.$principalId; |
|
| 49 | 49 | } |
| 50 | 50 | if (strrpos($principal, 'principals/groups', -strlen($principal)) !== false) { |
| 51 | 51 | [, $principalId] = \Sabre\Uri\split($principal); |
| 52 | - return self::ADDRESSBOOK_ROOT . '/groups/' . $principalId; |
|
| 52 | + return self::ADDRESSBOOK_ROOT.'/groups/'.$principalId; |
|
| 53 | 53 | } |
| 54 | 54 | if (strrpos($principal, 'principals/system', -strlen($principal)) !== false) { |
| 55 | 55 | [, $principalId] = \Sabre\Uri\split($principal); |
| 56 | - return self::ADDRESSBOOK_ROOT . '/system/' . $principalId; |
|
| 56 | + return self::ADDRESSBOOK_ROOT.'/system/'.$principalId; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $ns = '{http://owncloud.org/ns}'; |
| 69 | 69 | |
| 70 | 70 | if ($node instanceof AddressBook) { |
| 71 | - $propFind->handle($ns . 'groups', function () use ($node) { |
|
| 71 | + $propFind->handle($ns.'groups', function() use ($node) { |
|
| 72 | 72 | return new Groups($node->getContactsGroups()); |
| 73 | 73 | }); |
| 74 | 74 | } |
@@ -36,190 +36,190 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | trait PrincipalProxyTrait { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Returns the list of members for a group-principal |
|
| 41 | - * |
|
| 42 | - * @param string $principal |
|
| 43 | - * @return string[] |
|
| 44 | - * @throws Exception |
|
| 45 | - */ |
|
| 46 | - public function getGroupMemberSet($principal) { |
|
| 47 | - $members = []; |
|
| 48 | - |
|
| 49 | - if ($this->isProxyPrincipal($principal)) { |
|
| 50 | - $realPrincipal = $this->getPrincipalUriFromProxyPrincipal($principal); |
|
| 51 | - $principalArray = $this->getPrincipalByPath($realPrincipal); |
|
| 52 | - if (!$principalArray) { |
|
| 53 | - throw new Exception('Principal not found'); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - $proxies = $this->proxyMapper->getProxiesOf($principalArray['uri']); |
|
| 57 | - foreach ($proxies as $proxy) { |
|
| 58 | - if ($this->isReadProxyPrincipal($principal) && $proxy->getPermissions() === ProxyMapper::PERMISSION_READ) { |
|
| 59 | - $members[] = $proxy->getProxyId(); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - if ($this->isWriteProxyPrincipal($principal) && $proxy->getPermissions() === (ProxyMapper::PERMISSION_READ | ProxyMapper::PERMISSION_WRITE)) { |
|
| 63 | - $members[] = $proxy->getProxyId(); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - return $members; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Returns the list of groups a principal is a member of |
|
| 73 | - * |
|
| 74 | - * @param string $principal |
|
| 75 | - * @param bool $needGroups |
|
| 76 | - * @return array |
|
| 77 | - * @throws Exception |
|
| 78 | - */ |
|
| 79 | - public function getGroupMembership($principal, $needGroups = false) { |
|
| 80 | - [$prefix, $name] = \Sabre\Uri\split($principal); |
|
| 81 | - |
|
| 82 | - if ($prefix !== $this->principalPrefix) { |
|
| 83 | - return []; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - $principalArray = $this->getPrincipalByPath($principal); |
|
| 87 | - if (!$principalArray) { |
|
| 88 | - throw new Exception('Principal not found'); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - $groups = []; |
|
| 92 | - $proxies = $this->proxyMapper->getProxiesFor($principal); |
|
| 93 | - foreach ($proxies as $proxy) { |
|
| 94 | - if ($proxy->getPermissions() === ProxyMapper::PERMISSION_READ) { |
|
| 95 | - $groups[] = $proxy->getOwnerId() . '/calendar-proxy-read'; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - if ($proxy->getPermissions() === (ProxyMapper::PERMISSION_READ | ProxyMapper::PERMISSION_WRITE)) { |
|
| 99 | - $groups[] = $proxy->getOwnerId() . '/calendar-proxy-write'; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - return $groups; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Updates the list of group members for a group principal. |
|
| 108 | - * |
|
| 109 | - * The principals should be passed as a list of uri's. |
|
| 110 | - * |
|
| 111 | - * @param string $principal |
|
| 112 | - * @param string[] $members |
|
| 113 | - * @throws Exception |
|
| 114 | - */ |
|
| 115 | - public function setGroupMemberSet($principal, array $members) { |
|
| 116 | - [$principalUri, $target] = \Sabre\Uri\split($principal); |
|
| 117 | - |
|
| 118 | - if ($target !== 'calendar-proxy-write' && $target !== 'calendar-proxy-read') { |
|
| 119 | - throw new Exception('Setting members of the group is not supported yet'); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - $masterPrincipalArray = $this->getPrincipalByPath($principalUri); |
|
| 123 | - if (!$masterPrincipalArray) { |
|
| 124 | - throw new Exception('Principal not found'); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $permission = ProxyMapper::PERMISSION_READ; |
|
| 128 | - if ($target === 'calendar-proxy-write') { |
|
| 129 | - $permission |= ProxyMapper::PERMISSION_WRITE; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - [$prefix, $owner] = \Sabre\Uri\split($principalUri); |
|
| 133 | - $proxies = $this->proxyMapper->getProxiesOf($principalUri); |
|
| 134 | - |
|
| 135 | - foreach ($members as $member) { |
|
| 136 | - [$prefix, $name] = \Sabre\Uri\split($member); |
|
| 137 | - |
|
| 138 | - if ($prefix !== $this->principalPrefix) { |
|
| 139 | - throw new Exception('Invalid member group prefix: ' . $prefix); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $principalArray = $this->getPrincipalByPath($member); |
|
| 143 | - if (!$principalArray) { |
|
| 144 | - throw new Exception('Principal not found'); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - $found = false; |
|
| 148 | - foreach ($proxies as $proxy) { |
|
| 149 | - if ($proxy->getProxyId() === $member) { |
|
| 150 | - $found = true; |
|
| 151 | - $proxy->setPermissions($proxy->getPermissions() | $permission); |
|
| 152 | - $this->proxyMapper->update($proxy); |
|
| 153 | - |
|
| 154 | - $proxies = array_filter($proxies, function (Proxy $p) use ($proxy) { |
|
| 155 | - return $p->getId() !== $proxy->getId(); |
|
| 156 | - }); |
|
| 157 | - break; |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - if ($found === false) { |
|
| 162 | - $proxy = new Proxy(); |
|
| 163 | - $proxy->setOwnerId($principalUri); |
|
| 164 | - $proxy->setProxyId($member); |
|
| 165 | - $proxy->setPermissions($permission); |
|
| 166 | - $this->proxyMapper->insert($proxy); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - // Delete all remaining proxies |
|
| 171 | - foreach ($proxies as $proxy) { |
|
| 172 | - // Write and Read Proxies have individual requests, |
|
| 173 | - // so only delete proxies of this permission |
|
| 174 | - if ($proxy->getPermissions() === $permission) { |
|
| 175 | - $this->proxyMapper->delete($proxy); |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * @param string $principalUri |
|
| 182 | - * @return bool |
|
| 183 | - */ |
|
| 184 | - private function isProxyPrincipal(string $principalUri):bool { |
|
| 185 | - [$realPrincipalUri, $proxy] = \Sabre\Uri\split($principalUri); |
|
| 186 | - [$prefix, $userId] = \Sabre\Uri\split($realPrincipalUri); |
|
| 187 | - |
|
| 188 | - if (!isset($prefix) || !isset($userId)) { |
|
| 189 | - return false; |
|
| 190 | - } |
|
| 191 | - if ($prefix !== $this->principalPrefix) { |
|
| 192 | - return false; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - return $proxy === 'calendar-proxy-read' |
|
| 196 | - || $proxy === 'calendar-proxy-write'; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * @param string $principalUri |
|
| 201 | - * @return bool |
|
| 202 | - */ |
|
| 203 | - private function isReadProxyPrincipal(string $principalUri):bool { |
|
| 204 | - [, $proxy] = \Sabre\Uri\split($principalUri); |
|
| 205 | - return $proxy === 'calendar-proxy-read'; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * @param string $principalUri |
|
| 210 | - * @return bool |
|
| 211 | - */ |
|
| 212 | - private function isWriteProxyPrincipal(string $principalUri):bool { |
|
| 213 | - [, $proxy] = \Sabre\Uri\split($principalUri); |
|
| 214 | - return $proxy === 'calendar-proxy-write'; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * @param string $principalUri |
|
| 219 | - * @return string |
|
| 220 | - */ |
|
| 221 | - private function getPrincipalUriFromProxyPrincipal(string $principalUri):string { |
|
| 222 | - [$realPrincipalUri, ] = \Sabre\Uri\split($principalUri); |
|
| 223 | - return $realPrincipalUri; |
|
| 224 | - } |
|
| 39 | + /** |
|
| 40 | + * Returns the list of members for a group-principal |
|
| 41 | + * |
|
| 42 | + * @param string $principal |
|
| 43 | + * @return string[] |
|
| 44 | + * @throws Exception |
|
| 45 | + */ |
|
| 46 | + public function getGroupMemberSet($principal) { |
|
| 47 | + $members = []; |
|
| 48 | + |
|
| 49 | + if ($this->isProxyPrincipal($principal)) { |
|
| 50 | + $realPrincipal = $this->getPrincipalUriFromProxyPrincipal($principal); |
|
| 51 | + $principalArray = $this->getPrincipalByPath($realPrincipal); |
|
| 52 | + if (!$principalArray) { |
|
| 53 | + throw new Exception('Principal not found'); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + $proxies = $this->proxyMapper->getProxiesOf($principalArray['uri']); |
|
| 57 | + foreach ($proxies as $proxy) { |
|
| 58 | + if ($this->isReadProxyPrincipal($principal) && $proxy->getPermissions() === ProxyMapper::PERMISSION_READ) { |
|
| 59 | + $members[] = $proxy->getProxyId(); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + if ($this->isWriteProxyPrincipal($principal) && $proxy->getPermissions() === (ProxyMapper::PERMISSION_READ | ProxyMapper::PERMISSION_WRITE)) { |
|
| 63 | + $members[] = $proxy->getProxyId(); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + return $members; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Returns the list of groups a principal is a member of |
|
| 73 | + * |
|
| 74 | + * @param string $principal |
|
| 75 | + * @param bool $needGroups |
|
| 76 | + * @return array |
|
| 77 | + * @throws Exception |
|
| 78 | + */ |
|
| 79 | + public function getGroupMembership($principal, $needGroups = false) { |
|
| 80 | + [$prefix, $name] = \Sabre\Uri\split($principal); |
|
| 81 | + |
|
| 82 | + if ($prefix !== $this->principalPrefix) { |
|
| 83 | + return []; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + $principalArray = $this->getPrincipalByPath($principal); |
|
| 87 | + if (!$principalArray) { |
|
| 88 | + throw new Exception('Principal not found'); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + $groups = []; |
|
| 92 | + $proxies = $this->proxyMapper->getProxiesFor($principal); |
|
| 93 | + foreach ($proxies as $proxy) { |
|
| 94 | + if ($proxy->getPermissions() === ProxyMapper::PERMISSION_READ) { |
|
| 95 | + $groups[] = $proxy->getOwnerId() . '/calendar-proxy-read'; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + if ($proxy->getPermissions() === (ProxyMapper::PERMISSION_READ | ProxyMapper::PERMISSION_WRITE)) { |
|
| 99 | + $groups[] = $proxy->getOwnerId() . '/calendar-proxy-write'; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + return $groups; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Updates the list of group members for a group principal. |
|
| 108 | + * |
|
| 109 | + * The principals should be passed as a list of uri's. |
|
| 110 | + * |
|
| 111 | + * @param string $principal |
|
| 112 | + * @param string[] $members |
|
| 113 | + * @throws Exception |
|
| 114 | + */ |
|
| 115 | + public function setGroupMemberSet($principal, array $members) { |
|
| 116 | + [$principalUri, $target] = \Sabre\Uri\split($principal); |
|
| 117 | + |
|
| 118 | + if ($target !== 'calendar-proxy-write' && $target !== 'calendar-proxy-read') { |
|
| 119 | + throw new Exception('Setting members of the group is not supported yet'); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + $masterPrincipalArray = $this->getPrincipalByPath($principalUri); |
|
| 123 | + if (!$masterPrincipalArray) { |
|
| 124 | + throw new Exception('Principal not found'); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $permission = ProxyMapper::PERMISSION_READ; |
|
| 128 | + if ($target === 'calendar-proxy-write') { |
|
| 129 | + $permission |= ProxyMapper::PERMISSION_WRITE; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + [$prefix, $owner] = \Sabre\Uri\split($principalUri); |
|
| 133 | + $proxies = $this->proxyMapper->getProxiesOf($principalUri); |
|
| 134 | + |
|
| 135 | + foreach ($members as $member) { |
|
| 136 | + [$prefix, $name] = \Sabre\Uri\split($member); |
|
| 137 | + |
|
| 138 | + if ($prefix !== $this->principalPrefix) { |
|
| 139 | + throw new Exception('Invalid member group prefix: ' . $prefix); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $principalArray = $this->getPrincipalByPath($member); |
|
| 143 | + if (!$principalArray) { |
|
| 144 | + throw new Exception('Principal not found'); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + $found = false; |
|
| 148 | + foreach ($proxies as $proxy) { |
|
| 149 | + if ($proxy->getProxyId() === $member) { |
|
| 150 | + $found = true; |
|
| 151 | + $proxy->setPermissions($proxy->getPermissions() | $permission); |
|
| 152 | + $this->proxyMapper->update($proxy); |
|
| 153 | + |
|
| 154 | + $proxies = array_filter($proxies, function (Proxy $p) use ($proxy) { |
|
| 155 | + return $p->getId() !== $proxy->getId(); |
|
| 156 | + }); |
|
| 157 | + break; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + if ($found === false) { |
|
| 162 | + $proxy = new Proxy(); |
|
| 163 | + $proxy->setOwnerId($principalUri); |
|
| 164 | + $proxy->setProxyId($member); |
|
| 165 | + $proxy->setPermissions($permission); |
|
| 166 | + $this->proxyMapper->insert($proxy); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + // Delete all remaining proxies |
|
| 171 | + foreach ($proxies as $proxy) { |
|
| 172 | + // Write and Read Proxies have individual requests, |
|
| 173 | + // so only delete proxies of this permission |
|
| 174 | + if ($proxy->getPermissions() === $permission) { |
|
| 175 | + $this->proxyMapper->delete($proxy); |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * @param string $principalUri |
|
| 182 | + * @return bool |
|
| 183 | + */ |
|
| 184 | + private function isProxyPrincipal(string $principalUri):bool { |
|
| 185 | + [$realPrincipalUri, $proxy] = \Sabre\Uri\split($principalUri); |
|
| 186 | + [$prefix, $userId] = \Sabre\Uri\split($realPrincipalUri); |
|
| 187 | + |
|
| 188 | + if (!isset($prefix) || !isset($userId)) { |
|
| 189 | + return false; |
|
| 190 | + } |
|
| 191 | + if ($prefix !== $this->principalPrefix) { |
|
| 192 | + return false; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + return $proxy === 'calendar-proxy-read' |
|
| 196 | + || $proxy === 'calendar-proxy-write'; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * @param string $principalUri |
|
| 201 | + * @return bool |
|
| 202 | + */ |
|
| 203 | + private function isReadProxyPrincipal(string $principalUri):bool { |
|
| 204 | + [, $proxy] = \Sabre\Uri\split($principalUri); |
|
| 205 | + return $proxy === 'calendar-proxy-read'; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * @param string $principalUri |
|
| 210 | + * @return bool |
|
| 211 | + */ |
|
| 212 | + private function isWriteProxyPrincipal(string $principalUri):bool { |
|
| 213 | + [, $proxy] = \Sabre\Uri\split($principalUri); |
|
| 214 | + return $proxy === 'calendar-proxy-write'; |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * @param string $principalUri |
|
| 219 | + * @return string |
|
| 220 | + */ |
|
| 221 | + private function getPrincipalUriFromProxyPrincipal(string $principalUri):string { |
|
| 222 | + [$realPrincipalUri, ] = \Sabre\Uri\split($principalUri); |
|
| 223 | + return $realPrincipalUri; |
|
| 224 | + } |
|
| 225 | 225 | } |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | $proxies = $this->proxyMapper->getProxiesFor($principal); |
| 93 | 93 | foreach ($proxies as $proxy) { |
| 94 | 94 | if ($proxy->getPermissions() === ProxyMapper::PERMISSION_READ) { |
| 95 | - $groups[] = $proxy->getOwnerId() . '/calendar-proxy-read'; |
|
| 95 | + $groups[] = $proxy->getOwnerId().'/calendar-proxy-read'; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | if ($proxy->getPermissions() === (ProxyMapper::PERMISSION_READ | ProxyMapper::PERMISSION_WRITE)) { |
| 99 | - $groups[] = $proxy->getOwnerId() . '/calendar-proxy-write'; |
|
| 99 | + $groups[] = $proxy->getOwnerId().'/calendar-proxy-write'; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | [$prefix, $name] = \Sabre\Uri\split($member); |
| 137 | 137 | |
| 138 | 138 | if ($prefix !== $this->principalPrefix) { |
| 139 | - throw new Exception('Invalid member group prefix: ' . $prefix); |
|
| 139 | + throw new Exception('Invalid member group prefix: '.$prefix); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $principalArray = $this->getPrincipalByPath($member); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $proxy->setPermissions($proxy->getPermissions() | $permission); |
| 152 | 152 | $this->proxyMapper->update($proxy); |
| 153 | 153 | |
| 154 | - $proxies = array_filter($proxies, function (Proxy $p) use ($proxy) { |
|
| 154 | + $proxies = array_filter($proxies, function(Proxy $p) use ($proxy) { |
|
| 155 | 155 | return $p->getId() !== $proxy->getId(); |
| 156 | 156 | }); |
| 157 | 157 | break; |