Skip to content
Merged
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
32 changes: 20 additions & 12 deletions core/templates/layout.user.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,29 @@
* SPDX-License-Identifier: AGPL-3.0-only
* SPDX-FileContributor: Kai Henseler <[email protected]>
*/
?>

<?php
/**
* @var \OC_Defaults $theme
* @var array $_
* Check if logged user has email product
* @return bool
*/
$hasEmailProduct = static function (): bool {
try {
$availableProductsClaim = \OC::$server->get(\OC\SystemConfig::class)->getValue("user_oidc.claims.available_products");
if ($availableProductsClaim === '') {
return false;
}

$userOIDCBackend = \OC::$server->get(\OCA\UserOIDC\User\Backend::class);
$userData = $userOIDCBackend->getUserData();

$availableProductsString = $userData["raw"][$availableProductsClaim] ?? "[]";

$getUserAvatar = static function (int $size) use ($_): string {
return \OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', [
'userId' => $_['user_uid'],
'size' => $size,
'v' => $_['userAvatarVersion']
]);
}
$availableProducts = (array)json_decode($availableProductsString);
return in_array("email", $availableProducts);
} catch (\Error|\Exception) {
return false;
}
};

?><!DOCTYPE html>
<html class="ng-csp" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" data-locale="<?php p($_['locale']); ?>" translate="no" >
Expand Down Expand Up @@ -75,7 +83,7 @@
</div>

<?php $link = \OC::$server->get(\OC\SystemConfig::class)->getValue("ionos_peer_products", [])['ionos_webmail_target_link']; ?>
<?php if ($link !== null) { ?>
<?php if ($link !== null && $hasEmailProduct()) { ?>
<a href="<?php p($link) ?>"
target="_blank"
title="<?php p($l->t('IONOS WEBMAIL')) ?>" data-qa="IONOS-WEBMAIL-TARGET">
Expand Down