ILIAS  release_8 Revision v8.24
class.ilChatroomFormFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 protected ilLanguage $lng;
30 protected ilObjUser $user;
31 protected \ILIAS\HTTP\Services $http;
32
36 public function __construct()
37 {
38 global $DIC;
39
40 $this->lng = $DIC->language();
41 $this->user = $DIC->user();
42 $this->http = $DIC->http();
43 }
44
50 public static function applyValues(ilPropertyFormGUI $form, array $values): void
51 {
52 $form->setValuesByArray(array_map(
53 static fn ($value) => is_int($value) ? (string) $value : $value,
54 $values
55 ));
56 }
57
65 {
66 $form = new ilPropertyFormGUI();
67 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
68 $title->setRequired(true);
69 $form->addItem($title);
70
71 $description = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
72 $form->addItem($description);
73
74 return $this->addDefaultBehaviour($form);
75 }
76
83 {
84 $form->addCommandButton('create-save', $this->lng->txt('create'));
85 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
86
87 return $form;
88 }
89
90 public function getSettingsForm(ilObjectService $objectService, ilObjChatroom $chatroom): ilPropertyFormGUI
91 {
92 $this->lng->loadLanguageModule('rep');
93
94 $form = new ilPropertyFormGUI();
95 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
96 $title->setRequired(true);
97 $form->addItem($title);
98
99 $description = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
100 $form->addItem($description);
101
102 $section = new ilFormSectionHeaderGUI();
103 $section->setTitle($this->lng->txt('rep_activation_availability'));
104 $form->addItem($section);
105
106 $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'online_status');
107 $online->setInfo($this->lng->txt('chtr_activation_online_info'));
108 $form->addItem($online);
109
110 $dur = new ilDateDurationInputGUI($this->lng->txt('rep_time_period'), 'access_period');
111 $dur->setShowTime(true);
112 $form->addItem($dur);
113
114 $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'access_visibility');
115 $visible->setValue('1');
116 $visible->setInfo($this->lng->txt('chtr_activation_limited_visibility_info'));
117 $dur->addSubItem($visible);
118
119 $presentationHeader = new ilFormSectionHeaderGUI();
120 $presentationHeader->setTitle($this->lng->txt('settings_presentation_header'));
121 $form->addItem($presentationHeader);
122
123 $objectService->commonSettings()->legacyForm(
124 $form,
125 $chatroom
126 )->addTileImage();
127
128 $num_msg_history = new ilNumberInputGUI($this->lng->txt('display_past_msgs'), 'display_past_msgs');
129 $num_msg_history->setSuffix($this->lng->txt('display_past_msgs_suffix'));
130 $num_msg_history->allowDecimals(false);
131 $num_msg_history->setSize(5);
132 $num_msg_history->setInfo($this->lng->txt('hint_display_past_msgs'));
133 $num_msg_history->setMinValue(0);
134 $num_msg_history->setMaxValue(100);
135 $form->addItem($num_msg_history);
136
137 $cb_history = new ilCheckboxInputGUI($this->lng->txt('chat_enable_history'), 'enable_history');
138 $cb_history->setInfo($this->lng->txt('chat_enable_history_info'));
139 $form->addItem($cb_history);
140
141 $functionsnHeader = new ilFormSectionHeaderGUI();
142 $functionsnHeader->setTitle($this->lng->txt('chat_settings_functions_header'));
143 $form->addItem($functionsnHeader);
144
145 $cb = new ilCheckboxInputGUI($this->lng->txt('allow_anonymous'), 'allow_anonymous');
146 $cb->setInfo($this->lng->txt('anonymous_hint'));
147 $form->addItem($cb);
148
149 $cb = new ilCheckboxInputGUI($this->lng->txt('allow_custom_usernames'), 'allow_custom_usernames');
150 $txt = new ilTextInputGUI($this->lng->txt('autogen_usernames'), 'autogen_usernames');
151 $txt->setRequired(true);
152 $txt->setInfo($this->lng->txt('autogen_usernames_info'));
153 $cb->addSubItem($txt);
154 $form->addItem($cb);
155
156 $cb = new ilCheckboxInputGUI($this->lng->txt('private_rooms_enabled'), 'private_rooms_enabled');
157 $cb->setInfo($this->lng->txt('private_rooms_enabled_info'));
158 $form->addItem($cb);
159
160 return $form;
161 }
162
168 {
169 $form = new ilPropertyFormGUI();
170 $file_input = new ilFileInputGUI();
171
172 $file_input->setPostVar('file_to_upload');
173 $file_input->setTitle($this->lng->txt('upload'));
174 $form->addItem($file_input);
175 $form->addCommandButton('UploadFile-uploadFile', $this->lng->txt('submit'));
176
177 $form->setTarget('_blank');
178
179 return $form;
180 }
181
187 {
188 $form = new ilPropertyFormGUI();
189 $form->setPreventDoubleSubmission(false);
190
191 $duration = new ilDateDurationInputGUI($this->lng->txt('period'), 'timeperiod');
192
193 $duration->setStartText($this->lng->txt('duration_from'));
194 $duration->setEndText($this->lng->txt('duration_to'));
195 $duration->setShowTime(true);
196 $duration->setRequired(true);
197 $form->addItem($duration);
198
199 return $form;
200 }
201
207 public function getUserChatNameSelectionForm(array $name_options): ilPropertyFormGUI
208 {
209 $form = new ilPropertyFormGUI();
210
211 $radio = new ilRadioGroupInputGUI($this->lng->txt('select_custom_username'), 'custom_username_radio');
212
213 foreach ($name_options as $key => $option) {
214 $opt = new ilRadioOption($option, $key);
215 $radio->addOption($opt);
216 }
217
218 $custom_opt = new ilRadioOption($this->lng->txt('custom_username'), 'custom_username');
219 $radio->addOption($custom_opt);
220
221 $txt = new ilTextInputGUI($this->lng->txt('preferred_chatname'), 'custom_username_text');
222 $custom_opt->addSubItem($txt);
223 $form->addItem($radio);
224
225 if ($this->user->isAnonymous()) {
226 $radio->setValue('anonymousName');
227 } else {
228 $radio->setValue('fullname');
229 }
230
231 return $form;
232 }
233
239 public function getSessionForm(array $sessions): ilPropertyFormGUI
240 {
241 $form = new ilPropertyFormGUI();
242 $form->setPreventDoubleSubmission(false);
243 $list = new ilSelectInputGUI($this->lng->txt('session'), 'session');
244
245 $options = [];
246
247 foreach ($sessions as $session) {
248 $start = new ilDateTime($session['connected'], IL_CAL_UNIX);
249 $end = new ilDateTime($session['disconnected'], IL_CAL_UNIX);
250
251 $options[$session['connected'] . ',' .
252 $session['disconnected']] = ilDatePresentation::formatPeriod($start, $end);
253 }
254
255 $list->setOptions($options);
256 $list->setRequired(true);
257
258 $form->addItem($list);
259
260 return $form;
261 }
262
264 {
265 $form = new ilPropertyFormGUI();
266
267 $enable_chat = new ilCheckboxInputGUI($this->lng->txt('chat_enabled'), 'chat_enabled');
268 $form->addItem($enable_chat);
269
270 $enable_osc = new ilCheckboxInputGUI($this->lng->txt('chatroom_enable_osc'), 'enable_osc');
271 $enable_osc->setInfo($this->lng->txt('chatroom_enable_osc_info'));
272 $enable_chat->addSubItem($enable_osc);
273
274 $oscBrowserNotificationStatus = new ilCheckboxInputGUI(
275 $this->lng->txt('osc_adm_browser_noti_label'),
276 'enable_browser_notifications'
277 );
278 $oscBrowserNotificationStatus->setInfo($this->lng->txt('osc_adm_browser_noti_info'));
279 $oscBrowserNotificationStatus->setValue('1');
280 $enable_osc->addSubItem($oscBrowserNotificationStatus);
281
282 $oscBrowserNotificationIdleTime = new ilNumberInputGUI(
283 $this->lng->txt('osc_adm_conv_idle_state_threshold_label'),
284 'conversation_idle_state_in_minutes'
285 );
286 $oscBrowserNotificationIdleTime->allowDecimals(false);
287 $oscBrowserNotificationIdleTime->setSuffix($this->lng->txt('minutes'));
288 $oscBrowserNotificationIdleTime->setMinValue(1);
289 $oscBrowserNotificationIdleTime->setSize(5);
290 $oscBrowserNotificationIdleTime->setInfo($this->lng->txt('osc_adm_conv_idle_state_threshold_info'));
291 $enable_osc->addSubItem($oscBrowserNotificationIdleTime);
292
293 $enable_smilies = new ilCheckboxInputGUI($this->lng->txt('enable_smilies'), 'enable_smilies');
294 $enable_smilies->setInfo($this->lng->txt('hint_enable_smilies'));
295 $enable_chat->addSubItem($enable_smilies);
296
297 $name = new ilTextInputGUI($this->lng->txt('chatroom_client_name'), 'client_name');
298 $name->setInfo($this->lng->txt('chatroom_client_name_info'));
299 $name->setRequired(true);
300 $name->setMaxLength(100);
301 $enable_chat->addSubItem($name);
302
304 $this->lng->txt('chatroom_auth'),
305 'auth',
306 $this->http
307 );
308 $auth->setInfo($this->lng->txt('chat_auth_token_info'));
309 $auth->setCtrlPath(
310 [
311 ilAdministrationGUI::class,
312 ilObjChatroomGUI::class,
313 ilPropertyFormGUI::class,
314 ilFormPropertyDispatchGUI::class,
315 ilChatroomAuthInputGUI::class,
316 ]
317 );
318 $auth->setRequired(true);
319 $enable_chat->addSubItem($auth);
320
321 return $form;
322 }
323}
const IL_CAL_UNIX
Class ilChatroomAuthInputGUI.
Class ilChatroomFormFactory.
static applyValues(ilPropertyFormGUI $form, array $values)
Applies given values to field in given form.
getSessionForm(array $sessions)
Returns session form with period set by given $sessions.
getSettingsForm(ilObjectService $objectService, ilObjChatroom $chatroom)
getPeriodForm()
Returns period form.
getFileUploadForm()
Prepares Fileupload form and returns it.
addDefaultBehaviour(ilPropertyFormGUI $form)
Adds 'create-save' and 'cancel' button to given $form and returns it.
getUserChatNameSelectionForm(array $name_options)
Returns chatname selection form.
getCreationForm()
Instantiates and returns ilPropertyFormGUI containing ilTextInputGUI and ilTextAreaInputGUI.
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
@classDescription Date and time handling
This class represents a file property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
This class represents a number property in a property form.
Class ilObjChatroom.
User class.
This class represents a property form user interface.
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
$txt
Definition: error.php:13
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247
$auth
Definition: metadata.php:76
static http()
Fetches the global http state from ILIAS.
string $key
Consumer key/client ID value.
Definition: System.php:193
$session