X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/38602
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Don't rewrite private/public links when web app disabled

When oc10 app is installed but disabled, we still showed the nav item and rewrote the URLs for private and public links.

https://github.com/owncloud/core/issues/38602
https://github.com/owncloud/core/pull/38603
14 changes: 11 additions & 3 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,22 @@

/**
* Define the Web base URL
* If web.baseUrl is set, public and private links will be redirected to this url.
* Web will handle these links accordingly.
*
* It's needed for the navigation item to the new ownCloud Web UI and for redirecting
* public and private links.
*/
'web.baseUrl' => '',

/**
* Rewrite private and public links to the new ownCloud Web UI (if available).
* If web.rewriteLinks is set to 'true', public and private links will be redirected to this url.
* The Web UI will handle these links accordingly.
*
* As an example, in case 'web.baseUrl' is set to 'http://web.example.com',
* the shared link 'http://ocx.example.com/index.php/s/THoQjwYYMJvXMdW' will be redirected
* by ownCloud to 'http://web.example.com/index.html#/s/THoQjwYYMJvXMdW'.
*/
'web.baseUrl' => '',
'web.rewriteLinks' => false,

/**
* Define clean URLs without `/index.php`
Expand Down
21 changes: 19 additions & 2 deletions core/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
// Check the old phoenix.baseUrl system key to provide compatibility across the name change
$webBaseUrl = \OC::$server->getConfig()->getSystemValue('phoenix.baseUrl', null);
}
if ($webBaseUrl) {
if (isWebRewriteLinksEnabled()) {
$webBaseUrl = \rtrim($webBaseUrl, '/');
$fileId = $urlParams['fileId'];
\OC_Response::redirect("$webBaseUrl/index.html#/f/$fileId");
Expand All @@ -119,7 +119,7 @@
// Check the old phoenix.baseUrl system key to provide compatibility across the name change
$webBaseUrl = \OC::$server->getConfig()->getSystemValue('phoenix.baseUrl', null);
}
if ($webBaseUrl) {
if (isWebRewriteLinksEnabled()) {
$webBaseUrl = \rtrim($webBaseUrl, '/');
$token = $urlParams['token'];
\OC_Response::redirect("$webBaseUrl/index.html#/s/$token");
Expand All @@ -145,3 +145,20 @@
$this->create('heartbeat', '/heartbeat')->action(function () {
// do nothing
});

/**
* Asserts whether rewriting private and public links to the ownCloud Web UI is enabled.
*
* Since we have two different deployment modes - external or as oc10 app -
* we can't just decide based on whether or not the app is enabled. Only if it's
* installed at all, we return false on the disabled app.
*
* @return bool
*/
function isWebRewriteLinksEnabled(): bool {
if (\OC::$server->getAppManager()->isInstalled('web')
&& !\OC::$server->getAppManager()->isEnabledForUser('web')) {
return false;
}
return \OC::$server->getConfig()->getSystemValue('web.rewriteLinks', false);
}
19 changes: 18 additions & 1 deletion lib/private/NavigationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private function init() {
$webIconKey = 'phoenix.icon';
$webIconLabel = 'phoenix.label';
}
if ($webBaseUrl) {
if ($webBaseUrl && !$this->suppressWebNavItem()) {
$iconPath = $this->config->getSystemValue($webIconKey, $this->urlGenerator->imagePath('core', 'apps/web.svg'));
$l = $this->l10nFac->get("core");
$label = $this->config->getSystemValue($webIconLabel, $l->t('New Design'));
Expand All @@ -215,6 +215,23 @@ private function init() {
}
}

/**
* Decides if the `Web` nav item should be hidden.
*
* Since we have two different deployment modes - external or as oc10 app -
* we can't just decide based on whether or not the app is enabled. If it's
* not installed at all we skip the `enabled` check and just rely on the
* webBaseUrl being configured or not.
*
* @return bool
*/
private function suppressWebNavItem(): bool {
if (!$this->appManager->isInstalled('web')) {
return false;
}
return !$this->appManager->isEnabledForUser('web');
}

private function isAdmin() {
$user = $this->userSession->getUser();
if ($user !== null) {
Expand Down
X Tutup