Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please return null, so that the Link is hidden if it is not present.
An empty string will result in a broken link.
See:

if (($system_support_url = \ilSystemSupportContactsGUI::getFooterLink()) !== null) {

Also the buildURI call can be readded as well (but only a suggestion as this is a bugfix): ae7301f#diff-413f26f1852286d88624d2da1c0d7a70d1a68683b82b6c30f0583c30b003eb67R102

}

/**
* 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');
}
}
Loading