Skip to content

Commit 84f7ff2

Browse files
committed
Merge branch 'fix/handleput' into prep-release-0.10
2 parents d7e035a + 172abdf commit 84f7ff2

File tree

4 files changed

+100
-56
lines changed

4 files changed

+100
-56
lines changed

solid/lib/Controller/CalendarController.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

solid/lib/Controller/ContactsController.php

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

solid/lib/Controller/ProfileController.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -204,20 +204,31 @@ public function handlePost($userId, $path) {
204204
* @NoAdminRequired
205205
* @NoCSRFRequired
206206
*/
207-
public function handlePut() { // $userId, $path) {
208-
// FIXME: Adding the correct variables in the function name will make nextcloud
209-
// throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
210-
211-
// because we got here, the request uri should look like:
212-
// /index.php/apps/solid/@{userId}/storage{path}
213-
$pathInfo = explode("@", $_SERVER['REQUEST_URI']);
214-
$pathInfo = explode("/", $pathInfo[1], 2);
215-
$userId = $pathInfo[0];
216-
$path = $pathInfo[1];
217-
$path = preg_replace("/^profile/", "", $path);
218-
219-
return $this->handleRequest($userId, $path);
220-
}
207+
public function handlePut() { // $userId, $path) {
208+
// FIXME: Adding the correct variables in the function name will make nextcloud
209+
// throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
210+
211+
// because we got here, the request uri should look like:
212+
// - if we have user subdomains enabled:
213+
// /index.php/apps/solid/profile{path}
214+
// and otherwise:
215+
// index.php/apps/solid/~{userId}/profile{path}
216+
217+
// In the first case, we'll get the username from the SERVER_NAME. In the latter, it will come from the URL;
218+
if ($this->config->getUserSubDomainsEnabled()) {
219+
$pathInfo = explode("profile/", $_SERVER['REQUEST_URI']);
220+
$path = $pathInfo[1];
221+
$userId = explode(".", $_SERVER['SERVER_NAME'])[0];
222+
} else {
223+
$pathInfo = explode("~", $_SERVER['REQUEST_URI']);
224+
$pathInfo = explode("/", $pathInfo[1], 2);
225+
$userId = $pathInfo[0];
226+
$path = $pathInfo[1];
227+
$path = preg_replace("/^profile/", "", $path);
228+
}
229+
230+
return $this->handleRequest($userId, $path);
231+
}
221232
/**
222233
* @PublicPage
223234
* @NoAdminRequired

solid/lib/Controller/StorageController.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -375,20 +375,31 @@ public function handlePost($userId, $path) {
375375
* @NoAdminRequired
376376
* @NoCSRFRequired
377377
*/
378-
public function handlePut() { // $userId, $path) {
379-
// FIXME: Adding the correct variables in the function name will make nextcloud
380-
// throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
381-
382-
// because we got here, the request uri should look like:
383-
// /index.php/apps/solid/@{userId}/storage{path}
384-
$pathInfo = explode("@", $_SERVER['REQUEST_URI']);
385-
$pathInfo = explode("/", $pathInfo[1], 2);
386-
$userId = $pathInfo[0];
387-
$path = $pathInfo[1];
388-
$path = preg_replace("/^storage/", "", $path);
389-
390-
return $this->handleRequest($userId, $path);
391-
}
378+
public function handlePut() { // $userId, $path) {
379+
// FIXME: Adding the correct variables in the function name will make nextcloud
380+
// throw an error about accessing put twice, so we will find out the userId and path from $_SERVER instead;
381+
382+
// because we got here, the request uri should look like:
383+
// - if we have user subdomains enabled:
384+
// /index.php/apps/solid/storage{path}
385+
// and otherwise:
386+
// index.php/apps/solid/~{userId}/storage{path}
387+
388+
// In the first case, we'll get the username from the SERVER_NAME. In the latter, it will come from the URL;
389+
if ($this->config->getUserSubDomainsEnabled()) {
390+
$pathInfo = explode("storage/", $_SERVER['REQUEST_URI']);
391+
$path = $pathInfo[1];
392+
$userId = explode(".", $_SERVER['SERVER_NAME'])[0];
393+
} else {
394+
$pathInfo = explode("~", $_SERVER['REQUEST_URI']);
395+
$pathInfo = explode("/", $pathInfo[1], 2);
396+
$userId = $pathInfo[0];
397+
$path = $pathInfo[1];
398+
$path = preg_replace("/^storage/", "", $path);
399+
}
400+
401+
return $this->handleRequest($userId, $path);
402+
}
392403
/**
393404
* @PublicPage
394405
* @NoAdminRequired

0 commit comments

Comments
 (0)