ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations Class Reference
+ Inheritance diagram for ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations:
+ Collaboration diagram for ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations:

Public Member Functions

 getIdentifier ()
 
 isAvailable ()
 If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be. More...
 
 getLabel (Language $lng)
 
 getSettingsPage ()
 
 getSection ()
 
 getInput (FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
 
 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, thus you can also not rely on the post_var anywhere else, as it will be changed. More...
 
 getDefaultValueForDisplay (Language $lng, \ilSetting $settings)
 
 hasUserPersonalizedSetting (\ilSetting $settings, \ilObjUser $user)
 
 persistUserInput (\ilObjUser $user, mixed $input)
 
 retrieveValueFromUser (\ilObjUser $user)
 
 isAvailable ()
 If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be. More...
 
 getSettingsPage ()
 
 getDefaultValueForDisplay (Language $lng, \ilSetting $settings)
 
 hasUserPersonalizedSetting (\ilSetting $settings, \ilObjUser $user)
 
 getInput (FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
 
 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, thus you can also not rely on the post_var anywhere else, as it will be changed. More...
 
 persistUserInput (\ilObjUser $user, mixed $input)
 
 getIdentifier ()
 
 getLabel (Language $lng)
 
 getSection ()
 
 retrieveValueFromUser (\ilObjUser $user)
 

Private Member Functions

 buildValueForNotificationGroup (\ilSetting $settings, ?\ilObjUser $user)
 
 updateChatServer (int $user_id, bool $osc_state)
 

Private Attributes

const string KEY_ENABLE_BROWSER_NOTIFICATIONS = 'chat_osc_browser_notifications'
 

Detailed Description

Definition at line 31 of file AllowOnScreenChatConversations.php.

Member Function Documentation

◆ buildValueForNotificationGroup()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::buildValueForNotificationGroup ( \ilSetting  $settings,
?\ilObjUser  $user 
)
private

Definition at line 178 of file AllowOnScreenChatConversations.php.

181 : ?array {
182 $active = $settings->get($this->getIdentifier()) === 'y';
183 $notification = false;
184 if ($user !== null) {
185 $active = $user->getPref($this->getIdentifier()) === 'y';
186 $notification = $user->getPref(self::KEY_ENABLE_BROWSER_NOTIFICATIONS) === 'y';
187 }
188
189 if ($active === false) {
190 return null;
191 }
192
193 return [
194 self::KEY_ENABLE_BROWSER_NOTIFICATIONS => $notification
195 ];
196 }

References ilObjUser\getPref().

+ Here is the call graph for this function:

◆ getDefaultValueForDisplay()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::getDefaultValueForDisplay ( Language  $lng,
\ilSetting  $settings 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 117 of file AllowOnScreenChatConversations.php.

120 : string {
121 return $lng->txt('chat_osc_accepts_messages_no');
122 }
global $lng
Definition: privfeed.php:31

◆ getIdentifier()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::getIdentifier ( )

Implements ILIAS\User\Property.

Definition at line 35 of file AllowOnScreenChatConversations.php.

35 : string
36 {
37 return 'chat_osc_accept_msg';
38 }

◆ getInput()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::getInput ( FieldFactory  $field_factory,
Language  $lng,
Refinery  $refinery,
\ilSetting  $settings,
?\ilObjUser  $user = null 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 60 of file AllowOnScreenChatConversations.php.

66 : Input {
67 $chat_settings = new \ilSetting('chatroom');
68 $lng->loadLanguageModule('chatroom_adm');
69
70 if ($chat_settings->get('enable_browser_notifications', '0') !== '1') {
71 return $field_factory->checkbox(
72 $lng->txt('chat_osc_accept_msg'),
73 $lng->txt('chat_osc_accept_msg_info')
74 )->withValue(
75 $user !== null
76 ? $user->getPref('chat_osc_accept_msg') === 'y'
77 : $settings->get('chat_osc_accept_msg') === 'y'
78 );
79 }
80
81 return $field_factory->optionalGroup(
82 [
83 self::KEY_ENABLE_BROWSER_NOTIFICATIONS => $field_factory->checkbox(
84 $lng->txt('osc_enable_browser_notifications_label'),
85 \sprintf(
86 $lng->txt('osc_enable_browser_notifications_info'),
87 (int) $chat_settings->get('conversation_idle_state_in_minutes')
88 )
89 )->withDisabled(
90 $settings->get('usr_settings_disable_chat_osc_accept_msg', '0') === '1'
91 )
92 ],
93 $lng->txt('chat_osc_accept_msg'),
94 $lng->txt('chat_osc_accept_msg_info')
95 )->withValue(
96 $this->buildValueForNotificationGroup($settings, $user)
97 );
98 }

References $lng, and ilSetting\get().

+ Here is the call graph for this function:

◆ getLabel()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::getLabel ( Language  $lng)

Implements ILIAS\User\Property.

Definition at line 45 of file AllowOnScreenChatConversations.php.

45 : string
46 {
47 return $lng->txt('chat_osc_accept_msg');
48 }

References $lng.

◆ getLegacyInput()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::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, thus you can also not rely on the post_var anywhere else, as it will be changed.

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 100 of file AllowOnScreenChatConversations.php.

105 $lng->loadLanguageModule('chatroom');
106
107 $input = new \ilCheckboxInputGUI($lng->txt('chat_osc_accept_msg'));
108 $input->setChecked(
109 $user !== null
110 ? $user->getPref('chat_osc_accept_msg') === 'y'
111 : $settings->get('chat_osc_accept_msg') === 'y'
112 );
113
114 return $input;
115 }
This class represents a property in a property form.

◆ getSection()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::getSection ( )

Implements ILIAS\User\Property.

Definition at line 55 of file AllowOnScreenChatConversations.php.

56 {
57 return AvailableSections::Main;
58 }

◆ getSettingsPage()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::getSettingsPage ( )

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 50 of file AllowOnScreenChatConversations.php.

51 {
52 return AvailablePages::PrivacySettings;
53 }

◆ hasUserPersonalizedSetting()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::hasUserPersonalizedSetting ( \ilSetting  $settings,
\ilObjUser  $user 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 124 of file AllowOnScreenChatConversations.php.

127 : bool {
128 $user_value = $this->retrieveValueFromUser($user);
129 return $user_value[$this->getIdentifier()] !== false;
130 }

◆ isAvailable()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::isAvailable ( )

If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be.

This is meant e.g. to check if the chat server is configured or the badges enabled. Settings that are not available will also not be available on the table to define their PropertyAttributes

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 40 of file AllowOnScreenChatConversations.php.

40 : bool
41 {
42 return (new \ilSetting('chatroom'))->get('enable_osc', '0') === '1';
43 }
ILIAS Setting Class.

◆ persistUserInput()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::persistUserInput ( \ilObjUser  $user,
mixed  $input 
)
Parameters
mixed$inputNull will be handed in, if the user wants to use the system default. If you are able to set the preference on the user without saving it, you can rely on the User-object being saved after the call to this function. If your input has different structures depending on its provenience (KS-Input, Legacy-Input, ...), the function needs to be able to handle them all.

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 132 of file AllowOnScreenChatConversations.php.

135 : \ilObjUser {
136 if ($input === null) {
137 $user->deletePref($this->getIdentifier());
138 $user->deletePref(self::KEY_ENABLE_BROWSER_NOTIFICATIONS);
139 $this->updateChatServer($user->getId(), false);
140
141 return $user;
142 }
143
144 if (\is_bool($input)) {
145 $user->setPref($this->getIdentifier(), $input ? 'y' : 'n');
146 $this->updateChatServer($user->getId(), $input);
147
148 return $user;
149 }
150
151 if (\is_array($input)) {
152 $user->setPref($this->getIdentifier(), 'y');
153 $user->setPref(
154 self::KEY_ENABLE_BROWSER_NOTIFICATIONS,
155 $input[self::KEY_ENABLE_BROWSER_NOTIFICATIONS] ? 'y' : 'n'
156 );
157 $this->updateChatServer($user->getId(), true);
158 }
159
160 return $user;
161 }
User class.
deletePref(string $keyword)

References ilObjUser\deletePref(), and ilObject\getId().

+ Here is the call graph for this function:

◆ retrieveValueFromUser()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::retrieveValueFromUser ( \ilObjUser  $user)

Implements ILIAS\User\Property.

Definition at line 163 of file AllowOnScreenChatConversations.php.

163 : array
164 {
165 if ($user->getPref($this->getIdentifier()) !== 'y') {
166 return [
167 $this->getIdentifier() => false,
168 self::KEY_ENABLE_BROWSER_NOTIFICATIONS => false
169 ];
170 }
171
172 return [
173 $this->getIdentifier() => true,
174 self::KEY_ENABLE_BROWSER_NOTIFICATIONS => $user->getPref(self::KEY_ENABLE_BROWSER_NOTIFICATIONS) === 'y'
175 ];
176 }

References ilObjUser\getPref().

+ Here is the call graph for this function:

◆ updateChatServer()

ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::updateChatServer ( int  $user_id,
bool  $osc_state 
)
private

Definition at line 198 of file AllowOnScreenChatConversations.php.

198 : void
199 {
200 $message = [
201 $user_id => [
202 'acceptsMessages' => $osc_state,
203 ]
204 ];
205
206 $settings = \ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
207 $connector = new \ilChatroomServerConnector($settings);
208 $connector->sendUserConfigChange(json_encode($message, JSON_THROW_ON_ERROR));
209 }
static getDefaultConfiguration()
Instantiates and returns ilChatroomAdmin object using instance_id and settings from settingsTable.
$message
Definition: xapiexit.php:31

References $message, $user_id, and ilChatroomAdmin\getDefaultConfiguration().

+ Here is the call graph for this function:

Field Documentation

◆ KEY_ENABLE_BROWSER_NOTIFICATIONS

const string ILIAS\Chatroom\UserSettings\AllowOnScreenChatConversations::KEY_ENABLE_BROWSER_NOTIFICATIONS = 'chat_osc_browser_notifications'
private

Definition at line 33 of file AllowOnScreenChatConversations.php.


The documentation for this class was generated from the following file: