ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
BroadcastTyping.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29use ILIAS\Refinery\Factory as Refinery;
30
32{
33 public function getIdentifier(): string
34 {
35 return 'chat_broadcast_typing';
36 }
37
38 public function isAvailable(): bool
39 {
40 return (new \ilSetting('chatroom'))->get('chat_enabled', '0') === '1';
41 }
42
43 public function getLabel(Language $lng): string
44 {
45 return $lng->txt($this->getIdentifier());
46 }
47
49 {
50 return AvailablePages::PrivacySettings;
51 }
52
53 public function getSection(): AvailableSections
54 {
55 return AvailableSections::Main;
56 }
57
58 public function getInput(
59 FieldFactory $field_factory,
62 \ilSetting $settings,
63 ?\ilObjUser $user = null
64 ): Input {
65 $lng->loadLanguageModule('chatroom_adm');
66
67 return $field_factory->checkbox(
68 $lng->txt('chat_broadcast_typing'),
69 $lng->txt('chat_broadcast_typing_info')
70 )->withValue(
71 $user !== null
72 ? $user->getPref('chat_broadcast_typing') === 'y'
73 : $settings->get('chat_broadcast_typing') === 'y'
74 );
75 }
76
77 public function getLegacyInput(
79 \ilSetting $settings,
80 ?\ilObjUser $user = null
82 $lng->loadLanguageModule('chatroom_adm');
83
84 $input = new \ilCheckboxInputGUI($lng->txt('chat_broadcast_typing'));
85 $input->setInfo($lng->txt('chat_broadcast_typing_info'));
86 $input->setChecked(
87 $user !== null
88 ? $user->getPref('chat_broadcast_typing') === 'y'
89 : $settings->get('chat_broadcast_typing') === 'y'
90 );
91
92 return $input;
93 }
94
97 \ilSetting $settings
98 ): string {
99 return $settings->get($this->getIdentifier()) === 'y'
100 ? $lng->txt('chat_use_typing_broadcast')
101 : $lng->txt('chat_no_use_typing_broadcast');
102 }
103
105 \ilSetting $settings,
106 \ilObjUser $user
107 ): bool {
108 return $this->retrieveValueFromUser($user) !== $settings->get($this->getIdentifier());
109 }
110
111 public function persistUserInput(
112 \ilObjUser $user,
113 mixed $input
114 ): \ilObjUser {
115 if ($input === null) {
116 $user->deletePref($this->getIdentifier());
117
118 return $user;
119 }
120
121 $user->setPref($this->getIdentifier(), $input ? 'y' : 'n');
122
123 return $user;
124 }
125
126 public function retrieveValueFromUser(\ilObjUser $user): ?bool
127 {
128 $value = $user->getPref($this->getIdentifier());
129
130 return $value !== null ? $value === 'y' : null;
131 }
132}
getInput(FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
getDefaultValueForDisplay(Language $lng, \ilSetting $settings)
getLegacyInput(Language $lng, \ilSetting $settings, ?\ilObjUser $user=null)
You don't need to add a post_var to the input as the User will handle this for you,...
persistUserInput(\ilObjUser $user, mixed $input)
hasUserPersonalizedSetting(\ilSetting $settings, \ilObjUser $user)
isAvailable()
If this function returns false the setting will not be shown, even if it's PropertyAttributes would a...
Builds data types.
Definition: Factory.php:36
This class represents a property in a property form.
User class.
setPref(string $a_keyword, ?string $a_value)
getPref(string $a_keyword)
deletePref(string $keyword)
ILIAS Setting Class.
get(string $a_keyword, ?string $a_default_value=null)
get setting
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is what a factory for input fields looks like.
Definition: Factory.php:31
This describes commonalities between all inputs.
Definition: Input.php:47
get(string $class_name)
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))