ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilChatroomFormFactory Class Reference
+ Collaboration diagram for ilChatroomFormFactory:

Public Member Functions

 __construct ()
 
 getSettingsForm (ilChatroomObjectGUI $gui, ilCtrlInterface $ctrl, ?array $values=null, bool $may_write=false)
 
 getPeriodForm ()
 
 getUserChatNameSelectionForm (array $name_options)
 Returns chatname selection form. More...
 
 getClientSettingsForm ()
 

Static Public Member Functions

static applyValues (ilPropertyFormGUI $form, array $values)
 Applies given values to field in given form. More...
 

Data Fields

const PROP_TITLE_AND_DESC = 'title_and_desc'
 
const PROP_ONLINE_STATUS = 'online_status'
 
const PROP_TILE_IMAGE = 'tile_image'
 
const PROP_DISPLAY_PAST_MSG = 'display_past_msgs'
 
const PROP_ENABLE_HISTORY = 'enable_history'
 
const PROP_ALLOW_ANONYMOUS = 'allow_anonymous'
 
const PROP_ALLOW_CUSTOM_NAMES = 'allow_custom_usernames'
 
const PROP_AUTOGEN_USERNAMES = 'autogen_usernames'
 

Protected Attributes

ilLanguage $lng
 
ilObjUser $user
 
ILIAS HTTP Services $http
 
ILIAS UI Factory $ui_factory
 
ILIAS Refinery Factory $refinery
 

Private Member Functions

 mergeValuesTrafo ()
 
 saniziteArrayElementsTrafo ()
 

Detailed Description

Definition at line 21 of file class.ilChatroomFormFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilChatroomFormFactory::__construct ( )

Definition at line 38 of file class.ilChatroomFormFactory.php.

References $DIC, ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

39  {
40  global $DIC;
41 
42  $this->lng = $DIC->language();
43  $this->user = $DIC->user();
44  $this->http = $DIC->http();
45  $this->ui_factory = $DIC->ui()->factory();
46  $this->refinery = $DIC->refinery();
47  }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ applyValues()

static ilChatroomFormFactory::applyValues ( ilPropertyFormGUI  $form,
array  $values 
)
static

Applies given values to field in given form.

Definition at line 52 of file class.ilChatroomFormFactory.php.

References ilPropertyFormGUI\setValuesByArray().

52  : void
53  {
54  $form->setValuesByArray(
55  array_map(
56  static fn($value) => is_int($value) ? (string) $value : $value,
57  $values
58  )
59  );
60  }
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
+ Here is the call graph for this function:

◆ getClientSettingsForm()

ilChatroomFormFactory::getClientSettingsForm ( )

Definition at line 254 of file class.ilChatroomFormFactory.php.

