@@ -185,20 +185,31 @@ public function handlePost($userId, $path) {
185185 * @NoAdminRequired
186186 * @NoCSRFRequired
187187 */
188- public function handlePut () { // $userId, $path) {
189- // FIXME: Adding the correct variables in the function name will make nextcloud
190- // throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
191-
192- // because we got here, the request uri should look like:
193- // /index.php/apps/solid/@{userId}/storage{path}
194- $ pathInfo = explode ("@ " , $ _SERVER ['REQUEST_URI ' ]);
195- $ pathInfo = explode ("/ " , $ pathInfo [1 ], 2 );
196- $ userId = $ pathInfo [0 ];
197- $ path = $ pathInfo [1 ];
198- $ path = preg_replace ("/^calendar/ " , "" , $ path );
199-
200- return $ this ->handleRequest ($ userId , $ path );
201- }
188+ public function handlePut () { // $userId, $path) {
189+ // FIXME: Adding the correct variables in the function name will make nextcloud
190+ // throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
191+
192+ // because we got here, the request uri should look like:
193+ // - if we have user subdomains enabled:
194+ // /index.php/apps/solid/calendar{path}
195+ // and otherwise:
196+ // index.php/apps/solid/~{userId}/calendar{path}
197+
198+ // In the first case, we'll get the username from the SERVER_NAME. In the latter, it will come from the URL;
199+ if ($ this ->config ->getUserSubDomainsEnabled ()) {
200+ $ pathInfo = explode ("calendar/ " , $ _SERVER ['REQUEST_URI ' ]);
201+ $ path = $ pathInfo [1 ];
202+ $ userId = explode (". " , $ _SERVER ['SERVER_NAME ' ])[0 ];
203+ } else {
204+ $ pathInfo = explode ("~ " , $ _SERVER ['REQUEST_URI ' ]);
205+ $ pathInfo = explode ("/ " , $ pathInfo [1 ], 2 );
206+ $ userId = $ pathInfo [0 ];
207+ $ path = $ pathInfo [1 ];
208+ $ path = preg_replace ("/^calendar/ " , "" , $ path );
209+ }
210+
211+ return $ this ->handleRequest ($ userId , $ path );
212+ }
202213 /**
203214 * @PublicPage
204215 * @NoAdminRequired
0 commit comments