@@ -89,59 +89,90 @@ public function showContacts()
8989 $ this ->tpl ->loadStandardTemplate ();
9090 $ this ->tpl ->setTitle ($ this ->lng ->txt ("adm_support_contacts " ));
9191
92- $ html = "" ;
93- foreach (ilSystemSupportContacts::getValidSupportContactIds () as $ c ) {
94- $ pgui = new PublicProfileGUI ($ c );
95- //$pgui->setBackUrl($this->ctrl->getLinkTargetByClass("ilinfoscreengui"));
96- $ pgui ->setEmbedded (true );
97- $ html .= $ pgui ->getHTML ();
92+ $ content = [];
93+ if (self ::isAnonymous () && !self ::globalProfilesEnabled ()) {
94+ $ mails = [];
95+ foreach (ilSystemSupportContacts::getValidSupportContactIds () as $ user_id ) {
96+ $ mail = ilObjUser::_lookupEmail ($ user_id );
97+ if ($ mail ) {
98+ $ mails [] = $ mail ;
99+ }
100+ }
101+ $ content [] = $ this ->ui ->factory ()->listing ()->unordered (array_unique ($ mails ));
102+ } else {
103+ foreach (ilSystemSupportContacts::getValidSupportContactIds () as $ user_id ) {
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+ }
98110 }
99111
100- $ f = $ this ->ui ->factory ();
101- $ r = $ this ->ui ->renderer ();
102- $ p = $ f ->panel ()->standard (
112+ $ panel = $ this ->ui ->factory ()->panel ()->standard (
103113 $ this ->lng ->txt ("adm_support_contacts " ),
104- $ f -> legacy ()-> content ( $ html )
114+ $ content
105115 );
106116
107- $ this ->tpl ->setContent ($ r -> render ($ p ));
117+ $ this ->tpl ->setContent ($ this -> ui -> renderer ()-> render ($ panel ));
108118 $ this ->tpl ->printToStdout ();
109119 }
110120
111- public static function getFooterLink (): null |URI |string
121+
122+ /**
123+ * Get a contact link to be shown in the footer
124+ */
125+ public static function getFooterLink (): ?string
112126 {
113127 global $ DIC ;
114-
115- $ ilCtrl = $ DIC ->ctrl ();
116- $ ilUser = $ DIC ->user ();
117- $ uri = $ DIC ->http ()->request ()->getUri ();
118-
119- $ users = ilSystemSupportContacts::getValidSupportContactIds ();
120- if (count ($ users ) > 0 ) {
121- // #17847 - we cannot use a proper GUI on the login screen
122- if (!$ ilUser ->getId () || $ ilUser ->getId () == ANONYMOUS_USER_ID ) {
123- return "mailto: " . ilLegacyFormElementsUtil::prepareFormOutput (
124- ilSystemSupportContacts::getMailsToAddress ()
125- );
126- } else {
127- $ path = $ ilCtrl ->getLinkTargetByClass ("ilsystemsupportcontactsgui " , "" , "" , false , false );
128- return new URI ($ uri ->getScheme () . ':// ' . $ uri ->getHost () . '/ ' . $ path );
129- }
128+ if (!empty (ilSystemSupportContacts::getValidSupportContactIds ())) {
129+ return $ DIC ->ctrl ()->getLinkTargetByClass (self ::class);
130130 }
131-
132131 return null ;
133132 }
134133
135134 /**
136- * Get footer text
137- *
138- * @return string footer text
135+ * Get the text for a contact link to be shown in the footer
139136 */
140- public static function getFooterText ()
137+ public static function getFooterText (): string
141138 {
142139 global $ DIC ;
140+ return $ DIC ->language ()->txt ("contact_sysadmin " );
141+ }
143142
144- $ lng = $ DIC ->language ();
145- return $ lng ->txt ("contact_sysadmin " );
143+ /**
144+ * Check if the profile of a user can be shown
145+ * - if it is published for www
146+ * - OR if it is published for users and the current user is logged in
147+ */
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+
160+ /**
161+ * Check if the current user is anonymous
162+ */
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+
170+ /**
171+ * Check if user profiles can be shown to anonymous users
172+ */
173+ private static function globalProfilesEnabled (): bool
174+ {
175+ global $ DIC ;
176+ return $ DIC ->settings ()->get ('enable_global_profiles ' ) ?? false ;
146177 }
147178}
0 commit comments