85 $this->main_tpl = $DIC->ui()->mainTemplate();
86 $this->lng = $DIC->language();
87 $this->ctrl = $DIC->ctrl();
88 $this->lng->loadLanguageModule(
"user");
89 $this->
user = $DIC->user();
90 $this->refinery = $DIC->refinery();
91 $this->uiFactory = $DIC->ui()->factory();
92 $this->uiRenderer = $DIC->ui()->renderer();
93 $this->chatSettings =
new ilSetting(
'chatroom');
94 $this->notificationSettings =
new ilSetting(
'notifications');
95 $this->
event = $DIC->event();
97 $this->request = $DIC->http()->request();
110 $next_class = $this->ctrl->getNextClass();
112 switch ($next_class) {
114 $cmd = $this->ctrl->getCmd(
"showPrivacySettings");
118 $this->main_tpl->printToStdout();
134 return $this->user_settings_config->isVisibleAndChangeable($setting);
143 return $this->user_settings_config->isVisible($setting);
157 if ($this->checklist_status->anyVisibilitySettings()
161 if (is_null($form)) {
164 $html = $this->uiRenderer->render([$form]);
168 if ($this->profile_mode->isEnabled()) {
169 $pub_profile_legacy = $this->uiFactory->legacy($pub_profile->getEmbeddable());
170 $html .= $this->uiRenderer->render($this->uiFactory->panel()->standard(
171 $this->lng->txt(
'user_profile_preview'),
175 if (!$this->checklist_status->anyVisibilitySettings()) {
176 $html .= $this->uiRenderer->render(
177 [$this->uiFactory->messageBox()->info(
$lng->txt(
"usr_public_profile_disabled"))]
185 $main_tpl->setContent($html . $chat_tpl->get());
195 if ($awrn_set->get(
"awrn_enabled",
false) && $this->
userSettingVisible(
"hide_own_online_status")) {
225 $form_action = $this->ctrl->getLinkTarget($this,
"savePrivacySettings");
227 return $this->uiFactory->input()
230 ->standard($form_action, $sections)
231 ->withAdditionalTransformation($this->refinery->custom()->transformation(
static function ($values) : array {
232 return call_user_func_array(
'array_merge', $values);
242 $this->chatSettings->get(
'chat_enabled',
false) && (
254 $this->notificationSettings->get(
'enable_osd',
false) &&
255 $this->chatSettings->get(
'play_invitation_sound',
false)
265 $this->chatSettings->get(
'enable_osc',
false) &&
266 !(bool) $this->
settings->get(
'usr_settings_hide_chat_osc_accept_msg',
false)
279 $this->lng->loadLanguageModule(
"awrn");
281 $default = ($this->
settings->get(
'hide_own_online_status') ==
"n")
282 ? $this->lng->txt(
"user_awrn_show")
283 : $this->lng->txt(
"user_awrn_hide");
286 "x" => $this->lng->txt(
"user_awrn_default") .
" (" . $default .
")",
287 "n" => $this->lng->txt(
"user_awrn_show"),
288 "y" => $this->lng->txt(
"user_awrn_hide")
290 $val = $this->
user->prefs[
"hide_own_online_status"];
295 $fields[
"hide_own_online_status"] = $this->uiFactory->input()
298 $this->lng->txt(
"awrn_user_show"),
300 $this->lng->txt(
"awrn_hide_from_awareness_info")
305 $this->
settings->get(
'usr_settings_disable_hide_own_online_status',
'0') ===
'1' ? true : false
308 $formSections[
'awrn_sec'] = $this->uiFactory->input()->field()->section($fields, $this->lng->txt(
'obj_awra'));
320 $this->lng->loadLanguageModule(
'buddysystem');
321 $fields[
"bs_allow_to_contact_me"] = $this->uiFactory->input()
324 $this->lng->txt(
"buddy_allow_to_contact_me"),
325 $this->lng->txt(
"buddy_allow_to_contact_me_info")
327 ->withValue($this->
user->prefs[
'bs_allow_to_contact_me'] ==
'y')
329 $this->
settings->get(
'usr_settings_disable_bs_allow_to_contact_me',
'0') ===
'1' ? true : false
332 $formSections[
'contacts_sec'] = $this->uiFactory->input()->field()->section($fields, $this->lng->txt(
'mm_contacts'));
344 $fieldFactory = $this->uiFactory->input()->field();
347 $this->lng->loadLanguageModule(
'chatroom_adm');
348 $checkboxStateToBooleanTrafo = $this->refinery->custom()->transformation(
static function ($v) {
357 return $v ===
'checked';
361 $oscAvailable = $this->
settings->get(
'usr_settings_disable_chat_osc_accept_msg',
'0') ===
'1' ? true :
false;
362 $oscSubFormGroup = [];
364 if ($this->chatSettings->get(
'enable_browser_notifications',
false)) {
365 $enabledBrowserNotifications = $fieldFactory
367 $this->lng->txt(
'osc_enable_browser_notifications_label'),
369 $this->lng->txt(
'osc_enable_browser_notifications_info'),
370 (int) $this->chatSettings->get(
'conversation_idle_state_in_minutes')
373 ->withAdditionalTransformation($checkboxStateToBooleanTrafo)
374 ->withDisabled($oscAvailable);
376 $oscSubFormGroup[self::PROP_ENABLE_BROWSER_NOTIFICATIONS] = $enabledBrowserNotifications;
381 self::PROP_ENABLE_BROWSER_NOTIFICATIONS =>
ilUtil::yn2tf($this->
user->getPref(
'chat_osc_browser_notifications')),
384 $enabledOsc = $fieldFactory
387 $this->lng->txt(
'chat_osc_accept_msg'),
388 $this->lng->txt(
'chat_osc_accept_msg_info')
390 ->withAdditionalTransformation($checkboxStateToBooleanTrafo)
391 ->withDisabled($oscAvailable)
392 ->withValue($groupValue);
394 $enabledOsc = $fieldFactory
396 $this->lng->txt(
'chat_osc_accept_msg'),
397 $this->lng->txt(
'chat_osc_accept_msg_info')
399 ->withAdditionalTransformation($checkboxStateToBooleanTrafo)
400 ->withDisabled($oscAvailable)
404 $fields[self::PROP_ENABLE_OSC] = $enabledOsc;
408 $fields[self::PROP_ENABLE_SOUND] = $fieldFactory
409 ->checkbox($this->lng->txt(
'play_invitation_sound'), $this->lng->txt(
'play_invitation_sound_info'))
410 ->withAdditionalTransformation($checkboxStateToBooleanTrafo)
411 ->withValue((
bool) $this->
user->getPref(
'chat_play_invitation_sound'));
414 $formSections[
'chat_sec'] = $this->uiFactory->input()->field()->section($fields, $this->lng->txt(
'chat_settings'));
428 if (
$request->getMethod() ==
"POST") {
429 $form = $form->withRequest(
$request);
430 $formData = $form->getData();
433 $val = $formData[
"hide_own_online_status"] ??
'x';
438 "hide_own_online_status",
443 if ($formData[
"bs_allow_to_contact_me"]) {
444 $user->setPref(
"bs_allow_to_contact_me",
"y");
446 $user->setPref(
"bs_allow_to_contact_me",
"n");
453 $preferencesUpdated =
false;
456 $oldPlaySoundValue = (int) $this->
user->getPref(
'chat_play_invitation_sound');
457 $playASound = (int) ($formData[self::PROP_ENABLE_SOUND] ?? 0);
459 if ($oldPlaySoundValue !== $playASound) {
460 $this->
user->setPref(
'chat_play_invitation_sound', $playASound);
461 $preferencesUpdated =
true;
467 $enableOsc = $formData[self::PROP_ENABLE_OSC] ?? null;
468 if (!is_bool($enableOsc)) {
469 $enableOsc = is_array($enableOsc);
472 if ($this->
settings->get(
'usr_settings_disable_chat_osc_accept_msg',
'0') !==
'1') {
473 $preferencesUpdated =
true;
474 if ($oldEnableOscValue !== $enableOsc) {
476 $preferencesUpdated =
true;
480 if ($this->chatSettings->get(
'enable_browser_notifications',
false) && $enableOsc) {
481 $oldBrowserNotificationValue =
ilUtil::yn2tf($this->
user->getPref(
'chat_osc_browser_notifications'));
483 $sendBrowserNotifications =
false;
484 if (is_array($formData[self::PROP_ENABLE_OSC])) {
485 if (
true === $formData[self::PROP_ENABLE_OSC][self::PROP_ENABLE_BROWSER_NOTIFICATIONS]) {
486 $sendBrowserNotifications =
true;
490 if ($oldBrowserNotificationValue !== $sendBrowserNotifications) {
491 $this->
user->setPref(
492 'chat_osc_browser_notifications',
495 $preferencesUpdated =
true;
500 if ($preferencesUpdated) {
501 $this->
user->writePrefs();
505 'chatSettingsChanged',
507 'user' => $this->
user 514 ilUtil::sendSuccess(
$lng->txt(
'msg_obj_modified'),
true);
515 $ctrl->redirect($this,
'');
527 $tpl =
new ilTemplate(
'tpl.personal_chat_settings_form.html',
true,
true,
'Modules/Chatroom');
529 $pageTemplate->addJavascript(
'./Services/Notifications/js/browser_notifications.js');
532 $tpl->setVariable(
'BROWSER_NOTIFICATION_TOGGLE_LABEL', $this->lng->txt(
'osc_enable_browser_notifications_label'));
534 $this->lng->toJSMap([
535 'osc_browser_noti_no_permission_error' => $this->lng->txt(
'osc_browser_noti_no_permission_error'),
536 'osc_browser_noti_no_support_error' => $this->lng->txt(
'osc_browser_noti_no_support_error'),
537 'osc_browser_noti_req_permission_error' => $this->lng->txt(
'osc_browser_noti_req_permission_error'),
initPrivacySettingsForm()
Init form.
Personal profile publishing mode of a iser.
static tf2yn($a_tf)
convert true/false to "y"/"n"
populateWithContactsSettingsSection(array &$formSections)
shouldDisplayChatSection()
workWithUserSetting(string $setting)
shouldShowNotificationOptions()
isAwarnessSettingVisible()
Is awareness tool setting visible.
populateWithAwarenessSettingsSection(array &$formSections)
executeCommand()
execute command
GUI class for public user profile presentation.
Class ilGlobalPageTemplate.
userSettingVisible(string $setting)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
const STEP_VISIBILITY_OPTIONS
savePrivacySettings()
Save privacy settings.
shouldShowOnScreenChatOptions()
showPrivacySettings($form=null)
General settings form.
const PROP_ENABLE_BROWSER_NOTIFICATIONS
populateWithChatSettingsSection(array &$formSections)
User settings configuration (what preferences can be visible/changed/...)
User privacy settings (currently located under "Profile and Privacy")
static yn2tf($a_yn)
convert "y"/"n" to true/false
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
isContactSettingVisible()
Is contact setting visible.
appendChatJsToTemplate(ilGlobalPageTemplate $pageTemplate)