ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilSystemSupportContactsGUI.php
Go to the documentation of this file.
1<?php
2
21
29{
30 protected \ILIAS\DI\UIServices $ui;
34 protected $tpl;
35
39 protected $lng;
40
41 protected $ctrl;
42
46 public function __construct()
47 {
48 global $DIC;
49
50 $ilCtrl = $DIC->ctrl();
51 $tpl = $DIC["tpl"];
52 $lng = $DIC->language();
53
54 $this->ctrl = $ilCtrl;
55 $this->tpl = $tpl;
56 $this->lng = $lng;
57 $this->ui = $DIC->ui();
58 }
59
60
64 public function executeCommand()
65 {
66 $next_class = $this->ctrl->getNextClass($this);
67
68 switch ($next_class) {
69 case strtolower(PublicProfileGUI::class):
70 $gui = new PublicProfileGUI();
71 $this->ctrl->setReturn($this, 'showContacts');
72 $this->ctrl->forwardCommand($gui);
73 break;
74
75 default:
76 $cmd = $this->ctrl->getCmd("showContacts");
77 if (in_array($cmd, array("showContacts"))) {
78 $this->$cmd();
79 }
80 }
81 }
82
86 public function showContacts()
87 {
88 $this->lng->loadLanguageModule("adm");
89 $this->tpl->loadStandardTemplate();
90 $this->tpl->setTitle($this->lng->txt("adm_support_contacts"));
91
92 $content = [];
93 if (self::isAnonymous() && !self::globalProfilesEnabled()) {
94 $mails = [];
97 if ($mail) {
98 $mails[] = $mail;
99 }
100 }
101 $content[] = $this->ui->factory()->listing()->unordered(array_unique($mails));
102 } else {
104 if (self::isProfileVisible($user_id)) {
105 $pgui = new PublicProfileGUI($user_id);
106 $pgui->setEmbedded(true);
107 $content[] = $this->ui->factory()->legacy()->content($pgui->getHTML());
108 }
109 }
110 }
111
112 $panel = $this->ui->factory()->panel()->standard(
113 $this->lng->txt("adm_support_contacts"),
114 $content
115 );
116
117 $this->tpl->setContent($this->ui->renderer()->render($panel));
118 $this->tpl->printToStdout();
119 }
120
121
125 public static function getFooterLink(): ?string
126 {
127 global $DIC;
129 return $DIC->ctrl()->getLinkTargetByClass(self::class);
130 }
131 return null;
132 }
133
137 public static function getFooterText(): string
138 {
139 global $DIC;
140 return $DIC->language()->txt("contact_sysadmin");
141 }
142
148 public static function isProfileVisible(int $user_id): bool
149 {
150 $user = new ilObjUser($user_id);
151 $public = $user->getPref('public_profile');
152
153 if (self::isAnonymous()) {
154 return $public === 'g' && self::globalProfilesEnabled();
155 } else {
156 return $public === 'g' || $public === 'y';
157 }
158 }
159
163 private static function isAnonymous(): bool
164 {
165 global $DIC;
166 $current_user_id = $DIC->user()->getId();
167 return $current_user_id === 0 || $current_user_id === ANONYMOUS_USER_ID;
168 }
169
173 private static function globalProfilesEnabled(): bool
174 {
175 global $DIC;
176 return $DIC->settings()->get('enable_global_profiles') ?? false;
177 }
178}
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
GUI class for public user profile presentation.
User class.
static _lookupEmail(int $a_user_id)
static globalProfilesEnabled()
Check if user profiles can be shown to anonymous users.
static isAnonymous()
Check if the current user is anonymous.
static isProfileVisible(int $user_id)
Check if the profile of a user can be shown.
static getFooterLink()
Get a contact link to be shown in the footer.
static getFooterText()
Get the text for a contact link to be shown in the footer.
static getValidSupportContactIds()
Get valid support contacts.
const ANONYMOUS_USER_ID
Definition: constants.php:27
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26