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 @@ -74,63 +74,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();
}


/**
* Get footer link
*
* @return string footer link
* Get a contact link to be shown in the footer
*/
public static function getFooterLink()
public static function getFooterLink(): string
{
global $DIC;

$ilCtrl = $DIC->ctrl();
$ilUser = $DIC->user();

$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 {
return $ilCtrl->getLinkTargetByClass("ilsystemsupportcontactsgui", "", "", false, false);
}
if (!empty(ilSystemSupportContacts::getValidSupportContactIds())) {
return $DIC->ctrl()->getLinkTargetByClass(self::class);
}
return '';
}

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");
}

/**
* Get footer text
*
* @return string footer text
* 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 getFooterText()
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';
}
}

/**
* Check if the current user is anonymous
*/
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');
}
}