]> git.mxchange.org Git - friendica.git/commitdiff
separate parameter values for different functionalities
authorMichael <heluecht@pirati.ca>
Mon, 4 Oct 2021 18:04:41 +0000 (18:04 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 4 Oct 2021 18:04:41 +0000 (18:04 +0000)
src/Module/Photo.php
static/routes.config.php

index 39a8353b5d87f34bf0afb80d00ffbe0164ca9896..9ee737d3829db17036c481002e99f40913f12234 100644 (file)
@@ -82,24 +82,28 @@ class Photo extends BaseModule
                                $square_resize = !in_array($parameters['type'], ['media', 'preview']);
                        }
 
-                       if (!empty($parameters['nickname_ext'])) {
-                               if (in_array($parameters['type'], ['contact', 'header'])) {
-                                       $guid = pathinfo($parameters['nickname_ext'], PATHINFO_FILENAME);
-                                       $account = DBA::selectFirst('account-user-view', ['id'], ['guid' => $guid], ['order' => ['uid' => true]]);
-                                       if (empty($account)) {
-                                               throw new HTTPException\NotFoundException();
-                                       }
+                       if (!empty($parameters['guid'])) {
+                               $guid = pathinfo($parameters['guid'], PATHINFO_FILENAME);
+                               $account = DBA::selectFirst('account-user-view', ['id'], ['guid' => $guid], ['order' => ['uid' => true]]);
+                               if (empty($account)) {
+                                       throw new HTTPException\NotFoundException();
+                               }
 
-                                       $id = $account['id'];
-                               } else {
-                                       $nickname = pathinfo($parameters['nickname_ext'], PATHINFO_FILENAME);
-                                       $user = User::getByNickname($nickname, ['uid']);
-                                       if (empty($user)) {
-                                               throw new HTTPException\NotFoundException();
-                                       }
+                               $id = $account['id'];
+                       }
+
+                       if (!empty($parameters['contact_id'])) {
+                               $id = intval(pathinfo($parameters['contact_id'], PATHINFO_FILENAME));
+                       }
 
-                                       $id = $user['uid'];
+                       if (!empty($parameters['nickname_ext'])) {
+                               $nickname = pathinfo($parameters['nickname_ext'], PATHINFO_FILENAME);
+                               $user = User::getByNickname($nickname, ['uid']);
+                               if (empty($user)) {
+                                       throw new HTTPException\NotFoundException();
                                }
+
+                               $id = $user['uid'];
                        }
 
                        // User Id Fallback, to remove after version 2021.12
index 2f20d5177035b1406b64cd9f987051384bfc85f1..85bd4f9414188add3eeb453eceb1d08f7a9dd8e3 100644 (file)
@@ -373,15 +373,18 @@ return [
        '/permission/tooltip/{type}/{id:\d+}' => [Module\PermissionTooltip::class, [R::GET]],
 
        '/photo' => [
-               '/{name}'                                => [Module\Photo::class, [R::GET]],
-               '/{type}/{id:\d+}'                       => [Module\Photo::class, [R::GET]],
+               '/{name}'                                                  => [Module\Photo::class, [R::GET]],
+               '/{type}/{id:\d+}'                                         => [Module\Photo::class, [R::GET]],
                // User Id Fallback, to remove after version 2021.12
-               '/{type}/{uid_ext:\d+\..*}'              => [Module\Photo::class, [R::GET]],
-               '/{type}/{nickname_ext}'                 => [Module\Photo::class, [R::GET]],
-               '/{type}/{customsize}/{id:\d+}'          => [Module\Photo::class, [R::GET]],
+               '/{type}/{uid_ext:\d+\..*}'                                => [Module\Photo::class, [R::GET]],
+               '/{type}/{nickname_ext}'                                   => [Module\Photo::class, [R::GET]],
+               // Contact Id Fallback, to remove after version 2021.12
+               '/{type:contact|header}/{customsize:\d+}/{contact_id:\d+}' => [Module\Photo::class, [R::GET]],
+               '/{type:contact|header}/{customsize:\d+}/{guid}'           => [Module\Photo::class, [R::GET]],
+               '/{type}/{customsize:\d+}/{id:\d+}'                        => [Module\Photo::class, [R::GET]],
                // User Id Fallback, to remove after version 2021.12
-               '/{type}/{customsize}/{uid_ext:\d+\..*}' => [Module\Photo::class, [R::GET]],
-               '/{type}/{customsize}/{nickname_ext}'    => [Module\Photo::class, [R::GET]],
+               '/{type}/{customsize:\d+}/{uid_ext:\d+\..*}'               => [Module\Photo::class, [R::GET]],
+               '/{type}/{customsize:\d+}/{nickname_ext}'                  => [Module\Photo::class, [R::GET]],
        ],
 
        '/pretheme'          => [Module\ThemeDetails::class, [R::GET]],