19 declare(strict_types=1);
44 protected \Psr\Http\Message\RequestInterface
$request;
58 $this->main_tpl = $DIC[
'tpl'];
59 $this->
lng = $DIC[
'lng'];
60 $this->
ctrl = $DIC[
'ilCtrl'];
61 $this->
user = $DIC[
'ilUser'];
63 $this->uiFactory = $DIC[
'ui.factory'];
64 $this->uiRenderer = $DIC[
'ui.renderer'];
65 $this->
event = $DIC[
'ilAppEventHandler'];
66 $this->request = $DIC->http()->request();
68 $this->chatSettings =
new ilSetting(
'chatroom');
69 $this->notificationSettings =
new ilSetting(
'notifications');
73 $this->profile_mode =
new ProfileMode($this->
lng, $this->
settings, $this->
user);
81 $this->
lng->loadLanguageModule(
'user');
86 $next_class = $this->
ctrl->getNextClass();
88 switch ($next_class) {
90 $cmd = $this->
ctrl->getCmd(
"showPrivacySettings");
94 $this->main_tpl->printToStdout();
106 return $this->user_settings_config->isVisibleAndChangeable($setting);
111 return $this->user_settings_config->isVisible($setting);
122 if ($this->checklist_status->anyVisibilitySettings()
126 if (is_null($form)) {
129 $html = $this->uiRenderer->render([$form]);
133 if ($this->profile_mode->isEnabled()) {
134 $pub_profile_legacy = $this->uiFactory->legacy($pub_profile->getEmbeddable());
135 $html .= $this->uiRenderer->render($this->uiFactory->panel()->standard(
136 $this->
lng->txt(
'user_profile_preview'),
139 } elseif (!$this->checklist_status->anyVisibilitySettings()) {
140 $html .= $this->uiRenderer->render(
141 [$this->uiFactory->messageBox()->info($lng->
txt(
"usr_public_profile_disabled"))]
148 $main_tpl->
setContent($html . $chat_tpl->get());
158 return $awrn_set->get(
"awrn_enabled",
'0') && $this->
userSettingVisible(
"hide_own_online_status");
181 $form_action = $this->
ctrl->getLinkTarget($this,
"savePrivacySettings");
183 return $this->uiFactory->input()
186 ->standard($form_action, $sections)
187 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
static function (array $values): array {
188 return array_merge(...array_values($values));
195 $this->chatSettings->get(
'enable_osc',
'0') &&
196 !$this->
settings->get(
'usr_settings_hide_chat_osc_accept_msg',
'0')
203 !$this->
settings->get(
'usr_settings_hide_chat_broadcast_typing',
'0')
209 return (
bool) $this->chatSettings->get(
'chat_enabled',
'0');
214 return (
bool) $this->notificationSettings->get(
'osd_play_sound',
'0');
219 return (
bool) $this->notificationSettings->get(
'enable_osd',
'0');
229 $this->
lng->loadLanguageModule(
"awrn");
231 $default = ($this->
settings->get(
'hide_own_online_status') ===
"n")
232 ? $this->
lng->txt(
"user_awrn_show")
233 : $this->
lng->txt(
"user_awrn_hide");
236 "x" => $this->
lng->txt(
"user_awrn_default") .
" (" . $default .
")",
237 "n" => $this->
lng->txt(
"user_awrn_show"),
238 "y" => $this->
lng->txt(
"user_awrn_hide")
240 $val = $this->
user->prefs[
"hide_own_online_status"] ??
"";
245 $fields[
"hide_own_online_status"] = $this->uiFactory->input()
248 $this->
lng->txt(
"awrn_user_show"),
250 $this->
lng->txt(
"awrn_hide_from_awareness_info")
255 $this->
settings->get(
'usr_settings_disable_hide_own_online_status',
'0') ===
'1' ? true : false
258 $formSections[
'awrn_sec'] = $this->uiFactory->input()->field()->section($fields, $this->
lng->txt(
'obj_awra'));
268 $this->
lng->loadLanguageModule(
'buddysystem');
269 $bs_allow_contact_me = isset($this->
user->prefs[
'bs_allow_to_contact_me']) ?
270 $this->
user->prefs[
'bs_allow_to_contact_me'] ===
'y' :
false;
271 $fields[
"bs_allow_to_contact_me"] = $this->uiFactory->input()
274 $this->
lng->txt(
"buddy_allow_to_contact_me"),
275 $this->
lng->txt(
"buddy_allow_to_contact_me_info")
279 $this->
settings->get(
'usr_settings_disable_bs_allow_to_contact_me',
'0') ===
'1' ? true : false
282 $formSections[
'contacts_sec'] = $this->uiFactory->input()->field()->section($fields, $this->
lng->txt(
'mm_contacts'));
297 $this->
lng->loadLanguageModule(
'notifications_adm');
298 $fields[self::PROP_ENABLE_SOUND] = $this->uiFactory->input()->field()
299 ->checkbox($this->
lng->txt(
'osd_play_sound'), $this->
lng->txt(
'osd_play_sound_desc'))
303 if ($fields !== []) {
304 $formSections[
'notification_sec'] = $this->uiFactory->input()->field()->section(
306 $this->
lng->txt(
'notification_settings')
318 $fieldFactory = $this->uiFactory->input()->field();
321 $this->
lng->loadLanguageModule(
'chatroom_adm');
322 $checkboxStateToBooleanTrafo = $this->
refinery->custom()->transformation(
static function ($v) {
331 return $v ===
'checked';
335 $oscAvailable = $this->
settings->get(
'usr_settings_disable_chat_osc_accept_msg',
'0') ===
'1' ? true :
false;
336 $oscSubFormGroup = [];
338 if ($this->chatSettings->get(
'enable_browser_notifications',
'0')) {
339 $enabledBrowserNotifications = $fieldFactory
341 $this->
lng->txt(
'osc_enable_browser_notifications_label'),
343 $this->
lng->txt(
'osc_enable_browser_notifications_info'),
344 (
int) $this->chatSettings->get(
'conversation_idle_state_in_minutes')
347 ->withAdditionalTransformation($checkboxStateToBooleanTrafo)
348 ->withDisabled($oscAvailable);
350 $oscSubFormGroup[self::PROP_ENABLE_BROWSER_NOTIFICATIONS] = $enabledBrowserNotifications;
355 self::PROP_ENABLE_BROWSER_NOTIFICATIONS =>
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_osc_browser_notifications')),
358 $enabledOsc = $fieldFactory
361 $this->
lng->txt(
'chat_osc_accept_msg'),
362 $this->
lng->txt(
'chat_osc_accept_msg_info')
365 ->withDisabled($oscAvailable)
366 ->withValue($groupValue);
368 $enabledOsc = $fieldFactory
370 $this->
lng->txt(
'chat_osc_accept_msg'),
371 $this->
lng->txt(
'chat_osc_accept_msg_info')
374 ->withDisabled($oscAvailable)
375 ->withValue(
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_osc_accept_msg')));
378 $fields[self::PROP_ENABLE_OSC] = $enabledOsc;
382 $fields[self::PROP_ENABLE_BROADCAST_TYPING] = $fieldFactory
383 ->checkbox($this->
lng->txt(
'chat_broadcast_typing'), $this->
lng->txt(
'chat_broadcast_typing_info'))
385 ->withValue(
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_broadcast_typing')));
388 if ($fields !== []) {
389 $formSections[
'chat_sec'] = $this->uiFactory->input()->field()->section(
391 $this->
lng->txt(
'chat_settings')
404 if ($request->getMethod() ===
"POST") {
405 $form = $form->withRequest($request);
406 $formData = $form->getData();
409 $val = $formData[
"hide_own_online_status"] ??
'x';
414 "hide_own_online_status",
419 if ($formData[
"bs_allow_to_contact_me"]) {
420 $user->
setPref(
"bs_allow_to_contact_me",
"y");
422 $user->
setPref(
"bs_allow_to_contact_me",
"n");
430 $oldPlaySoundValue = (
int) $this->
user->getPref(
'osd_play_sound');
431 $playASound = (
int) ($formData[self::PROP_ENABLE_SOUND] ?? 0);
433 if ($oldPlaySoundValue !== $playASound) {
434 $this->
user->setPref(
'osd_play_sound', (
string) $playASound);
440 $preferencesUpdated =
false;
443 $oldEnableOscValue =
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_osc_accept_msg'));
444 $enableOsc = $formData[self::PROP_ENABLE_OSC] ?? null;
445 if (!is_bool($enableOsc)) {
446 $enableOsc = is_array($enableOsc);
449 if ($this->
settings->get(
'usr_settings_disable_chat_osc_accept_msg',
'0') !==
'1') {
450 $preferencesUpdated =
true;
451 if ($oldEnableOscValue !== $enableOsc) {
453 $preferencesUpdated =
true;
457 if ($enableOsc && $this->chatSettings->get(
'enable_browser_notifications',
'0')) {
458 $oldBrowserNotificationValue =
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_osc_browser_notifications'));
460 $sendBrowserNotifications =
false;
461 if (is_array($formData[self::PROP_ENABLE_OSC]) &&
462 true === $formData[self::PROP_ENABLE_OSC][self::PROP_ENABLE_BROWSER_NOTIFICATIONS]) {
463 $sendBrowserNotifications =
true;
466 if ($oldBrowserNotificationValue !== $sendBrowserNotifications) {
467 $this->
user->setPref(
468 'chat_osc_browser_notifications',
471 $preferencesUpdated =
true;
477 $oldBroadcastTypingValue =
ilUtil::yn2tf((
string) $this->
user->getPref(
'chat_broadcast_typing'));
478 $broadcastTyping = (bool) ($formData[self::PROP_ENABLE_BROADCAST_TYPING] ??
false);
480 if ($oldBroadcastTypingValue !== $broadcastTyping) {
482 $preferencesUpdated =
true;
486 if ($preferencesUpdated) {
487 $this->
user->writePrefs();
490 'components/ILIAS/Chatroom',
491 'chatSettingsChanged',
493 'user' => $this->
user 499 $this->checklist_status->saveStepSucess(ChecklistStatus::STEP_VISIBILITY_OPTIONS);
500 $this->main_tpl->setOnScreenMessage(
'success', $lng->
txt(
'msg_obj_modified'),
true);
510 $tpl =
new ilTemplate(
'tpl.personal_chat_settings_form.html',
true,
true,
'components/ILIAS/Chatroom');
512 $pageTemplate->
addJavaScript(
'assets/js/browser_notifications.js');
515 $tpl->setVariable(
'BROWSER_NOTIFICATION_TOGGLE_LABEL', $this->
lng->txt(
'osc_enable_browser_notifications_label'));
517 $this->
lng->toJSMap([
518 'osc_browser_noti_no_permission_error' => $this->
lng->txt(
'osc_browser_noti_no_permission_error'),
519 'osc_browser_noti_no_support_error' => $this->
lng->txt(
'osc_browser_noti_no_support_error'),
520 'osc_browser_noti_req_permission_error' => $this->
lng->txt(
'osc_browser_noti_req_permission_error'),
initPrivacySettingsForm()
Init form.
populateWithContactsSettingsSection(array &$formSections)
shouldDisplayChatSection()
ilSetting $notificationSettings
ILIAS UI Factory $uiFactory
appendChatJsToTemplate(ilGlobalTemplateInterface $pageTemplate)
Personal profile publishing mode of a user.
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
workWithUserSetting(string $setting)
shouldShowNotificationOptions()
populateWithNotificationSettingsSection(array &$formSections)
ilUserSettingsConfig $user_settings_config
showPrivacySettings(\ILIAS\UI\Component\Input\Container\Form\Standard $form=null)
ProfileMode $profile_mode
isAwarnessSettingVisible()
Is awareness tool setting visible.
populateWithAwarenessSettingsSection(array &$formSections)
const PROP_ENABLE_BROADCAST_TYPING
ILIAS UI Renderer $uiRenderer
ILIAS Refinery Factory $refinery
GUI class for public user profile presentation.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
shouldDisplayNotificationSection()
shouldShowChatTypingBroadcastOption()
setContent(string $a_html)
Sets content for standard template.
userSettingVisible(string $setting)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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.
setPref(string $a_keyword, ?string $a_value)
shouldShowOnScreenChatOptions()
ilGlobalTemplateInterface $main_tpl
ChecklistStatus $checklist_status
const PROP_ENABLE_BROWSER_NOTIFICATIONS
populateWithChatSettingsSection(array &$formSections)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static yn2tf(string $a_yn)
isContactSettingVisible()
Is contact setting visible.
Psr Http Message RequestInterface $request