ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
27  public function getCreationForm()
28  {
32  global $lng;
33 
34  $form = new ilPropertyFormGUI();
35  $title = new ilTextInputGUI($lng->txt('title'), 'title');
36  $title->setRequired(true);
37  $form->addItem($title);
38 
39  $description = new ilTextAreaInputGUI($lng->txt('description'), 'desc');
40  $form->addItem($description);
41 
42  return $this->addDefaultBehaviour($form);
43  }
44 
50  public static function applyValues(ilPropertyFormGUI $form, array $values)
51  {
52  foreach($values as $key => $value)
53  {
54  $field = $form->getItemByPostVar($key);
55  if(!$field)
56  {
57  continue;
58  }
59 
60  switch(strtolower(get_class($field)))
61  {
62  case 'ilcheckboxinputgui':
63  if($value)
64  {
65  $field->setChecked(true);
66  }
67  break;
68 
69  default:
70  $field->setValue($value);
71  }
72  }
73  }
74 
79  public function getSettingsForm()
80  {
84  global $lng;
85 
86  $form = new ilPropertyFormGUI();
87  $title = new ilTextInputGUI($lng->txt('title'), 'title');
88  $title->setRequired(true);
89  $form->addItem($title);
90 
91  $description = new ilTextAreaInputGUI($lng->txt('description'), 'desc');
92  $form->addItem($description);
93 
94  $cb = new ilCheckboxInputGUI($lng->txt('allow_anonymous'), 'allow_anonymous');
95  $cb->setInfo($lng->txt('anonymous_hint'));
96  $form->addItem($cb);
97 
98  $txt = new ilTextInputGUI($lng->txt('autogen_usernames'), 'autogen_usernames');
99  $txt->setRequired(true);
100  $txt->setInfo($lng->txt('autogen_usernames_info'));
101  $form->addItem($txt);
102 
103  $cb = new ilCheckboxInputGUI($lng->txt('allow_custom_usernames'), 'allow_custom_usernames');
104  $form->addItem($cb);
105 
106  $cb_history = new ilCheckboxInputGUI($lng->txt('enable_history'), 'enable_history');
107  $form->addItem($cb_history);
108 
109  $num_msg_history = new ilNumberInputGUI($lng->txt('display_past_msgs'), 'display_past_msgs');
110  $num_msg_history->setInfo($lng->txt('hint_display_past_msgs'));
111  $num_msg_history->setMinValue(0);
112  $num_msg_history->setMaxValue(100);
113  $form->addItem($num_msg_history);
114 
115  $cb = new ilCheckboxInputGUI($lng->txt('private_rooms_enabled'), 'private_rooms_enabled');
116  $cb->setInfo($lng->txt('private_rooms_enabled_info'));
117  $form->addItem($cb);
118 
119  return $form;
120  }
121 
126  public function getFileUploadForm()
127  {
131  global $lng;
132 
133  $form = new ilPropertyFormGUI();
134  $file_input = new ilFileInputGUI();
135 
136  $file_input->setPostVar('file_to_upload');
137  $file_input->setTitle($lng->txt('upload'));
138  $form->addItem($file_input);
139  $form->addCommandButton('UploadFile-uploadFile', $lng->txt('submit'));
140 
141  $form->setTarget('_blank');
142 
143  return $form;
144  }
145 
151  private function addDefaultBehaviour(ilPropertyFormGUI $form)
152  {
156  global $lng;
157 
158  $form->addCommandButton('create-save', $lng->txt('create'));
159  $form->addCommandButton('cancel', $lng->txt('cancel'));
160 
161  return $form;
162  }
163 
168  public function getPeriodForm()
169  {
173  global $lng;
174 
175  $form = new ilPropertyFormGUI();
176 
177  require_once 'Services/Form/classes/class.ilDateDurationInputGUI.php';
178  $duration = new ilDateDurationInputGUI($lng->txt('period'), 'timeperiod');
179 
180  $duration->setStartText($lng->txt('duration_from'));
181  $duration->setEndText($lng->txt('duration_to'));
182  $duration->setShowTime(true);
183  $form->addItem($duration);
184 
185  return $form;
186  }
187 
193  public function getUserChatNameSelectionForm(array $name_options)
194  {
199  global $lng, $ilUser;
200 
201  $form = new ilPropertyFormGUI();
202 
203  $radio = new ilRadioGroupInputGUI($lng->txt('select_custom_username'), 'custom_username_radio');
204 
205  foreach($name_options as $key => $option)
206  {
207  $opt = new ilRadioOption($option, $key);
208  $radio->addOption($opt);
209  }
210 
211  $custom_opt = new ilRadioOption($lng->txt('custom_username'), 'custom_username');
212  $radio->addOption($custom_opt);
213 
214  $txt = new ilTextInputGUI($lng->txt('custom_username'), 'custom_username_text');
215  $custom_opt->addSubItem($txt);
216  $form->addItem($radio);
217 
218  if($ilUser->isAnonymous())
219  {
220  $radio->setValue('anonymousName');
221  }
222  else
223  {
224  $radio->setValue('fullname');
225  }
226 
227  return $form;
228  }
229 
235  public function getSessionForm(array $sessions)
236  {
240  global $lng;
241 
242  $form = new ilPropertyFormGUI();
243  $list = new ilSelectInputGUI($lng->txt('session'), 'session');
244 
245  $options = array();
246 
247  foreach($sessions as $session)
248  {
249  $start = new ilDateTime($session['connected'], IL_CAL_UNIX);
250  $end = new ilDateTime($session['disconnected'], IL_CAL_UNIX);
251 
252  $options[$session['connected'] . ',' .
253  $session['disconnected']] = ilDatePresentation::formatPeriod($start, $end);
254  }
255 
256  $list->setOptions($options);
257  $list->setRequired(true);
258 
259  $form->addItem($list);
260 
261  return $form;
262  }
263 
268  public function getGeneralSettingsForm()
269  {
273  global $lng;
274 
275  $form = new ilPropertyFormGUI();
276 
277  $address = new ilTextInputGUI($lng->txt('chatserver_address'), 'address');
278  $address->setRequired(true);
279  $form->addItem($address);
280 
281  $port = new ilNumberInputGUI($lng->txt('chatserver_port'), 'port');
282  $port->setMinValue(1);
283  $port->setMaxValue(65535);
284  $port->setRequired(true);
285  $port->setInfo($lng->txt('port_info'));
286  $port->setSize(6);
287  $form->addItem($port);
288 
289  $priv_hosts = new ilTextInputGUI($lng->txt('priv_hosts'), 'priv_hosts');
290  $priv_hosts->setRequired(true);
291  $form->addItem($priv_hosts);
292 
293  $keystore = new ilTextInputGUI($lng->txt('keystore'), 'keystore');
294  $keystore->setRequired(true);
295  $keypass = new ilTextInputGUI($lng->txt('keypass'), 'keypass');
296  $keypass->setRequired(true);
297  $storepass = new ilTextInputGUI($lng->txt('storepass'), 'storepass');
298  $storepass->setRequired(true);
299 
300  $protocol = new ilRadioGroupInputGUI($lng->txt('protocol'), 'protocol');
301  $http = new ilRadioOption($lng->txt('http'), 'http');
302  $https = new ilRadioOption($lng->txt('https'), 'https');
303  $https->addSubItem($keystore);
304  $https->addSubItem($keypass);
305  $https->addSubItem($storepass);
306  $protocol->addOption($http);
307  $protocol->addOption($https);
308  $form->addItem($protocol);
309 
310  return $form;
311  }
312 
316  public function getClientSettingsForm()
317  {
321  global $lng;
322 
323  $form = new ilPropertyFormGUI();
324 
325  $cb = new ilCheckboxInputGUI($lng->txt('chat_enabled'), 'chat_enabled');
326  $form->addItem($cb);
327 
328  $cb = new ilCheckboxInputGUI($lng->txt('enable_osd'), 'enable_osd');
329  $cb->setInfo($lng->txt('hint_osd'));
330  $form->addItem($cb);
331 
332  $txt = new ilNumberInputGUI($lng->txt('osd_intervall'), 'osd_intervall');
333  $txt->setMinValue(1);
334  $txt->setRequired(true);
335  $txt->setInfo($lng->txt('hint_osd_interval'));
336  $cb->addSubItem($txt);
337 
338  $cb1 = new ilCheckboxInputGUI($lng->txt('play_invitation_sound'), 'play_invitation_sound');
339  $cb1->setInfo($lng->txt('play_invitation_sound'));
340  $cb->addSubItem($cb1);
341 
342  $cb = new ilCheckboxInputGUI($lng->txt('enable_smilies'), 'enable_smilies');
343  $cb->setInfo($lng->txt('hint_enable_smilies'));
344  $form->addItem($cb);
345 
346  $name = new ilTextInputGUI($lng->txt('instance_name'), 'name');
347  $name->setRequired(true);
348  $name->setValidationRegexp('/^[a-z0-9_-]+$/i');
349  $name->setInfo($lng->txt('hint_unique_name'));
350  $form->addItem($name);
351 
352  $url = new ilTextInputGUI($lng->txt('ilias_url'), 'url');
353  $url->setRequired(true);
354  $form->addItem($url);
355 
356  $user = new ilTextInputGUI($lng->txt('soap_user'), 'user');
357  $user->setInfo($lng->txt('soap_user_hint'));
358  $user->setRequired(true);
359  $form->addItem($user);
360 
361  $password = new ilPasswordInputGUI($lng->txt('soap_user_password'), 'password');
362  $password->setSkipSyntaxCheck(true);
363  $password->setRequired(true);
364  $form->addItem($password);
365 
366  return $form;
367  }
368 }