-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add label for logo link #37435
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 label for logo link #37435
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -827,4 +827,28 @@ public function getDefaultEnabledApps():array { | |||
|
|
||||
| return $this->defaultEnabled; | ||||
| } | ||||
|
|
||||
| public function getDefaultAppForUser(?IUser $user = null): string { | ||||
| // Set fallback to always-enabled files app | ||||
| $appId = 'files'; | ||||
| $defaultApps = explode(',', $this->config->getSystemValueString('defaultapp', 'dashboard,files')); | ||||
|
|
||||
| $user ??= $this->userSession->getUser(); | ||||
|
|
||||
| if ($user !== null) { | ||||
| $userDefaultApps = explode(',', $this->config->getUserValue($user->getUID(), 'core', 'defaultapp')); | ||||
|
Member
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.
Member
Author
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. Does not seem to be updatable from the web UI but added in db86bea probably for admins to set with occ user:setting admin core defaultapp files
Member
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. Do we actually support users setting their own default app?
Member
Author
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.
Can only be set by an admin from what I can see
Probably thought the string was the default fallback? Line 196 in 31f4f41
|
||||
| $defaultApps = array_filter(array_merge($userDefaultApps, $defaultApps)); | ||||
| } | ||||
|
|
||||
| // Find the first app that is enabled for the current user | ||||
| foreach ($defaultApps as $defaultApp) { | ||||
| $defaultApp = \OC_App::cleanAppId(strip_tags($defaultApp)); | ||||
| if ($this->isEnabledForUser($defaultApp, $user)) { | ||||
| $appId = $defaultApp; | ||||
| break; | ||||
| } | ||||
| } | ||||
|
|
||||
| return $appId; | ||||
| } | ||||
| } | ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ | |
| use OCP\IConfig; | ||
| use OCP\IRequest; | ||
| use OCP\IURLGenerator; | ||
| use OCP\IUser; | ||
| use OCP\IUserSession; | ||
|
|
||
| /** | ||
|
|
@@ -216,21 +215,16 @@ public function provideOCSRoutes() { | |
| ]; | ||
| } | ||
|
|
||
| private function mockLinkToDefaultPageUrl(string $defaultAppConfig = '', bool $ignoreFrontControllerConfig = false) { | ||
| $this->config->expects($this->exactly(2)) | ||
| ->method('getSystemValue') | ||
| ->withConsecutive( | ||
| ['defaultapp', $this->anything()], | ||
| ['htaccess.IgnoreFrontController', $this->anything()], | ||
| ) | ||
| ->will($this->onConsecutiveCalls( | ||
| $defaultAppConfig, | ||
| $ignoreFrontControllerConfig | ||
| )); | ||
| private function mockLinkToDefaultPageUrl(bool $ignoreFrontControllerConfig = false) { | ||
| $this->config->expects($this->once()) | ||
| ->method('getAppValue') | ||
| ->with('core', 'defaultpage') | ||
| ->willReturn(''); | ||
|
|
||
| $this->config->expects($this->once()) | ||
| ->method('getSystemValue') | ||
| ->with('htaccess.IgnoreFrontController', $this->anything()) | ||
| ->willReturn($ignoreFrontControllerConfig); | ||
| } | ||
|
|
||
| public function testLinkToDefaultPageUrlWithRedirectUrlWithoutFrontController() { | ||
|
|
@@ -246,7 +240,7 @@ public function testLinkToDefaultPageUrlWithRedirectUrlRedirectBypassWithoutFron | |
| putenv('front_controller_active=false'); | ||
|
|
||
| $_REQUEST['redirect_url'] = '[email protected]:a'; | ||
| $this->assertSame('http://localhost' . \OC::$WEBROOT . '/index.php/apps/files/', $this->urlGenerator->linkToDefaultPageUrl()); | ||
| $this->assertSame('http://localhost' . \OC::$WEBROOT . '/index.php/apps/dashboard/', $this->urlGenerator->linkToDefaultPageUrl()); | ||
| } | ||
|
|
||
| public function testLinkToDefaultPageUrlWithRedirectUrlRedirectBypassWithFrontController() { | ||
|
|
@@ -255,70 +249,16 @@ public function testLinkToDefaultPageUrlWithRedirectUrlRedirectBypassWithFrontCo | |
| putenv('front_controller_active=true'); | ||
|
|
||
| $_REQUEST['redirect_url'] = '[email protected]:a'; | ||
| $this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/files/', $this->urlGenerator->linkToDefaultPageUrl()); | ||
| $this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/dashboard/', $this->urlGenerator->linkToDefaultPageUrl()); | ||
| } | ||
|
|
||
| public function testLinkToDefaultPageUrlWithRedirectUrlWithIgnoreFrontController() { | ||
| $this->mockBaseUrl(); | ||
| $this->mockLinkToDefaultPageUrl('', true); | ||
| $this->mockLinkToDefaultPageUrl(true); | ||
| putenv('front_controller_active=false'); | ||
|
|
||
| $_REQUEST['redirect_url'] = '[email protected]:a'; | ||
| $this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/files/', $this->urlGenerator->linkToDefaultPageUrl()); | ||
| } | ||
|
|
||
| /** | ||
| * @dataProvider provideDefaultApps | ||
| */ | ||
| public function testLinkToDefaultPageUrlWithDefaultApps($defaultAppConfig, $expectedPath) { | ||
| $userId = $this->getUniqueID(); | ||
|
|
||
| /** @var \PHPUnit\Framework\MockObject\MockObject|IUser $userMock */ | ||
| $userMock = $this->createMock(IUser::class); | ||
| $userMock->expects($this->once()) | ||
| ->method('getUID') | ||
| ->willReturn($userId); | ||
|
|
||
| $this->mockBaseUrl(); | ||
| $this->mockLinkToDefaultPageUrl($defaultAppConfig); | ||
|
|
||
| $this->config->expects($this->once()) | ||
| ->method('getUserValue') | ||
| ->with($userId, 'core', 'defaultapp') | ||
| ->willReturn(''); | ||
| $this->userSession->expects($this->once()) | ||
| ->method('isLoggedIn') | ||
| ->willReturn(true); | ||
| $this->userSession->expects($this->once()) | ||
| ->method('getUser') | ||
| ->willReturn($userMock); | ||
|
|
||
| $this->assertEquals('http://localhost' . \OC::$WEBROOT . $expectedPath, $this->urlGenerator->linkToDefaultPageUrl()); | ||
| } | ||
|
|
||
| public function provideDefaultApps(): array { | ||
| return [ | ||
| // none specified, default to files | ||
| [ | ||
| '', | ||
| '/index.php/apps/files/', | ||
| ], | ||
| // unexisting or inaccessible app specified, default to files | ||
| [ | ||
| 'unexist', | ||
| '/index.php/apps/files/', | ||
| ], | ||
| // non-standard app | ||
| [ | ||
| 'settings', | ||
| '/index.php/apps/settings/', | ||
| ], | ||
| // non-standard app with fallback | ||
| [ | ||
| 'unexist,settings', | ||
| '/index.php/apps/settings/', | ||
| ], | ||
| ]; | ||
| $this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/dashboard/', $this->urlGenerator->linkToDefaultPageUrl()); | ||
| } | ||
|
|
||
| public function imagePathProvider(): array { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.