From 28d9f33faf7fc904409ea5e827ea5a82cceefb91 Mon Sep 17 00:00:00 2001 From: fneumann Date: Thu, 8 Jan 2026 12:34:40 +0100 Subject: [PATCH] =?UTF-8?q?[Admin]=2046680:=20Footerlink=20=E2=80=9ETechni?= =?UTF-8?q?sche=20Betreuung=20kontaktieren=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://mantis.ilias.de/view.php?id=46680 --- .../class.ilSystemSupportContactsGUI.php | 101 ++++++++++++------ 1 file changed, 66 insertions(+), 35 deletions(-) diff --git a/components/ILIAS/SystemFolder/classes/class.ilSystemSupportContactsGUI.php b/components/ILIAS/SystemFolder/classes/class.ilSystemSupportContactsGUI.php index a06de1b1a008..f9845e7f729e 100755 --- a/components/ILIAS/SystemFolder/classes/class.ilSystemSupportContactsGUI.php +++ b/components/ILIAS/SystemFolder/classes/class.ilSystemSupportContactsGUI.php @@ -76,59 +76,90 @@ public function showContacts() $this->tpl->loadStandardTemplate(); $this->tpl->setTitle($this->lng->txt("adm_support_contacts")); - $html = ""; - foreach (ilSystemSupportContacts::getValidSupportContactIds() as $c) { - $pgui = new ilPublicUserProfileGUI($c); - //$pgui->setBackUrl($this->ctrl->getLinkTargetByClass("ilinfoscreengui")); - $pgui->setEmbedded(true); - $html .= $pgui->getHTML(); + $content = []; + if (self::isAnonymous() && !self::globalProfilesEnabled()) { + $mails = []; + foreach (ilSystemSupportContacts::getValidSupportContactIds() as $user_id) { + $mail = ilObjUser::_lookupEmail($user_id); + if ($mail) { + $mails[] = $mail; + } + } + $content[] = $this->ui->factory()->listing()->unordered(array_unique($mails)); + } else { + foreach (ilSystemSupportContacts::getValidSupportContactIds() as $user_id) { + if (self::isProfileVisible($user_id)) { + $pgui = new ilPublicUserProfileGUI($user_id); + $pgui->setEmbedded(true); + $content[] = $this->ui->factory()->legacy($pgui->getHTML()); + } + } } - $f = $this->ui->factory(); - $r = $this->ui->renderer(); - $p = $f->panel()->standard( + $panel = $this->ui->factory()->panel()->standard( $this->lng->txt("adm_support_contacts"), - $f->legacy($html) + $content ); - $this->tpl->setContent($r->render($p)); + $this->tpl->setContent($this->ui->renderer()->render($panel)); $this->tpl->printToStdout(); } - public static function getFooterLink(): null|URI|string + + /** + * Get a contact link to be shown in the footer + */ + public static function getFooterLink(): string { global $DIC; - - $ilCtrl = $DIC->ctrl(); - $ilUser = $DIC->user(); - $uri = $DIC->http()->request()->getUri(); - - $users = ilSystemSupportContacts::getValidSupportContactIds(); - if (count($users) > 0) { - // #17847 - we cannot use a proper GUI on the login screen - if (!$ilUser->getId() || $ilUser->getId() == ANONYMOUS_USER_ID) { - return "mailto:" . ilLegacyFormElementsUtil::prepareFormOutput( - ilSystemSupportContacts::getMailsToAddress() - ); - } else { - $path = $ilCtrl->getLinkTargetByClass("ilsystemsupportcontactsgui", "", "", false, false); - return new URI($uri->getScheme() . '://' . $uri->getHost() . '/' . $path); - } + if (!empty(ilSystemSupportContacts::getValidSupportContactIds())) { + return $DIC->ctrl()->getLinkTargetByClass(self::class); } + return ''; + } + + /** + * Get the text for a contact link to be shown in the footer + */ + public static function getFooterText(): string + { + global $DIC; + return $DIC->language()->txt("contact_sysadmin"); + } - return null; + /** + * Check if the profile of a user can be shown + * - if it is published for www + * - OR if it is published for users and the current user is logged in + */ + public static function isProfileVisible(int $user_id): bool + { + $user = new ilObjUser($user_id); + $public = $user->getPref('public_profile'); + + if (self::isAnonymous()) { + return $public === 'g' && self::globalProfilesEnabled(); + } else { + return $public === 'g' || $public === 'y'; + } } /** - * Get footer text - * - * @return string footer text + * Check if the current user is anonymous */ - public static function getFooterText() + private static function isAnonymous(): bool { global $DIC; + $current_user_id = $DIC->user()->getId(); + return $current_user_id === 0 || $current_user_id === ANONYMOUS_USER_ID; + } - $lng = $DIC->language(); - return $lng->txt("contact_sysadmin"); + /** + * Check if user profiles can be shown to anonymous users + */ + private static function globalProfilesEnabled(): bool + { + global $DIC; + return $DIC->settings()->get('enable_global_profiles'); } }