-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add user-configurable defaultapp_path (fixes broken external defaultapp) #28962
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
* @author Marvin Thomas Rabe <[email protected]> | ||
* @author Michael Gapczynski <[email protected]> | ||
* @author Morris Jobke <[email protected]> | ||
* @author Nick Sweeting <[email protected]> | ||
* @author Philipp Schaffrath <[email protected]> | ||
* @author Robin Appelman <[email protected]> | ||
* @author Robin McCorkell <[email protected]> | ||
|
@@ -1089,20 +1090,33 @@ public static function getDefaultPageUrl() { | |
$location = $urlGenerator->getAbsoluteURL($defaultPage); | ||
} else { | ||
$appId = 'files'; | ||
$defaultApps = explode(',', \OCP\Config::getSystemValue('defaultapp', 'files')); | ||
$appPath = '/'; | ||
$defaultApps = explode(',', \OCP\Config::getSystemValue('defaultapp', $appId)); | ||
$defaultAppPaths = explode(',', \OCP\Config::getSystemValue('defaultapp_path', $appPath)); | ||
|
||
// find the first app that is enabled for the current user | ||
foreach ($defaultApps as $defaultApp) { | ||
foreach ($defaultApps as $idx=>$defaultApp) { | ||
$defaultApp = OC_App::cleanAppId(strip_tags($defaultApp)); | ||
// if app has a corresponding path, use it, otherwise default to / | ||
if (isset($defaultAppPaths[$idx]) && $defaultAppPaths[$idx] !== '') { | ||
$defaultAppPath = strip_tags($defaultAppPaths[$idx]); | ||
} else { | ||
$defaultAppPath = '/'; | ||
} | ||
if (static::getAppManager()->isEnabledForUser($defaultApp)) { | ||
$appId = $defaultApp; | ||
$appPath = $defaultAppPath; | ||
break; | ||
} | ||
} | ||
|
||
if(getenv('front_controller_active') === 'true') { | ||
$location = $urlGenerator->getAbsoluteURL('/apps/' . $appId . '/'); | ||
if ($appId === 'external' && $appPath === '/') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Core should not know about any external apps, please remove. I suggest that you instead improve the external sites app to have a special route that accepts indices so that when it's opened in the browser, it will redirect to the external site page. |
||
// correct external/ to external/1/ if custom path wasn't specified | ||
$appPath = '/1/'; | ||
} | ||
if (getenv('front_controller_active') === 'true') { | ||
$location = $urlGenerator->getAbsoluteURL('/apps/' . $appId . $appPath); | ||
} else { | ||
$location = $urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/'); | ||
$location = $urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . $appPath); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is a PHP file, you could even use a PHP array directly like it's done for other settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I wasn't sure if these options could be set by environment variable or other config file so I assumed they had to be strings, but an
array
is definitely better.