Skip to content

Commit 28d9f33

Browse files
committed
[Admin] 46680: Footerlink „Technische Betreuung kontaktieren“
https://mantis.ilias.de/view.php?id=46680
1 parent b8b844d commit 28d9f33

1 file changed

Lines changed: 66 additions & 35 deletions

File tree

components/ILIAS/SystemFolder/classes/class.ilSystemSupportContactsGUI.php

Lines changed: 66 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -76,59 +76,90 @@ public function showContacts()
7676
$this->tpl->loadStandardTemplate();
7777
$this->tpl->setTitle($this->lng->txt("adm_support_contacts"));
7878

79-
$html = "";
80-
foreach (ilSystemSupportContacts::getValidSupportContactIds() as $c) {
81-
$pgui = new ilPublicUserProfileGUI($c);
82-
//$pgui->setBackUrl($this->ctrl->getLinkTargetByClass("ilinfoscreengui"));
83-
$pgui->setEmbedded(true);
84-
$html .= $pgui->getHTML();
79+
$content = [];
80+
if (self::isAnonymous() && !self::globalProfilesEnabled()) {
81+
$mails = [];
82+
foreach (ilSystemSupportContacts::getValidSupportContactIds() as $user_id) {
83+
$mail = ilObjUser::_lookupEmail($user_id);
84+
if ($mail) {
85+
$mails[] = $mail;
86+
}
87+
}
88+
$content[] = $this->ui->factory()->listing()->unordered(array_unique($mails));
89+
} else {
90+
foreach (ilSystemSupportContacts::getValidSupportContactIds() as $user_id) {
91+
if (self::isProfileVisible($user_id)) {
92+
$pgui = new ilPublicUserProfileGUI($user_id);
93+
$pgui->setEmbedded(true);
94+
$content[] = $this->ui->factory()->legacy($pgui->getHTML());
95+
}
96+
}
8597
}
8698

87-
$f = $this->ui->factory();
88-
$r = $this->ui->renderer();
89-
$p = $f->panel()->standard(
99+
$panel = $this->ui->factory()->panel()->standard(
90100
$this->lng->txt("adm_support_contacts"),
91-
$f->legacy($html)
101+
$content
92102
);
93103

94-
$this->tpl->setContent($r->render($p));
104+
$this->tpl->setContent($this->ui->renderer()->render($panel));
95105
$this->tpl->printToStdout();
96106
}
97107

98-
public static function getFooterLink(): null|URI|string
108+
109+
/**
110+
* Get a contact link to be shown in the footer
111+
*/
112+
public static function getFooterLink(): string
99113
{
100114
global $DIC;
101-
102-
$ilCtrl = $DIC->ctrl();
103-
$ilUser = $DIC->user();
104-
$uri = $DIC->http()->request()->getUri();
105-
106-
$users = ilSystemSupportContacts::getValidSupportContactIds();
107-
if (count($users) > 0) {
108-
// #17847 - we cannot use a proper GUI on the login screen
109-
if (!$ilUser->getId() || $ilUser->getId() == ANONYMOUS_USER_ID) {
110-
return "mailto:" . ilLegacyFormElementsUtil::prepareFormOutput(
111-
ilSystemSupportContacts::getMailsToAddress()
112-
);
113-
} else {
114-
$path = $ilCtrl->getLinkTargetByClass("ilsystemsupportcontactsgui", "", "", false, false);
115-
return new URI($uri->getScheme() . '://' . $uri->getHost() . '/' . $path);
116-
}
115+
if (!empty(ilSystemSupportContacts::getValidSupportContactIds())) {
116+
return $DIC->ctrl()->getLinkTargetByClass(self::class);
117117
}
118+
return '';
119+
}
120+
121+
/**
122+
* Get the text for a contact link to be shown in the footer
123+
*/
124+
public static function getFooterText(): string
125+
{
126+
global $DIC;
127+
return $DIC->language()->txt("contact_sysadmin");
128+
}
118129

119-
return null;
130+
/**
131+
* Check if the profile of a user can be shown
132+
* - if it is published for www
133+
* - OR if it is published for users and the current user is logged in
134+
*/
135+
public static function isProfileVisible(int $user_id): bool
136+
{
137+
$user = new ilObjUser($user_id);
138+
$public = $user->getPref('public_profile');
139+
140+
if (self::isAnonymous()) {
141+
return $public === 'g' && self::globalProfilesEnabled();
142+
} else {
143+
return $public === 'g' || $public === 'y';
144+
}
120145
}
121146

122147
/**
123-
* Get footer text
124-
*
125-
* @return string footer text
148+
* Check if the current user is anonymous
126149
*/
127-
public static function getFooterText()
150+
private static function isAnonymous(): bool
128151
{
129152
global $DIC;
153+
$current_user_id = $DIC->user()->getId();
154+
return $current_user_id === 0 || $current_user_id === ANONYMOUS_USER_ID;
155+
}
130156

131-
$lng = $DIC->language();
132-
return $lng->txt("contact_sysadmin");
157+
/**
158+
* Check if user profiles can be shown to anonymous users
159+
*/
160+
private static function globalProfilesEnabled(): bool
161+
{
162+
global $DIC;
163+
return $DIC->settings()->get('enable_global_profiles');
133164
}
134165
}

0 commit comments

Comments
 (0)