diff --git a/src/App/Page.php b/src/App/Page.php
index afc94fbdf0..37141426c3 100644
--- a/src/App/Page.php
+++ b/src/App/Page.php
@@ -241,7 +241,6 @@ class Page implements ArrayAccess
* being first
*/
$this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
- '$local_nickname' => $app->getLoggedInUserNickname(),
'$local_user' => $localUID,
'$generator' => 'Friendica' . ' ' . App::VERSION,
'$delitem' => $l10n->t('Delete this item?'),
diff --git a/src/Model/Photo.php b/src/Model/Photo.php
index 12d0c2f92c..87a81069f8 100644
--- a/src/Model/Photo.php
+++ b/src/Model/Photo.php
@@ -207,7 +207,7 @@ class Photo
public static function getBrowsablePhotosForUser(int $uid, string $album = null): array
{
if (!empty($album)) {
- $sqlExtra = sprintf("AND `album` = '%S' ", DBA::escape($album));
+ $sqlExtra = sprintf("AND `album` = '%s' ", DBA::escape($album));
$sqlExtra2 = "";
} else {
$sqlExtra = '';
diff --git a/src/Module/Profile/Attachment/Browser.php b/src/Module/Media/AttachmentBrowser.php
similarity index 89%
rename from src/Module/Profile/Attachment/Browser.php
rename to src/Module/Media/AttachmentBrowser.php
index a6640bf5d2..c0ec1c5d9b 100644
--- a/src/Module/Profile/Attachment/Browser.php
+++ b/src/Module/Media/AttachmentBrowser.php
@@ -19,7 +19,7 @@
*
*/
-namespace Friendica\Module\Profile\Attachment;
+namespace Friendica\Module\Media;
use Friendica\App;
use Friendica\BaseModule;
@@ -29,6 +29,7 @@ use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Model\Attach;
use Friendica\Module\Response;
+use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Util\Profiler;
use Friendica\Util\Strings;
use Psr\Log\LoggerInterface;
@@ -36,7 +37,7 @@ use Psr\Log\LoggerInterface;
/**
* Browser for Attachments
*/
-class Browser extends BaseModule
+class AttachmentBrowser extends BaseModule
{
/** @var IHandleUserSessions */
protected $session;
@@ -54,7 +55,7 @@ class Browser extends BaseModule
protected function content(array $request = []): string
{
if (!$this->session->getLocalUserId()) {
- $this->baseUrl->redirect();
+ throw new UnauthorizedException($this->t('Permission denied.'));
}
// Needed to match the correct template in a module that uses a different theme than the user/site/default
@@ -68,7 +69,7 @@ class Browser extends BaseModule
$fileArray = array_map([$this, 'map_files'], $files);
- $tpl = Renderer::getMarkupTemplate('profile/filebrowser.tpl');
+ $tpl = Renderer::getMarkupTemplate('media/filebrowser.tpl');
$output = Renderer::replaceMacros($tpl, [
'$type' => 'attachment',
'$path' => ['' => $this->t('Files')],
@@ -88,8 +89,8 @@ class Browser extends BaseModule
protected function map_files(array $record): array
{
- list($m1, $m2) = explode('/', $record['filetype']);
- $filetype = file_exists(sprintf('images/icons/%s.png', $m1) ? $m1 : 'zip');
+ [$m1, $m2] = explode('/', $record['filetype']);
+ $filetype = file_exists(sprintf('images/icons/%s.png', $m1) ? $m1 : 'text');
return [
sprintf('%s/attach/%s', $this->baseUrl, $record['id']),
diff --git a/src/Module/Profile/Photos/Browser.php b/src/Module/Media/PhotosBrowser.php
similarity index 93%
rename from src/Module/Profile/Photos/Browser.php
rename to src/Module/Media/PhotosBrowser.php
index 2185aa7c78..4c9803fc60 100644
--- a/src/Module/Profile/Photos/Browser.php
+++ b/src/Module/Media/PhotosBrowser.php
@@ -19,7 +19,7 @@
*
*/
-namespace Friendica\Module\Profile\Photos;
+namespace Friendica\Module\Media;
use Friendica\App;
use Friendica\BaseModule;
@@ -29,6 +29,7 @@ use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Model\Photo;
use Friendica\Module\Response;
+use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Util\Images;
use Friendica\Util\Profiler;
use Friendica\Util\Strings;
@@ -37,7 +38,7 @@ use Psr\Log\LoggerInterface;
/**
* Browser for Photos
*/
-class Browser extends BaseModule
+class PhotosBrowser extends BaseModule
{
/** @var IHandleUserSessions */
protected $session;
@@ -55,7 +56,7 @@ class Browser extends BaseModule
protected function content(array $request = []): string
{
if (!$this->session->getLocalUserId()) {
- $this->baseUrl->redirect();
+ throw new UnauthorizedException($this->t('Permission denied.'));
}
// Needed to match the correct template in a module that uses a different theme than the user/site/default
@@ -78,7 +79,7 @@ class Browser extends BaseModule
$photosArray = array_map([$this, 'map_files'], $photos);
- $tpl = Renderer::getMarkupTemplate('profile/filebrowser.tpl');
+ $tpl = Renderer::getMarkupTemplate('media/filebrowser.tpl');
$output = Renderer::replaceMacros($tpl, [
'$type' => 'photos',
'$path' => $path,
diff --git a/static/routes.config.php b/static/routes.config.php
index 794f705e40..542e31679b 100644
--- a/static/routes.config.php
+++ b/static/routes.config.php
@@ -31,20 +31,18 @@ use Friendica\App\Router as R;
use Friendica\Module;
$profileRoutes = [
- '' => [Module\Profile\Index::class, [R::GET]],
- '/attachment/upload' => [Module\Profile\Attachment\Upload::class, [ R::POST]],
- '/attachment/browser' => [Module\Profile\Attachment\Browser::class, [R::GET]],
- '/contacts/common' => [Module\Profile\Common::class, [R::GET]],
- '/contacts[/{type}]' => [Module\Profile\Contacts::class, [R::GET]],
- '/media' => [Module\Profile\Media::class, [R::GET]],
- '/photos' => [Module\Profile\Photos\Index::class, [R::GET ]],
- '/photos/browser[/{album}]' => [Module\Profile\Photos\Browser::class, [R::GET]],
- '/photos/upload' => [Module\Profile\Photos\Upload::class, [ R::POST]],
- '/profile' => [Module\Profile\Profile::class, [R::GET]],
- '/remote_follow' => [Module\Profile\RemoteFollow::class, [R::GET, R::POST]],
- '/schedule' => [Module\Profile\Schedule::class, [R::GET, R::POST]],
- '/status[/{category}[/{date1}[/{date2}]]]' => [Module\Profile\Status::class, [R::GET]],
- '/unkmail' => [Module\Profile\UnkMail::class, [R::GET, R::POST]],
+ '' => [Module\Profile\Index::class, [R::GET]],
+ '/attachment/upload' => [Module\Profile\Attachment\Upload::class, [ R::POST]],
+ '/contacts/common' => [Module\Profile\Common::class, [R::GET]],
+ '/contacts[/{type}]' => [Module\Profile\Contacts::class, [R::GET]],
+ '/media' => [Module\Profile\Media::class, [R::GET]],
+ '/photos' => [Module\Profile\Photos\Index::class, [R::GET ]],
+ '/photos/upload' => [Module\Profile\Photos\Upload::class, [ R::POST]],
+ '/profile' => [Module\Profile\Profile::class, [R::GET]],
+ '/remote_follow' => [Module\Profile\RemoteFollow::class, [R::GET, R::POST]],
+ '/schedule' => [Module\Profile\Schedule::class, [R::GET, R::POST]],
+ '/status[/{category}[/{date1}[/{date2}]]]' => [Module\Profile\Status::class, [R::GET]],
+ '/unkmail' => [Module\Profile\UnkMail::class, [R::GET, R::POST]],
];
$apiRoutes = [
@@ -471,6 +469,12 @@ return [
'/magic' => [Module\Magic::class, [R::GET]],
'/manifest' => [Module\Manifest::class, [R::GET]],
'/friendica.webmanifest' => [Module\Manifest::class, [R::GET]],
+
+ '/media' => [
+ '/attachment/browser' => [Module\Media\AttachmentBrowser::class, [R::GET]],
+ '/photos/browser[/{album}]' => [Module\Media\PhotosBrowser::class, [R::GET]],
+ ],
+
'/moderation' => [
'[/]' => [Module\Moderation\Summary::class, [R::GET]],
diff --git a/view/js/main.js b/view/js/main.js
index 782eb4ec56..deaa450603 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -1095,7 +1095,7 @@ var Dialog = {
if (id !== undefined) {
hash = hash + "-" + id;
}
- return '/profile/' + localNickname + '/' + type + '/browser?mode=minimal#' + hash;
+ return 'media/' + type + '/browser?mode=minimal#' + hash;
},
_get_size: function() {
diff --git a/view/js/filebrowser.js b/view/js/media/filebrowser.js
similarity index 97%
rename from view/js/filebrowser.js
rename to view/js/media/filebrowser.js
index a1ed09d24d..2239de4f64 100644
--- a/view/js/filebrowser.js
+++ b/view/js/media/filebrowser.js
@@ -155,7 +155,7 @@ const FileBrowser = {
_getUrl: function (mode, hash, folder) {
let folderValue = folder !== undefined ? folder : FileBrowser.folder;
let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
- return 'profile/' + FileBrowser.nickname + '/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + hash;
+ return 'media/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + hash;
}
};
// @license-end
diff --git a/view/templates/profile/filebrowser.tpl b/view/templates/media/filebrowser.tpl
similarity index 91%
rename from view/templates/profile/filebrowser.tpl
rename to view/templates/media/filebrowser.tpl
index ff25741a9b..6c087a62be 100644
--- a/view/templates/profile/filebrowser.tpl
+++ b/view/templates/media/filebrowser.tpl
@@ -2,7 +2,7 @@
This is the template used by mod/fbrowser.php
-->
-
+