ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilChatroomFormFactory.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
5 
13 {
17  public function __construct()
18  {
19  }
20 
26  public static function applyValues(ilPropertyFormGUI $form, array $values)
27  {
28  foreach($values as $key => $value)
29  {
30  $field = $form->getItemByPostVar($key);
31  if(!$field)
32  {
33  continue;
34  }
35 
36  switch(strtolower(get_class($field)))
37  {
38  case 'ilcheckboxinputgui':
39  if($value)
40  {
41  $field->setChecked(true);
42  }
43  break;
44 
45  default:
46  $field->setValue($value);
47  }
48  }
49  }
50 
57  public function getCreationForm()
58  {
62  global $lng;
63 
64  $form = new ilPropertyFormGUI();
65  $title = new ilTextInputGUI($lng->txt('title'), 'title');
66  $title->setRequired(true);
67  $form->addItem($title);
68 
69  $description = new ilTextAreaInputGUI($lng->txt('description'), 'desc');
70  $form->addItem($description);
71 
72  return $this->addDefaultBehaviour($form);
73  }
74 
80  private function addDefaultBehaviour(ilPropertyFormGUI $form)
81  {
85  global $lng;
86 
87  $form->addCommandButton('create-save', $lng->txt('create'));
88  $form->addCommandButton('cancel', $lng->txt('cancel'));
89 
90  return $form;
91  }
92 
97  public function getSettingsForm()
98  {
102  global $lng;
103 
104  $form = new ilPropertyFormGUI();
105  $title = new ilTextInputGUI($lng->txt('title'), 'title');
106  $title->setRequired(true);
107  $form->addItem($title);
108 
109  $description = new ilTextAreaInputGUI($lng->txt('description'), 'desc');
110  $form->addItem($description);
111 
112  $cb = new ilCheckboxInputGUI($lng->txt('allow_anonymous'), 'allow_anonymous');
113  $cb->setInfo($lng->txt('anonymous_hint'));
114 
115  $txt = new ilTextInputGUI($lng->txt('autogen_usernames'), 'autogen_usernames');
116  $txt->setRequired(true);
117  $txt->setInfo($lng->txt('autogen_usernames_info'));
118  $cb->addSubItem($txt);
119  $form->addItem($cb);
120 
121  $cb = new ilCheckboxInputGUI($lng->txt('allow_custom_usernames'), 'allow_custom_usernames');
122  $form->addItem($cb);
123 
124  $cb_history = new ilCheckboxInputGUI($lng->txt('enable_history'), 'enable_history');
125  $form->addItem($cb_history);
126 
127  $num_msg_history = new ilNumberInputGUI($lng->txt('display_past_msgs'), 'display_past_msgs');
128  $num_msg_history->setInfo($lng->txt('hint_display_past_msgs'));
129  $num_msg_history->setMinValue(0);
130  $num_msg_history->setMaxValue(100);
131  $form->addItem($num_msg_history);
132 
133  $cb = new ilCheckboxInputGUI($lng->txt('private_rooms_enabled'), 'private_rooms_enabled');
134  $cb->setInfo($lng->txt('private_rooms_enabled_info'));
135  $form->addItem($cb);
136 
137  return $form;
138  }
139 
144  public function getFileUploadForm()
145  {
149  global $lng;
150 
151  $form = new ilPropertyFormGUI();
152  $file_input = new ilFileInputGUI();
153 
154  $file_input->setPostVar('file_to_upload');
155  $file_input->setTitle($lng->txt('upload'));
156  $form->addItem($file_input);
157  $form->addCommandButton('UploadFile-uploadFile', $lng->txt('submit'));
158 
159  $form->setTarget('_blank');
160 
161  return $form;
162  }
163 
168  public function getPeriodForm()
169  {
173  global $lng;
174 
175  $form = new ilPropertyFormGUI();
176  $form->setPreventDoubleSubmission(false);
177 
178  require_once 'Services/Form/classes/class.ilDateDurationInputGUI.php';
179  $duration = new ilDateDurationInputGUI($lng->txt('period'), 'timeperiod');
180 
181  $duration->setStartText($lng->txt('duration_from'));
182  $duration->setEndText($lng->txt('duration_to'));
183  $duration->setShowTime(true);
184  $duration->setRequired(true);
185  $form->addItem($duration);
186 
187  return $form;
188  }
189 
195  public function getUserChatNameSelectionForm(array $name_options)
196  {
201  global $lng, $ilUser;
202 
203  $form = new ilPropertyFormGUI();
204 
205  $radio = new ilRadioGroupInputGUI($lng->txt('select_custom_username'), 'custom_username_radio');
206 
207  foreach($name_options as $key => $option)
208  {
209  $opt = new ilRadioOption($option, $key);
210  $radio->addOption($opt);
211  }
212 
213  $custom_opt = new ilRadioOption($lng->txt('custom_username'), 'custom_username');
214  $radio->addOption($custom_opt);
215 
216  $txt = new ilTextInputGUI($lng->txt('custom_username'), 'custom_username_text');
217  $custom_opt->addSubItem($txt);
218  $form->addItem($radio);
219 
220  if($ilUser->isAnonymous())
221  {
222  $radio->setValue('anonymousName');
223  }
224  else
225  {
226  $radio->setValue('fullname');
227  }
228 
229  return $form;
230  }
231 
237  public function getSessionForm(array $sessions)
238  {
242  global $lng;
243 
244  $form = new ilPropertyFormGUI();
245  $form->setPreventDoubleSubmission(false);
246  $list = new ilSelectInputGUI($lng->txt('session'), 'session');
247 
248  $options = array();
249 
250  foreach($sessions as $session)
251  {
252  $start = new ilDateTime($session['connected'], IL_CAL_UNIX);
253  $end = new ilDateTime($session['disconnected'], IL_CAL_UNIX);
254 
255  $options[$session['connected'] . ',' .
256  $session['disconnected']] = ilDatePresentation::formatPeriod($start, $end);
257  }
258 
259  $list->setOptions($options);
260  $list->setRequired(true);
261 
262  $form->addItem($list);
263 
264  return $form;
265  }
266 
271  public function getGeneralSettingsForm()
272  {
276  global $lng;
277 
278  $form = new ilPropertyFormGUI();
279 
280  $address = new ilTextInputGUI($lng->txt('chatserver_address'), 'address');
281  $address->setRequired(true);
282  $form->addItem($address);
283 
284  $port = new ilNumberInputGUI($lng->txt('chatserver_port'), 'port');
285  $port->setMinValue(1);
286  $port->setMaxValue(65535);
287  $port->setRequired(true);
288  $port->setInfo($lng->txt('port_info'));
289  $port->setSize(6);
290  $form->addItem($port);
291 
292  $subDirectory = new ilTextInputGUI($lng->txt('chat_osc_no_sub_directory'), 'sub_directory');
293  $subDirectory->setRequired(false);
294  $subDirectory->setInfo($lng->txt('chat_osc_no_sub_directory_info'));
295  $form->addItem($subDirectory);
296 
297  $protocol = new ilRadioGroupInputGUI($lng->txt('protocol'), 'protocol');
298  $form->addItem($protocol);
299 
300  $http = new ilRadioOption($lng->txt('http'), 'http');
301  $protocol->addOption($http);
302 
303  $https = new ilRadioOption($lng->txt('https'), 'https');
304  $protocol->addOption($https);
305 
306  $certificate = new ilTextInputGUI($lng->txt('certificate'), 'cert');
307  $certificate->setInfo($lng->txt('chat_https_cert_info'));
308  $certificate->setRequired(true);
309  $https->addSubItem($certificate);
310 
311  $key = new ilTextInputGUI($lng->txt('key'), 'key');
312  $key->setInfo($lng->txt('chat_https_key_info'));
313  $key->setRequired(true);
314  $https->addSubItem($key);
315 
316  $dhparam = new ilTextInputGUI($lng->txt('dhparam'), 'dhparam');
317  $dhparam->setInfo($lng->txt('chat_https_dhparam_info'));
318  $dhparam->setRequired(true);
319  $https->addSubItem($dhparam);
320 
321  $chatLog = new ilTextInputGUI($lng->txt('log'), 'log');
322  $chatLog->setInfo($lng->txt('chat_log_info'));
323  $chatLog->setRequired(false);
324  $form->addItem($chatLog);
325 
326  $chatErrorLog = new ilTextInputGUI($lng->txt('error_log'), 'error_log');
327  $chatErrorLog->setInfo($lng->txt('chat_error_log_info'));
328  $chatErrorLog->setRequired(false);
329  $form->addItem($chatErrorLog);
330 
331  $iliasSection = new ilFormSectionHeaderGUI();
332  $iliasSection->setTitle($lng->txt('ilias_chatserver_connection'));
333  $form->addItem($iliasSection);
334 
335  $iliasProxy = new ilCheckboxInputGUI($lng->txt('proxy'), 'ilias_proxy');
336  $iliasProxy->setRequired(false);
337  $iliasProxy->setInfo($lng->txt('ilias_proxy_info'));
338  $form->addItem($iliasProxy);
339 
340  $chatServerILIASUrl = new ilTextInputGUI($lng->txt('url'), 'ilias_url');
341  $chatServerILIASUrl->setRequired(true);
342  $chatServerILIASUrl->setInfo($lng->txt('connection_url_info'));
343  $iliasProxy->addSubItem($chatServerILIASUrl);
344 
345  $clientSection = new ilFormSectionHeaderGUI();
346  $clientSection->setTitle($lng->txt('client_chatserver_connection'));
347  $form->addItem($clientSection);
348 
349  $clientProxy = new ilCheckboxInputGUI($lng->txt('proxy'), 'client_proxy');
350  $clientProxy->setRequired(false);
351  $clientProxy->setInfo($lng->txt('client_proxy_info'));
352  $form->addItem($clientProxy);
353 
354  $chatServerClientUrl = new ilTextInputGUI($lng->txt('url'), 'client_url');
355  $chatServerClientUrl->setRequired(true);
356  $chatServerClientUrl->setInfo($lng->txt('connection_url_info'));
357  $clientProxy->addSubItem($chatServerClientUrl);
358 
359  $deletion_section = new ilFormSectionHeaderGUI();
360  $deletion_section->setTitle($lng->txt('chat_deletion_section_head'));
361  $form->addItem($deletion_section);
362 
363  $deletion_options = new ilRadioGroupInputGUI($lng->txt('chat_deletion_section_head'), 'deletion_mode');
364 
365  $deletion_mode_deactivated = new ilRadioOption($lng->txt('chat_deletion_disabled'), 0);
366  $deletion_options->addOption($deletion_mode_deactivated);
367 
368  $chat_deletion_interval = new ilRadioOption($lng->txt('chat_deletion_interval'), 1);
369  $chat_deletion_interval->setInfo($lng->txt('chat_deletion_interval_info'));
370  $interval_unit = new ilSelectInputGUI($lng->txt('chat_deletion_interval_unit'), 'deletion_unit');
371  $interval_unit->setRequired(true);
372  $interval_unit->setOptions(array(
373  'days' => $lng->txt('days'),
374  'weeks' => $lng->txt('weeks'),
375  'month' => $lng->txt('months'),
376  'years' => $lng->txt('years'),
377  ));
378  $chat_deletion_interval->addSubItem($interval_unit);
379 
380  require_once 'Modules/Chatroom/classes/form/class.ilChatroomMessageDeletionThresholdInputGUI.php';
381  $interval_value = new ilChatroomMessageDeletionThresholdInputGUI($lng->txt('chat_deletion_interval_value'), 'deletion_value', $interval_unit);
382  $interval_value->allowDecimals(false);
383  $interval_value->setMinValue(1);
384  $interval_value->setRequired(true);
385  $chat_deletion_interval->addSubItem($interval_value);
386 
387  $runAtTime = new ilTextInputGUI($lng->txt('chat_deletion_interval_run_at'), 'deletion_time');
388  $runAtTime->setInfo($lng->txt('chat_deletion_interval_run_at_info'));
389  $runAtTime->setRequired(true);
390  $runAtTime->setValidationRegexp('/([01][0-9]|[2][0-3]):[0-5][0-9]/');
391  $chat_deletion_interval->addSubItem($runAtTime);
392 
393  $deletion_options->addOption($chat_deletion_interval);
394 
395  $form->addItem($deletion_options);
396 
397  return $form;
398  }
399 
403  public function getClientSettingsForm()
404  {
408  global $lng;
409 
410  $form = new ilPropertyFormGUI();
411 
412  $enable_chat = new ilCheckboxInputGUI($lng->txt('chat_enabled'), 'chat_enabled');
413  $form->addItem($enable_chat);
414 
415  $enable_osc = new ilCheckboxInputGUI($lng->txt('chatroom_enable_osc'), 'enable_osc');
416  $enable_osc->setInfo($lng->txt('chatroom_enable_osc_info'));
417  $enable_chat->addSubItem($enable_osc);
418 
419  $osd = new ilCheckboxInputGUI($lng->txt('enable_osd'), 'enable_osd');
420  $osd->setInfo($lng->txt('hint_osd'));
421  $enable_chat->addSubItem($osd);
422 
423  $interval = new ilNumberInputGUI($lng->txt('osd_intervall'), 'osd_intervall');
424  $interval->setMinValue(1);
425  $interval->setRequired(true);
426  $interval->setInfo($lng->txt('hint_osd_interval'));
427  $osd->addSubItem($interval);
428 
429  $play_sound = new ilCheckboxInputGUI($lng->txt('play_invitation_sound'), 'play_invitation_sound');
430  $play_sound->setInfo($lng->txt('play_invitation_sound'));
431  $osd->addSubItem($play_sound);
432 
433  $enable_smilies = new ilCheckboxInputGUI($lng->txt('enable_smilies'), 'enable_smilies');
434  $enable_smilies->setInfo($lng->txt('hint_enable_smilies'));
435  $enable_chat->addSubItem($enable_smilies);
436 
437  $name = new \ilTextInputGUI($lng->txt('chatroom_client_name'), 'client_name');
438  $name->setInfo($lng->txt('chatroom_client_name_info'));
439  $name->setRequired(true);
440  $name->setMaxLength(100);
441  $enable_chat->addSubItem($name);
442 
443  require_once 'Modules/Chatroom/classes/class.ilChatroomAuthInputGUI.php';
444  $auth = new ilChatroomAuthInputGUI($lng->txt('chatroom_auth'), 'auth');
445  $auth->setInfo($lng->txt('chat_auth_token_info'));
446  $auth->setCtrlPath(array('iladministrationgui', 'ilobjchatroomgui', 'ilpropertyformgui', 'ilformpropertydispatchgui', 'ilchatroomauthinputgui'));
447  $auth->setRequired(true);
448  $enable_chat->addSubItem($auth);
449 
450  return $form;
451  }
452 }
setPreventDoubleSubmission($a_val)
Set prevent double submission.
This class represents an option in a radio group.
getItemByPostVar($a_post_var)
Get Item by POST variable.
This class represents a selection list property in a property form.
This class represents a property form user interface.
This class represents a section header in a property form.
This class represents a file property in a property form.
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
This class represents a checkbox property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
const IL_CAL_UNIX
setInfo($a_info)
Set Info.
Class ilChatroomFormFactory.
allowDecimals($a_value)
Toggle Decimals.
setInfo($a_info)
Set Information Text.
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
Definition: example_052.php:77
input GUI for a time span (start and end date)
setTarget($a_target)
Set Target.
This class represents a property in a property form.
setMinValue($a_minvalue, $a_display_always=false)
Set Minimum Value.
if(!is_array($argv)) $options
This class represents a number property in a property form.
This class represents a text property in a property form.
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
Date and time handling
$ilUser
Definition: imgupload.php:18
$https
Definition: imgupload.php:19
Class ilChatroomAuthInputGUI.
$http
Definition: raiseError.php:7
$txt
Definition: error.php:12
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
This class represents a text area property in a property form.
static applyValues(ilPropertyFormGUI $form, array $values)
Applies given values to field in given form.
setRequired($a_required)
Set Required.