References $http, ilNumberInputGUI\allowDecimals(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setInfo().

255  {
256  $form = new ilPropertyFormGUI();
257 
258  $enable_chat = new ilCheckboxInputGUI($this->lng->txt('chat_enabled'), 'chat_enabled');
259  $form->addItem($enable_chat);
260 
261  $enable_osc = new ilCheckboxInputGUI($this->lng->txt('chatroom_enable_osc'), 'enable_osc');
262  $enable_osc->setInfo($this->lng->txt('chatroom_enable_osc_info'));
263  $enable_chat->addSubItem($enable_osc);
264 
265  $oscBrowserNotificationStatus = new ilCheckboxInputGUI(
266  $this->lng->txt('osc_adm_browser_noti_label'),
267  'enable_browser_notifications'
268  );
269  $oscBrowserNotificationStatus->setInfo($this->lng->txt('osc_adm_browser_noti_info'));
270  $oscBrowserNotificationStatus->setValue('1');
271  $enable_osc->addSubItem($oscBrowserNotificationStatus);
272 
273  $oscBrowserNotificationIdleTime = new ilNumberInputGUI(
274  $this->lng->txt('osc_adm_conv_idle_state_threshold_label'),
275  'conversation_idle_state_in_minutes'
276  );
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);
283 
284  $name = new ilTextInputGUI($this->lng->txt('chatroom_client_name'), 'client_name');
285  $name->setInfo($this->lng->txt('chatroom_client_name_info'));
286  $name->setRequired(true);
287  $name->setMaxLength(100);
288  $enable_chat->addSubItem($name);
289 
290  $auth = new ilChatroomAuthInputGUI(
291  $this->lng->txt('chatroom_auth'),
292  'auth',
294  );
295  $auth->setInfo($this->lng->txt('chat_auth_token_info'));
296  $auth->setCtrlPath(
297  [
298  ilAdministrationGUI::class,
299  ilObjChatroomGUI::class,
300  ilPropertyFormGUI::class,
301  ilFormPropertyDispatchGUI::class,
302  ilChatroomAuthInputGUI::class,
303  ]
304  );
305  $auth->setRequired(true);
306  $enable_chat->addSubItem($auth);
307 
308  return $form;
309  }
allowDecimals(bool $a_value)
This class represents a number property in a property form.
Class ilChatroomAuthInputGUI.
+ Here is the call graph for this function:

◆ getPeriodForm()

ilChatroomFormFactory::getPeriodForm ( )

Definition at line 207 of file class.ilChatroomFormFactory.php.

References $duration, and ILIAS\Repository\lng().

208  {
209  $form = new ilPropertyFormGUI();
210  $form->setPreventDoubleSubmission(false);
211 
212  $duration = new ilDateDurationInputGUI($this->lng->txt('period'), 'timeperiod');
213 
214  $duration->setStartText($this->lng->txt('duration_from'));
215  $duration->setEndText($this->lng->txt('duration_to'));
216  $duration->setShowTime(true);
217  $duration->setRequired(true);
218  $form->addItem($duration);
219 
220  return $form;
221  }
$duration
+ Here is the call graph for this function:

◆ getSettingsForm()

ilChatroomFormFactory::getSettingsForm ( ilChatroomObjectGUI  $gui,
ilCtrlInterface  $ctrl,
?array  $values = null,
bool  $may_write = false 
)

Definition at line 84 of file class.ilChatroomFormFactory.php.

References ilCtrlInterface\getFormAction(), ilObjectGUI\getObject(), ILIAS\Repository\lng(), mergeValuesTrafo(), null, ILIAS\Repository\refinery(), saniziteArrayElementsTrafo(), and ILIAS\UI\Implementation\Component\Input\withValue().

