X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2Flegacy%2FLegacyController.php;h=1fed418b7c16612e875b9be185e07dd730100f4c;hb=da950241f3381f6c40dbef2f3648179f5b658a07;hp=75fa9d2cfb962cf1009bea63da16ed0d41a74c93;hpb=9e2d47e519783a991962e1fe2c9f28d77756ae49;p=github%2Fshaarli%2FShaarli.git diff --git a/application/legacy/LegacyController.php b/application/legacy/LegacyController.php index 75fa9d2c..1fed418b 100644 --- a/application/legacy/LegacyController.php +++ b/application/legacy/LegacyController.php @@ -39,13 +39,23 @@ class LegacyController extends ShaarliVisitorController /** Legacy route: ?post= */ public function post(Request $request, Response $response): Response { - $parameters = count($request->getQueryParams()) > 0 ? '?' . http_build_query($request->getQueryParams()) : ''; $route = '/admin/shaare'; + $buildParameters = function (?array $parameters, bool $encode) { + if ($encode) { + $parameters = array_map('urlencode', $parameters); + } + + return count($parameters) > 0 ? '?' . http_build_query($parameters) : ''; + }; + if (!$this->container->loginManager->isLoggedIn()) { - return $this->redirect($response, '/login?returnurl='. $this->getBasePath() . $route . $parameters); + $parameters = $buildParameters($request->getQueryParams(), true); + return $this->redirect($response, '/login?returnurl=' . $this->getBasePath() . $route . $parameters); } + $parameters = $buildParameters($request->getQueryParams(), false); + return $this->redirect($response, $route . $parameters); } @@ -132,4 +142,21 @@ class LegacyController extends ShaarliVisitorController return $this->redirect($response, '/feed/' . $feedType . $parameters); } + + /** Legacy route: ?do=configure */ + protected function configure(Request $request, Response $response): Response + { + $route = '/admin/configure'; + + if (!$this->container->loginManager->isLoggedIn()) { + return $this->redirect($response, '/login?returnurl=' . $this->getBasePath() . $route); + } + + return $this->redirect($response, $route); + } + + protected function getBasePath(): string + { + return $this->container->basePath ?: ''; + } }