38 protected \Psr\Http\Message\RequestInterface
$request;
52 $this->main_tpl =
$DIC->ui()->mainTemplate();
53 $this->
lng = $DIC->language();
54 $this->
ctrl = $DIC->ctrl();
55 $this->
lng->loadLanguageModule(
"user");
56 $this->
user = $DIC->user();
58 $this->uiFactory =
$DIC->ui()->factory();
59 $this->uiRenderer =
$DIC->ui()->renderer();
60 $this->chatSettings =
new ilSetting(
'chatroom');
61 $this->notificationSettings =
new ilSetting(
'notifications');
62 $this->
event = $DIC->event();
64 $this->request =
$DIC->http()->request();
74 $next_class = $this->
ctrl->getNextClass();
76 switch ($next_class) {
78 $cmd = $this->
ctrl->getCmd(
"showPrivacySettings");
82 $this->main_tpl->printToStdout();
94 return $this->user_settings_config->isVisibleAndChangeable($setting);
99 return $this->user_settings_config->isVisible($setting);
110 if ($this->checklist_status->anyVisibilitySettings()
111 && ($this->isAwarnessSettingVisible()
112 || $this->isContactSettingVisible()
113 || $this->shouldDisplayChatSection())) {
114 if (is_null($form)) {
117 $html = $this->uiRenderer->render([$form]);
121 if ($this->profile_mode->isEnabled()) {
122 $pub_profile_legacy = $this->uiFactory->legacy($pub_profile->getEmbeddable());
123 $html .= $this->uiRenderer->render($this->uiFactory->panel()->standard(
124 $this->lng->txt(
'user_profile_preview'),
127 } elseif (!$this->checklist_status->anyVisibilitySettings()) {
128 $html .= $this->uiRenderer->render(
129 [$this->uiFactory->messageBox()->info(
$lng->
txt(
"usr_public_profile_disabled"))]
146 return $awrn_set->get(
"awrn_enabled",
'0') && $this->userSettingVisible(
"hide_own_online_status");
164 $this->populateWithAwarenessSettingsSection($sections);
165 $this->populateWithContactsSettingsSection($sections);
166 $this->populateWithChatSettingsSection($sections);
167 $this->populateWithNotificationSettingsSection($sections);
169 $form_action = $this->
ctrl->getLinkTarget($this,
"savePrivacySettings");
171 return $this->uiFactory->input()
174 ->standard($form_action, $sections)
175 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
static function (array $values): array {
176 return array_merge(...array_values($values));
183 $this->chatSettings->get(
'enable_osc',
'0') &&
184 !$this->settings->get(
'usr_settings_hide_chat_osc_accept_msg',
'0')
191 !$this->
settings->get(
'usr_settings_hide_chat_broadcast_typing',
'0')
197 return (
bool) $this->chatSettings->get(
'chat_enabled',
'0');
202 return (
bool) $this->notificationSettings->get(
'osd_play_sound',
'0');
207 return (
bool) $this->notificationSettings->get(
'enable_osd',
'0');
213 if (!$this->isAwarnessSettingVisible()) {
217 $this->
lng->loadLanguageModule(
"awrn");
219 $default = ($this->
settings->get(
'hide_own_online_status') ===
"n")
220 ? $this->
lng->txt(
"user_awrn_show")
221 : $this->
lng->txt(
"user_awrn_hide");
224 "x" => $this->
lng->txt(
"user_awrn_default") .
" (" . $default .
")",
225 "n" => $this->
lng->txt(
"user_awrn_show"),
226 "y" => $this->
lng->txt(
"user_awrn_hide")
228 $val = $this->
user->prefs[
"hide_own_online_status"] ??
"";
233 $fields[
"hide_own_online_status"] = $this->uiFactory->input()
236 $this->
lng->txt(
"awrn_user_show"),
238 $this->
lng->txt(
"awrn_hide_from_awareness_info")
243 $this->
settings->get(
'usr_settings_disable_hide_own_online_status',
'0') ===
'1' ?
true : false
246 $formSections[
'awrn_sec'] = $this->uiFactory->input()->field()->section($fields, $this->
lng->txt(
'obj_awra'));
252 if (!$this->isContactSettingVisible()) {
256 $this->
lng->loadLanguageModule(
'buddysystem');
257 $bs_allow_contact_me = isset($this->
user->prefs[
'bs_allow_to_contact_me']) ?
258 $this->
user->prefs[
'bs_allow_to_contact_me'] ===
'y' :
false;
259 $fields[
"bs_allow_to_contact_me"] = $this->uiFactory->input()
262 $this->
lng->txt(
"buddy_allow_to_contact_me"),
263 $this->lng->txt(
"buddy_allow_to_contact_me_info")
265 ->withValue($bs_allow_contact_me)
267 $this->
settings->get(
'usr_settings_disable_bs_allow_to_contact_me',
'0') ===
'1' ?
true :
false
270 $formSections[
'contacts_sec'] = $this->uiFactory->input()->field()->section($fields, $this->
lng->txt(
'mm_contacts'));
278 if (!$this->shouldDisplayNotificationSection()) {
284 if ($this->shouldShowNotificationOptions()) {
285 $this->
lng->loadLanguageModule(
'notifications_adm');
286 $fields[self::PROP_ENABLE_SOUND] = $this->uiFactory->input()->field()
287 ->checkbox($this->
lng->txt(
'osd_play_sound'), $this->lng->txt(
'osd_play_sound_desc'))
288 ->withValue((
bool) $this->
user->getPref(
'osd_play_sound'));
291 if ($fields !== []) {
292 $formSections[
'notification_sec'] = $this->uiFactory->input()->field()->section(
294 $this->
lng->txt(
'notification_settings')
302 if (!$this->shouldDisplayChatSection()) {
306 $fieldFactory = $this->uiFactory->input()->field();
309 $this->
lng->loadLanguageModule(
'chatroom_adm');
310 $checkboxStateToBooleanTrafo = $this->
refinery->custom()->transformation(
static function ($v) {
319 return $v ===
'checked';
322 if ($this->shouldShowOnScreenChatOptions()) {
323 $oscAvailable = $this->
settings->get(
'usr_settings_disable_chat_osc_accept_msg',
'0') ===
'1' ?
true :
false;
324 $oscSubFormGroup = [];
326 if ($this->chatSettings->get(
'enable_browser_notifications',
'0')) {
327 $enabledBrowserNotifications = $fieldFactory
329 $this->
lng->txt(
'osc_enable_browser_notifications_label'),
331 $this->
lng->txt(
'osc_enable_browser_notifications_info'),
332 (
int) $this->chatSettings->get(
'conversation_idle_state_in_minutes')
335 ->withAdditionalTransformation($checkboxStateToBooleanTrafo)
336 ->withDisabled($oscAvailable);
338 $oscSubFormGroup[self::PROP_ENABLE_BROWSER_NOTIFICATIONS] = $enabledBrowserNotifications;
343 self::PROP_ENABLE_BROWSER_NOTIFICATIONS =>
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_osc_browser_notifications')),
346 $enabledOsc = $fieldFactory
349 $this->
lng->txt(
'chat_osc_accept_msg'),
350 $this->lng->txt(
'chat_osc_accept_msg_info')
352 ->withAdditionalTransformation($checkboxStateToBooleanTrafo)
353 ->withDisabled($oscAvailable)
354 ->withValue($groupValue);
356 $enabledOsc = $fieldFactory
358 $this->
lng->txt(
'chat_osc_accept_msg'),
359 $this->lng->txt(
'chat_osc_accept_msg_info')
361 ->withAdditionalTransformation($checkboxStateToBooleanTrafo)
362 ->withDisabled($oscAvailable)
363 ->withValue(
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_osc_accept_msg')));
366 $fields[self::PROP_ENABLE_OSC] = $enabledOsc;
369 if ($this->shouldShowChatTypingBroadcastOption()) {
370 $fields[self::PROP_ENABLE_BROADCAST_TYPING] = $fieldFactory
371 ->checkbox($this->
lng->txt(
'chat_broadcast_typing'), $this->lng->txt(
'chat_broadcast_typing_info'))
372 ->withAdditionalTransformation($checkboxStateToBooleanTrafo)
373 ->withValue(
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_broadcast_typing')));
376 if ($fields !== []) {
377 $formSections[
'chat_sec'] = $this->uiFactory->input()->field()->section(
379 $this->
lng->txt(
'chat_settings')
386 $request = $this->request;
387 $form = $this->initPrivacySettingsForm();
392 if ($request->getMethod() ===
"POST") {
393 $form = $form->withRequest($request);
394 $formData = $form->getData();
396 if ($this->isAwarnessSettingVisible() && $this->workWithUserSetting(
"hide_own_online_status")) {
397 $val = $formData[
"hide_own_online_status"] ??
'x';
402 "hide_own_online_status",
406 if ($this->isContactSettingVisible() && $this->workWithUserSetting(
"bs_allow_to_contact_me")) {
407 if ($formData[
"bs_allow_to_contact_me"]) {
408 $user->
setPref(
"bs_allow_to_contact_me",
"y");
410 $user->
setPref(
"bs_allow_to_contact_me",
"n");
416 if ($this->shouldDisplayNotificationSection()) {
417 if ($this->shouldShowNotificationOptions()) {
418 $oldPlaySoundValue = (
int) $this->
user->getPref(
'osd_play_sound');
419 $playASound = (
int) ($formData[self::PROP_ENABLE_SOUND] ?? 0);
421 if ($oldPlaySoundValue !== $playASound) {
422 $this->
user->setPref(
'osd_play_sound', (
string) $playASound);
427 if ($this->shouldDisplayChatSection()) {
428 $preferencesUpdated =
false;
430 if ($this->shouldShowOnScreenChatOptions()) {
431 $oldEnableOscValue =
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_osc_accept_msg'));
432 $enableOsc = $formData[self::PROP_ENABLE_OSC] ??
null;
433 if (!is_bool($enableOsc)) {
434 $enableOsc = is_array($enableOsc);
437 if ($this->
settings->get(
'usr_settings_disable_chat_osc_accept_msg',
'0') !==
'1') {
438 $preferencesUpdated =
true;
439 if ($oldEnableOscValue !== $enableOsc) {
441 $preferencesUpdated =
true;
445 if ($enableOsc && $this->chatSettings->get(
'enable_browser_notifications',
'0')) {
446 $oldBrowserNotificationValue =
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_osc_browser_notifications'));
448 $sendBrowserNotifications =
false;
449 if (is_array($formData[self::PROP_ENABLE_OSC]) &&
450 true === $formData[self::PROP_ENABLE_OSC][self::PROP_ENABLE_BROWSER_NOTIFICATIONS]) {
451 $sendBrowserNotifications =
true;
454 if ($oldBrowserNotificationValue !== $sendBrowserNotifications) {
455 $this->
user->setPref(
456 'chat_osc_browser_notifications',
459 $preferencesUpdated =
true;
464 if ($this->shouldShowChatTypingBroadcastOption()) {
465 $oldBroadcastTypingValue =
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_broadcast_typing'));
466 $broadcastTyping = (bool) ($formData[self::PROP_ENABLE_BROADCAST_TYPING] ??
false);
468 if ($oldBroadcastTypingValue !== $broadcastTyping) {
470 $preferencesUpdated =
true;
474 if ($preferencesUpdated) {
475 $this->
user->writePrefs();
479 'chatSettingsChanged',
481 'user' => $this->
user
488 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
'msg_obj_modified'),
true);
492 $this->showPrivacySettings($form);
499 if ($this->shouldShowOnScreenChatOptions() && $this->chatSettings->get(
'enable_browser_notifications',
'0')) {
500 $pageTemplate->
addJavaScript(
'./Services/Notifications/js/browser_notifications.js');
503 $tpl->setVariable(
'BROWSER_NOTIFICATION_TOGGLE_LABEL', $this->
lng->txt(
'osc_enable_browser_notifications_label'));
505 $this->
lng->toJSMap([
506 'osc_browser_noti_no_permission_error' => $this->
lng->txt(
'osc_browser_noti_no_permission_error'),
507 'osc_browser_noti_no_support_error' => $this->lng->txt(
'osc_browser_noti_no_support_error'),
508 'osc_browser_noti_req_permission_error' => $this->lng->txt(
'osc_browser_noti_req_permission_error'),
static return function(ContainerConfigurator $containerConfigurator)
Class ilCtrl provides processing control methods.
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
@inheritDoc
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setPref(string $a_keyword, ?string $a_value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const STEP_VISIBILITY_OPTIONS
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
User privacy settings (currently located under "Profile and Privacy")
ILIAS Refinery Factory $refinery
shouldShowOnScreenChatOptions()
shouldDisplayChatSection()
shouldShowChatTypingBroadcastOption()
ILIAS UI Factory $uiFactory
ilUserSettingsConfig $user_settings_config
userSettingVisible(string $setting)
appendChatJsToTemplate(ilGlobalTemplateInterface $pageTemplate)
ilPersonalProfileMode $profile_mode
populateWithChatSettingsSection(array &$formSections)
initPrivacySettingsForm()
Init form.
populateWithAwarenessSettingsSection(array &$formSections)
isAwarnessSettingVisible()
Is awareness tool setting visible.
workWithUserSetting(string $setting)
ilProfileChecklistStatus $checklist_status
shouldDisplayNotificationSection()
showPrivacySettings(\ILIAS\UI\Component\Input\Container\Form\Standard $form=null)
ilGlobalTemplateInterface $main_tpl
isContactSettingVisible()
Is contact setting visible.
const PROP_ENABLE_BROWSER_NOTIFICATIONS
Psr Http Message RequestInterface $request
ilSetting $notificationSettings
ILIAS UI Renderer $uiRenderer
const PROP_ENABLE_BROADCAST_TYPING
populateWithContactsSettingsSection(array &$formSections)
populateWithNotificationSettingsSection(array &$formSections)
shouldShowNotificationOptions()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static yn2tf(string $a_yn)
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
setContent(string $a_html)
Sets content for standard template.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.