8000 Add default app setting on a user basis by JammingBen · Pull Request #39600 · owncloud/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add default app setting on a user basis #39600

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

Merged
merged 2 commits into from
Jul 7, 2022
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
3 changes: 3 additions & 0 deletions changelog/unreleased/39600
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Add default app setting on a user basis

https://github.com/owncloud/core/pull/39600
12 changes: 11 additions & 1 deletion lib/private/legacy/util.php
C362
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,17 @@ public static function getDefaultPageUrl() {
$location = $urlGenerator->getAbsoluteURL($defaultPage);
} else {
$appId = 'files';
$defaultApps = \explode(',', \OC::$server->getConfig()->getSystemValue('defaultapp', 'files'));
$uid = \OC_User::getUser();
$config = \OC::$server->getConfig();
$defaultApps = \explode(',', $config->getSystemValue('defaultapp', 'files'));

if ($uid) {
$userDefaultApp = $config->getUserValue($uid, 'core', 'defaultapp', null);
if ($userDefaultApp) {
\array_unshift($defaultApps, $userDefaultApp);
}
}

// find the first app that is enabled for the current user
foreach ($defaultApps as $defaultApp) {
$defaultApp = OC_App::cleanAppId(\strip_tags($defaultApp));
Expand Down
19 changes: 19 additions & 0 deletions tests/lib/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,25 @@ public function testGetDefaultPageUrlWithRedirectUrlRedirectBypassWithFrontContr
$this->assertSame('http://localhost'.\OC::$WEBROOT.'/apps/files/', OC_Util::getDefaultPageUrl());
}

public function testGetDefaultPageUrlWithUserConfig() {
$uid = $this->getUniqueID();
$userDefaultApp = 'user_default_app';
\OC_User::setUserId($uid);
\OC::$server->getConfig()->setUserValue($uid, 'core', 'defaultapp', $userDefaultApp);

$appManager = $this->createMock(IAppManager::class);
$appManager->expects($this->any())
->method('isEnabledForUser')
->willReturn(true);
Dummy_OC_Util::$appManager = $appManager;

\putenv('front_controller_active=true');
$_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
$this->assertSame('http://localhost'.\OC::$WEBROOT.'/apps/' . $userDefaultApp . '/', Dummy_OC_Util::getDefaultPageUrl());
\OC::$server->getConfig()->deleteUserValue($uid, 'core', 'defaultapp');
\OC_User::setUserId(null);
}

/**
* Test needUpgrade() when the core version is increased
*/
Expand Down
0