Skip to content

Commit

Permalink
Add label for logo link
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Mar 28, 2023
1 parent 8ee52d3 commit 7c6ffd9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 23 deletions.
7 changes: 2 additions & 5 deletions core/templates/layout.user.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,9 @@
</h1>
<div class="header-left">
<a href="<?php print_unescaped($_['logoUrl'] ?: link_to('', 'index.php')); ?>"
aria-label="<?php p($l->t('Go to %s', [$_['logoUrl'] ?: $_['defaultAppName']])); ?>"
id="nextcloud">
<div class="logo logo-icon">
<span class="hidden-visually">
<?php p($l->t('%s homepage', [$theme->getName()])); ?>
</span>
</div>
<div class="logo logo-icon"></div>
</a>

<nav id="header-left__appmenu"></nav>
Expand Down
24 changes: 24 additions & 0 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
$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;
}
}
8 changes: 7 additions & 1 deletion lib/private/TemplateLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,16 @@ public function __construct($renderAs, $appId = '') {
$this->assign('enabledThemes', $themesService->getEnabledThemes());
}

// set logo link target
// Set logo link target
$logoUrl = $this->config->getSystemValueString('logo_url', '');
$this->assign('logoUrl', $logoUrl);

// Set default app name
$defaultApp = \OC::$server->getAppManager()->getDefaultAppForUser();
$defaultAppInfo = \OC::$server->getAppManager()->getAppInfo($defaultApp);
$l10n = \OC::$server->getL10NFactory()->get($defaultApp);
$this->assign('defaultAppName', $l10n->t($defaultAppInfo['name']));

// Add navigation entry
$this->assign('application', '');
$this->assign('appid', $appId);
Expand Down
18 changes: 1 addition & 17 deletions lib/private/URLGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,23 +311,7 @@ public function linkToDefaultPageUrl(): string {
return $this->getAbsoluteURL($defaultPage);
}

$appId = 'files';
$defaultApps = explode(',', $this->config->getSystemValue('defaultapp', 'dashboard,files'));

$userId = $this->userSession->isLoggedIn() ? $this->userSession->getUser()->getUID() : null;
if ($userId !== null) {
$userDefaultApps = explode(',', $this->config->getUserValue($userId, 'core', 'defaultapp'));
$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 (\OC::$server->getAppManager()->isEnabledForUser($defaultApp)) {
$appId = $defaultApp;
break;
}
}
$appId = $this->getAppManager()->getDefaultAppForUser();

if ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true
|| getenv('front_controller_active') === 'true') {
Expand Down
9 changes: 9 additions & 0 deletions lib/public/App/IAppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,13 @@ public function getEnabledAppsForGroup(IGroup $group): array;
* @since 17.0.0
*/
public function getAppRestriction(string $appId): array;

/**
* Returns the id of the user's default app
*
* If `user` is not passed, the currently logged in user will be used
*
* @since 25.0.6
*/
public function getDefaultAppForUser(?IUser $user = null): string;
}

0 comments on commit 7c6ffd9

Please sign in to comment.