89  : \ILIAS\UI\Component\Input\Container\Form\Form {
90  $this->lng->loadLanguageModule('obj');
91  $this->lng->loadLanguageModule('rep');
92 
93  $field_factory = $this->ui_factory->input()->field();
94 
95  $title_and_description = $gui->getObject()->getObjectProperties()->getPropertyTitleAndDescription();
96  $general_settings_fields = [
97  self::PROP_TITLE_AND_DESC => $title_and_description->toForm(
98  $this->lng,
99  $field_factory,
100  $this->refinery
101  )
102  ];
103 
104  $online_status = $gui->getObject()->getObjectProperties()->getPropertyIsOnline();
105  $availability_fields = [
106  self::PROP_ONLINE_STATUS => $online_status->toForm(
107  $this->lng,
108  $field_factory,
109  $this->refinery
110  )->withByline($this->lng->txt('chtr_activation_online_info')),
111  ];
112 
113  $tile_image = $gui->getObject()->getObjectProperties()->getPropertyTileImage();
114  $presentation_fields = [
115  self::PROP_TILE_IMAGE => $tile_image->toForm(
116  $this->lng,
117  $field_factory,
118  $this->refinery
119  ),
120  self::PROP_DISPLAY_PAST_MSG => $field_factory->numeric(
121  $this->lng->txt('display_past_msgs'),
122  $this->lng->txt('hint_display_past_msgs')
123  )->withRequired(
124  true
125  )->withAdditionalTransformation(
126  $this->refinery->logical()->parallel([
127  $this->refinery->int()->isGreaterThanOrEqual(0),
128  $this->refinery->int()->isLessThanOrEqual(100)
129  ])
130  )->withValue(
131  $values['display_past_msgs'] ?? 0
132  ),
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)),
137  ];
138 
139  $function_fields = [
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(
145  [
146  self::PROP_AUTOGEN_USERNAMES => $field_factory->text(
147  $this->lng->txt('autogen_usernames'),
148  $this->lng->txt('autogen_usernames_info')
149  )->withRequired(true),
150  ],
151  $this->lng->txt('allow_custom_usernames')
152  )->withValue(
153  ($values['allow_custom_usernames'] ?? false) ? [self::PROP_AUTOGEN_USERNAMES => $values['autogen_usernames'] ?? ''] : null
154  ),
155  ];
156 
157  $sections = [
158  $field_factory->section(
159  $general_settings_fields,
160  $this->lng->txt('settings_title'),
161  ''
162  ),
163  $field_factory->section(
164  $availability_fields,
165  $this->lng->txt('rep_activation_availability'),
166  ''
167  ),
168  $field_factory->section(
169  $presentation_fields,
170  $this->lng->txt('settings_presentation_header'),
171  ''
172  ),
173  $field_factory->section(
174  $function_fields,
175  $this->lng->txt('chat_settings_functions_header'),
176  ''
177  ),
178  ];
179 
180  $action = $ctrl->getFormAction($gui, 'settings-saveGeneral');
181  if (!$may_write) {
182  $action = $ctrl->getFormAction($gui, 'settings-general');
183  }
184 
185  if (!$may_write) {
186  $sections = array_map(static fn($x) => $x->withDisabled(true), $sections);
187  }
188 
189  $form = $this->ui_factory
190  ->input()
191  ->container()
192  ->form()
193  ->standard(
194  $action,
195  $sections
196  )
197  ->withAdditionalTransformation($this->mergeValuesTrafo())
198  ->withAdditionalTransformation($this->saniziteArrayElementsTrafo());
199 
200  if (!$may_write) {
201  $form = $form->withSubmitLabel($this->lng->txt('refresh'));
202  }
203 
204  return $form;
205  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
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.
+ Here is the call graph for this function:

◆ getUserChatNameSelectionForm()

ilChatroomFormFactory::getUserChatNameSelectionForm ( array  $name_options)

Returns chatname selection form.

Parameters
array<string,string>$name_options

Definition at line 227 of file class.ilChatroomFormFactory.php.

References $txt, ILIAS\Repository\lng(), and ILIAS\Repository\user().

228  {
229  $form = new ilPropertyFormGUI();
230 
231  $radio = new ilRadioGroupInputGUI($this->lng->txt('select_custom_username'), 'custom_username_radio');
232 
233  foreach ($name_options as $key => $option) {
234  $opt = new ilRadioOption($option, $key);
235  $radio->addOption($opt);
236  }
237 
238  $custom_opt = new ilRadioOption($this->lng->txt('custom_username'), 'custom_username');
239  $radio->addOption($custom_opt);
240 
241  $txt = new ilTextInputGUI($this->lng->txt('preferred_chatname'), 'custom_username_text');
242  $custom_opt->addSubItem($txt);
243  $form->addItem($radio);
244 
245  if ($this->user->isAnonymous()) {
246  $radio->setValue('anonymousName');
247  } else {
248  $radio->setValue('fullname');
249  }
250 
251  return $form;
252  }
This class represents an option in a radio group.
This class represents a property in a property form.
$txt
Definition: error.php:31
+ Here is the call graph for this function:

◆ mergeValuesTrafo()

