19declare(strict_types=1);
34 protected \ILIAS\HTTP\Services
$http;
42 $this->
lng = $DIC->language();
43 $this->
user = $DIC->user();
44 $this->
http = $DIC->http();
45 $this->ui_factory =
$DIC->ui()->factory();
56 static fn($value) => is_int($value) ? (
string) $value : $value,
64 return $this->
refinery->custom()->transformation(
static fn(array $values): array => array_merge(...$values));
69 $sanitize =
static function (array
$data) use (&$sanitize): array {
70 foreach (
$data as $key => $value) {
71 if (is_array($value)) {
72 $data[$key] = $sanitize($value);
73 } elseif (is_string($value)) {
81 return $this->
refinery->custom()->transformation($sanitize);
87 ?array $values =
null,
88 bool $may_write =
false
90 $this->
lng->loadLanguageModule(
'obj');
91 $this->
lng->loadLanguageModule(
'rep');
93 $field_factory = $this->ui_factory->input()->field();
95 $title_and_description = $gui->
getObject()->getObjectProperties()->getPropertyTitleAndDescription();
96 $general_settings_fields = [
97 self::PROP_TITLE_AND_DESC => $title_and_description->toForm(
104 $online_status = $gui->
getObject()->getObjectProperties()->getPropertyIsOnline();
105 $availability_fields = [
106 self::PROP_ONLINE_STATUS => $online_status->toForm(
110 )->withByline($this->
lng->txt(
'chtr_activation_online_info')),
113 $tile_image = $gui->
getObject()->getObjectProperties()->getPropertyTileImage();
114 $presentation_fields = [
115 self::PROP_TILE_IMAGE => $tile_image->toForm(
120 self::PROP_DISPLAY_PAST_MSG => $field_factory->numeric(
121 $this->
lng->txt(
'display_past_msgs'),
122 $this->lng->txt(
'hint_display_past_msgs')
125 )->withAdditionalTransformation(
126 $this->
refinery->logical()->parallel([
127 $this->refinery->int()->isGreaterThanOrEqual(0),
128 $this->refinery->int()->isLessThanOrEqual(100)
131 $values[
'display_past_msgs'] ?? 0
133 self::PROP_ENABLE_HISTORY => $field_factory->checkbox(
134 $this->
lng->txt(
'chat_enable_history'),
135 $this->lng->txt(
'chat_enable_history_info')
136 )->withValue((
bool) ($values[
'enable_history'] ??
false)),
140 self::PROP_ALLOW_ANONYMOUS => $field_factory->checkbox(
141 $this->
lng->txt(
'allow_anonymous'),
142 $this->lng->txt(
'anonymous_hint')
143 )->withValue((
bool) ($values[
'allow_anonymous'] ??
false)),
144 self::PROP_ALLOW_CUSTOM_NAMES => $field_factory->optionalGroup(
146 self::PROP_AUTOGEN_USERNAMES => $field_factory->text(
147 $this->lng->txt(
'autogen_usernames'),
148 $this->lng->txt(
'autogen_usernames_info')
149 )->withRequired(
true),
151 $this->lng->txt(
'allow_custom_usernames')
153 ($values[
'allow_custom_usernames'] ??
false) ? [self::PROP_AUTOGEN_USERNAMES => $values[
'autogen_usernames'] ??
''] :
null
158 $field_factory->section(
159 $general_settings_fields,
160 $this->
lng->txt(
'settings_title'),
163 $field_factory->section(
164 $availability_fields,
165 $this->
lng->txt(
'rep_activation_availability'),
168 $field_factory->section(
169 $presentation_fields,
170 $this->
lng->txt(
'settings_presentation_header'),
173 $field_factory->section(
175 $this->
lng->txt(
'chat_settings_functions_header'),
180 $action = $ctrl->
getFormAction($gui,
'settings-saveGeneral');
186 $sections = array_map(
static fn($x) => $x->withDisabled(
true), $sections);
189 $form = $this->ui_factory
201 $form = $form->withSubmitLabel($this->
lng->txt(
'refresh'));
210 $form->setPreventDoubleSubmission(
false);
214 $duration->setStartText($this->
lng->txt(
'duration_from'));
233 foreach ($name_options as $key => $option) {
235 $radio->addOption($opt);
238 $custom_opt =
new ilRadioOption($this->
lng->txt(
'custom_username'),
'custom_username');
239 $radio->addOption($custom_opt);
242 $custom_opt->addSubItem(
$txt);
243 $form->addItem($radio);
245 if ($this->
user->isAnonymous()) {
246 $radio->setValue(
'anonymousName');
248 $radio->setValue(
'fullname');
259 $form->addItem($enable_chat);
262 $enable_osc->setInfo($this->
lng->txt(
'chatroom_enable_osc_info'));
263 $enable_chat->addSubItem($enable_osc);
266 $this->
lng->txt(
'osc_adm_browser_noti_label'),
267 'enable_browser_notifications'
269 $oscBrowserNotificationStatus->setInfo($this->
lng->txt(
'osc_adm_browser_noti_info'));
270 $oscBrowserNotificationStatus->setValue(
'1');
271 $enable_osc->addSubItem($oscBrowserNotificationStatus);
274 $this->
lng->txt(
'osc_adm_conv_idle_state_threshold_label'),
275 'conversation_idle_state_in_minutes'
277 $oscBrowserNotificationIdleTime->allowDecimals(
false);
278 $oscBrowserNotificationIdleTime->setSuffix($this->
lng->txt(
'minutes'));
279 $oscBrowserNotificationIdleTime->setMinValue(1);
280 $oscBrowserNotificationIdleTime->setSize(5);
281 $oscBrowserNotificationIdleTime->setInfo($this->
lng->txt(
'osc_adm_conv_idle_state_threshold_info'));
282 $enable_osc->addSubItem($oscBrowserNotificationIdleTime);
285 $this->
lng->txt(
'chat_osc_accept_msg'),
286 'chat_osc_accept_msg'
288 $oscAllowConversations->setOptions(
290 'n' => $this->
lng->txt(
'buddy_allow_to_contact_me_no'),
291 'y' => $this->lng->txt(
'buddy_allow_to_contact_me_yes')
294 $oscAllowConversations->setInfo($this->
lng->txt(
'chat_osc_accept_msg_default_info'));
295 $enable_osc->addSubItem($oscAllowConversations);
298 $this->
lng->txt(
'chat_broadcast_typing'),
299 'chat_broadcast_typing'
301 $oscBroadcastTyping->setOptions(
303 'n' => $this->
lng->txt(
'chat_no_use_typing_broadcast'),
304 'y' => $this->lng->txt(
'chat_use_typing_broadcast')
307 $oscBroadcastTyping->setInfo($this->
lng->txt(
'chat_broadcast_typing_default_info'));
308 $enable_osc->addSubItem($oscBroadcastTyping);
310 $name =
new ilTextInputGUI($this->
lng->txt(
'chatroom_client_name'),
'client_name');
311 $name->setInfo($this->
lng->txt(
'chatroom_client_name_info'));
312 $name->setRequired(
true);
313 $name->setMaxLength(100);
314 $enable_chat->addSubItem($name);
317 $this->
lng->txt(
'chatroom_auth'),
321 $auth->setInfo($this->
lng->txt(
'chat_auth_token_info'));
324 ilAdministrationGUI::class,
325 ilObjChatroomGUI::class,
326 ilPropertyFormGUI::class,
327 ilFormPropertyDispatchGUI::class,
328 ilChatroomAuthInputGUI::class,
331 $auth->setRequired(
true);
332 $enable_chat->addSubItem($auth);
This class represents an option in a radio group.
This class represents a text property in a property form.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getFormAction(object $a_gui_obj, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
Returns a form action link for the given information.
static http()
Fetches the global http state from ILIAS.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.