ilChatroomFormFactory::mergeValuesTrafo ( )
private

Definition at line 62 of file class.ilChatroomFormFactory.php.

References ILIAS\Repository\refinery().

Referenced by getSettingsForm().

62  : \ILIAS\Refinery\Transformation
63  {
64  return $this->refinery->custom()->transformation(static fn(array $values): array => array_merge(...$values));
65  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saniziteArrayElementsTrafo()

ilChatroomFormFactory::saniziteArrayElementsTrafo ( )
private

Definition at line 67 of file class.ilChatroomFormFactory.php.

References $data, ILIAS\Repository\refinery(), and ilUtil\stripSlashes().

Referenced by getSettingsForm().

67  : \ILIAS\Refinery\Transformation
68  {
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)) {
74  $data[$key] = ilUtil::stripSlashes($value);
75  }
76  }
77 
78  return $data;
79  };
80 
81  return $this->refinery->custom()->transformation($sanitize);
82  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $http

ILIAS HTTP Services ilChatroomFormFactory::$http
protected

Definition at line 34 of file class.ilChatroomFormFactory.php.

Referenced by getClientSettingsForm().

◆ $lng

ilLanguage ilChatroomFormFactory::$lng
protected

Definition at line 32 of file class.ilChatroomFormFactory.php.

◆ $refinery

ILIAS Refinery Factory ilChatroomFormFactory::$refinery
protected

Definition at line 36 of file class.ilChatroomFormFactory.php.

◆ $ui_factory

ILIAS UI Factory ilChatroomFormFactory::$ui_factory
protected

Definition at line 35 of file class.ilChatroomFormFactory.php.

◆ $user

ilObjUser ilChatroomFormFactory::$user
protected

Definition at line 33 of file class.ilChatroomFormFactory.php.

◆ PROP_ALLOW_ANONYMOUS

const ilChatroomFormFactory::PROP_ALLOW_ANONYMOUS = 'allow_anonymous'

Definition at line 28 of file class.ilChatroomFormFactory.php.

◆ PROP_ALLOW_CUSTOM_NAMES

const ilChatroomFormFactory::PROP_ALLOW_CUSTOM_NAMES = 'allow_custom_usernames'

Definition at line 29 of file class.ilChatroomFormFactory.php.

Referenced by ilChatroomSettingsGUI\saveGeneral().

◆ PROP_AUTOGEN_USERNAMES

const ilChatroomFormFactory::PROP_AUTOGEN_USERNAMES = 'autogen_usernames'

Definition at line 30 of file class.ilChatroomFormFactory.php.

Referenced by ilChatroomSettingsGUI\saveGeneral().

◆ PROP_DISPLAY_PAST_MSG

const ilChatroomFormFactory::PROP_DISPLAY_PAST_MSG = 'display_past_msgs'

Definition at line 26 of file class.ilChatroomFormFactory.php.

◆ PROP_ENABLE_HISTORY

const ilChatroomFormFactory::PROP_ENABLE_HISTORY = 'enable_history'

Definition at line 27 of file class.ilChatroomFormFactory.php.

◆ PROP_ONLINE_STATUS

const ilChatroomFormFactory::PROP_ONLINE_STATUS = 'online_status'

Definition at line 24 of file class.ilChatroomFormFactory.php.

Referenced by ilChatroomSettingsGUI\saveGeneral().

◆ PROP_TILE_IMAGE

const ilChatroomFormFactory::PROP_TILE_IMAGE = 'tile_image'

Definition at line 25 of file class.ilChatroomFormFactory.php.

Referenced by ilChatroomSettingsGUI\saveGeneral().

◆ PROP_TITLE_AND_DESC

const ilChatroomFormFactory::PROP_TITLE_AND_DESC = 'title_and_desc'

Definition at line 23 of file class.ilChatroomFormFactory.php.

Referenced by ilChatroomSettingsGUI\saveGeneral().


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