ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjChatServerGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2009 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
36 require_once 'classes/class.ilObjectGUI.php';
37 
39 {
40  private $form_gui = null;
41 
46  public function __construct($a_data,$a_id,$a_call_by_reference = true, $a_prepare_output = true)
47  {
48 
49  #define('ILIAS_MODULE','chat');
50  $this->type = 'chac';
51  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output);
52 
53  $this->lng->loadLanguageModule('chat');
54  }
55 
56  public function &executeCommand()
57  {
58  $next_class = $this->ctrl->getNextClass($this);
59  $cmd = $this->ctrl->getCmd();
60  $this->prepareOutput();
61 
62  switch($next_class)
63  {
64  case 'ilpermissiongui':
65  include_once('Services/AccessControl/classes/class.ilPermissionGUI.php');
66  $perm_gui =& new ilPermissionGUI($this);
67  $ret =& $this->ctrl->forwardCommand($perm_gui);
68  break;
69 
70  default:
71  if(!$cmd)
72  {
73  $cmd = 'view';
74  }
75 
76  if ($cmd != 'update')
77  {
78  if(!$this->object->server_conf->isAlive())
79  {
81  (
82  $this->lng->txt('chat_cannot_connect_to_server') .
83  ($cmd != 'edit' ? ' ' . $this->lng->txt('check_configuration') : '')
84  );
85  }
86 
87  }
88  $cmd .= 'Object';
89  $this->$cmd();
90 
91  break;
92  }
93  return true;
94  }
95 
96  public function initForm($a_mode)
97  {
98  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
99  $this->form_gui = new ilPropertyFormGUI();
100  $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'update'));
101 
102  if($this->object->server_conf->isAlive() or $this->object->server_conf->getActiveStatus())
103  {
104  // activation/deactivation of chat module
105  $sec_cd = new ilFormSectionHeaderGUI();
106  $sec_cd->setTitle($this->lng->txt('chat_ilias'));
107  $this->form_gui->addItem($sec_cd);
108 
109  $sel = new ilSelectInputGUI($this->lng->txt('chat_status'), 'chat_active');
110  $options = array(
111  1 => $this->lng->txt('chat_active'),
112  0 => $this->lng->txt('chat_inactive')
113  );
114  $sel->setOptions($options);
115  $sel->setValue(1);
116  $this->form_gui->addItem($sel);
117  }
118 # else if(!$this->object->server_conf->isAlive() && $this->ctrl->getCmd() != 'update')
119 # {
120 # ilUtil::sendFailure($this->lng->txt('chat_cannot_connect_to_server'));
121 # }
122 
123  // chat server settings
124  $sec_l = new ilFormSectionHeaderGUI();
125  $sec_l->setTitle($this->lng->txt('chat_server_settings'));
126  $this->form_gui->addItem($sec_l);
127 
128  // sever internal ip
129  $inp = new ilTextInputGUI($this->lng->txt('chat_server_internal_ip'), 'chat_internal_ip');
130  $inp->setRequired(true);
131  $inp->setSize(40);
132  $inp->setMaxLength(128);
133  $this->form_gui->addItem($inp);
134 
135  // server address
136  $inp = new ilTextInputGUI($this->lng->txt('chat_server_external_ip'), 'chat_external_ip');
137  $inp->setRequired(true);
138  $inp->setSize(40);
139  $inp->setMaxLength(128);
140  $this->form_gui->addItem($inp);
141 
142  // server port
143  $inp = new ilTextInputGUI($this->lng->txt('chat_server_port'), 'chat_port');
144  $inp->setRequired(true);
145  $inp->setSize(5);
146  $inp->setMaxLength(5);
147  $this->form_gui->addItem($inp);
148 
149  // ssl
150  $chb = new ilCheckboxInputGUI($this->lng->txt('chat_server_ssl_settings'), 'chat_ssl_status');
151  $chb->setOptionTitle($this->lng->txt('chat_server_ssl_active'));
152  $chb->setChecked(false);
153  $inp = new ilTextInputGUI($this->lng->txt('chat_server_ssl_port'), 'chat_ssl_port');
154  $inp->setSize(5);
155  $inp->setMaxLength(5);
156  $chb->addSubItem($inp);
157  $this->form_gui->addItem($chb);
158 
159  // moderator password
160  $inp = new ilPasswordInputGUI($this->lng->txt('chat_moderator_password'), 'chat_moderator');
161  $inp->setRequired(true);
162  $inp->setSize(9);
163  $inp->setMaxLength(16);
164  $this->form_gui->addItem($inp);
165 
166  // logfile path
167  $inp = new ilTextInputGUI($this->lng->txt('chat_server_logfile'), 'chat_logfile');
168  $inp->setSize(40);
169  $inp->setMaxLength(256);
170  $this->form_gui->addItem($inp);
171 
172  // log level
173  $sel = new ilSelectInputGUI($this->lng->txt('chat_server_loglevel'), 'chat_loglevel');
174  $options = array(
175  1 => $this->lng->txt('chat_level_fatal'),
176  2 => $this->lng->txt('chat_level_error'),
177  3 => $this->lng->txt('chat_level_info'),
178  5 => $this->lng->txt('chat_level_debug'),
179  6 => $this->lng->txt('chat_level_all')
180  );
181  $sel->setOptions($options);
182  $sel->setValue(1);
183  $this->form_gui->addItem($sel);
184 
185  // allowed hosts
186  $inp = new ilTextInputGUI($this->lng->txt('chat_server_allowed'), 'chat_allowed');
187  $inp->setInfo($this->lng->txt('chat_server_allowed_b'));
188  $inp->setRequired(true);
189  $inp->setSize(40);
190  $inp->setMaxLength(256);
191  $this->form_gui->addItem($inp);
192 
193  // chat general settings
194  $sec_cd = new ilFormSectionHeaderGUI();
195  $sec_cd->setTitle($this->lng->txt('chat_general_settings'));
196  $this->form_gui->addItem($sec_cd);
197 
198  // sound activation/deactivation for new chat invitations and messages
199  $rg = new ilRadioGroupInputGUI($this->lng->txt('chat_sounds'), 'chat_sound_status');
200  $rg->setValue(0);
201  $ro = new ilRadioOption($this->lng->txt('chat_sound_status_activate'), 1);
202  $chb = new ilCheckboxInputGUI('', 'chat_new_invitation_sound_status');
203  $chb->setOptionTitle($this->lng->txt('chat_new_invitation_sound_status'));
204  $chb->setChecked(false);
205  $ro->addSubItem($chb);
206  $chb = new ilCheckBoxInputGUI('','chat_new_message_sound_status');
207  $chb->setOptionTitle($this->lng->txt('chat_new_message_sound_status'));
208  $chb->setChecked(false);
209  $ro->addSubItem($chb);
210  $rg->addOption($ro);
211  $ro = new ilRadioOption($this->lng->txt('chat_sound_status_deactivate'), 0);
212  $rg->addOption($ro);
213  $this->form_gui->addItem($rg);
214 
215  // chat message notification in ilias
216  $rg = new ilRadioGroupInputGUI($this->lng->txt('chat_message_notify'), 'chat_message_notify_status');
217  $rg->setValue(0);
218  $ro = new ilRadioOption($this->lng->txt('chat_message_notify_activate'), 1);
219  $rg->addOption($ro);
220  $ro = new ilRadioOption($this->lng->txt('chat_message_notify_deactivate'), 0);
221  $rg->addOption($ro);
222  $this->form_gui->addItem($rg);
223 
224  // smilies
225  $rg = new ilRadioGroupInputGUI($this->lng->txt('chat_smilies_status'), 'chat_smilies_status');
226  $rg->setValue(0);
227  $ro = new ilRadioOption($this->lng->txt('chat_smilies_activate'), 1);
228  $rg->addOption($ro);
229  $ro = new ilRadioOption($this->lng->txt('chat_smilies_deactivate'), 0);
230  $rg->addOption($ro);
231  $this->form_gui->addItem($rg);
232 
233  // message export permissions
234  $rg = new ilRadioGroupInputGUI($this->lng->txt('chat_export_status'), 'chat_export_status');
235  $ro = new ilRadioOption($this->lng->txt('chat_export_all'), 0);
236  $rg->addOption($ro);
237  $ro = new ilRadioOption($this->lng->txt('chat_export_moderator'), 1);
238  $rg->addOption($ro);
239  $rg->setInfo($this->lng->txt('chat_export_info'));
240  $this->form_gui->addItem($rg);
241 
242  // message export period
243  $inp = new ilTextInputGUI($this->lng->txt('chat_export_period'), 'chat_export_period');
244  $inp->setInfo($this->lng->txt('chat_export_period_info'));
245  $inp->setValidationRegexp('/[1-9][0-9]{0,2}/');
246  $inp->setRequired(true);
247  $inp->setSize(5);
248  $inp->setMaxLength(3);
249  $this->form_gui->addItem($inp);
250 
251  $this->form_gui->addCommandButton('update', $this->lng->txt('save'));
252  $this->form_gui->addCommandButton('cancel', $this->lng->txt('cancel'));
253  }
254 
255  /*
256  public function initialDBObject() {
257  //include_once 'Modules/Chat/classes/class.ilChatSmilies.php';
258  //ilChatSmilies::initial();
259  }
260  */
261 
262  public function uploadSmileyObject() {
263  global $rbacsystem, $ilSetting, $ilCtrl;
264 
265  if(!$rbacsystem->checkAccess('write', $this->ref_id))
266  {
267  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE);
268  }
269 
270  $this->initSmiliesForm();
271 
272  include_once "Modules/Chat/classes/class.ilChatSmilies.php";
273 
274  $keywords = ilChatSmilies::_prepareKeywords(ilUtil::stripSlashes($_REQUEST["chat_smiley_keywords"]));
275  $keywordscheck = count($keywords) > 0;
276 
277  if(!$this->form_gui->checkInput())
278  {
279  $this->tabs_gui->setTabActive('edit_smilies');
280  $this->form_gui->setValuesByPost();
281  $this->tpl->setContent($this->form_gui->getHtml());
282  return;
283  }
284  $pathinfo = pathinfo($_FILES["chat_image_path"]["name"]);
285  $target_file = md5(time() + $pathinfo['basename']).".".$pathinfo['extension'];
286 
287  move_uploaded_file($_FILES["chat_image_path"]["tmp_name"], ilChatSmilies::_getSmiliesBasePath() . $target_file);
288  ilChatSmilies::_storeSmiley(join("\n", $keywords), $target_file);
289  //$this->editSmiliesObject();
290  $ilCtrl->redirect($this, "editSmilies");
291  }
292 
293  public function deleteMultipleObject() {
294  global $rbacsystem, $ilSetting, $lng, $ilCtrl;
295  $this->tabs_gui->setTabActive('edit_smilies');
296  if(!$rbacsystem->checkAccess('write', $this->ref_id)) {
297  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE);
298  }
299 
300  $items = $_REQUEST["smiley_id"];
301 
302  if (count($items) == 0)
303  {
304  ilUtil::sendInfo($lng->txt('select_one'), true);
305  $ilCtrl->redirect($this, "editSmilies");
306  }
307 
308  include_once 'Modules/Chat/classes/class.ilChatSmilies.php';
309 
310  $smilies = ilChatSmilies::_getSmiliesById($items);
311  $tpl = new ilTemplate("tpl.chat_smilies_delete_multiple_confirm.html", true, true, "Modules/Chat");
312  $tpl->setVariable("SMILIES_DELETE_INTRO", $lng->txt('chat_confirm_delete_smiley'));
313  $tpl->setVariable("TXT_SUBMIT", $lng->txt('submit'));
314  $tpl->setVariable("TXT_CANCEL", $lng->txt('cancel'));
315  $tpl->setVariable("SMILIES_IDS", join(",", $items));
316  $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this,'update'));
317 
318  $i = 0;
319 
320  foreach($smilies as $s) {
321  $tpl->setCurrentBlock("smilies_list");
322  $tpl->setVariable("SMILEY_PATH", $s["smiley_fullpath"]);
323  $tpl->setVariable("SMILEY_KEYWORDS", $s["smiley_keywords"]);
324  $tpl->setVariable("ROW_CNT", ($i++ % 2) + 1);
325  $tpl->parseCurrentBlock();
326  }
327  $this->tpl->setContent($tpl->get());
328 
329  }
330 
331  public function confirmedDeleteMultipleObject() {
332  global $rbacsystem, $ilSetting, $lng, $ilCtrl;
333 
334  if(!$rbacsystem->checkAccess('write', $this->ref_id)) {
335  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE);
336  }
337 
338  $ids = $_REQUEST["sel_ids"];
339  $parts = explode(",", $ids);
340 
341  if (count($parts) == 0)
342  {
343  $ilCtrl->redirect($this, "editSmilies");
344  }
345 
346  include_once "Modules/Chat/classes/class.ilChatSmilies.php";
348  //$this->editSmiliesObject();
349  $ilCtrl->redirect($this, "editSmilies");
350  }
351 
352  public function initSmiliesForm()
353  {
354  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
355  $this->form_gui = new ilPropertyFormGUI();
356  $table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=".$_REQUEST["_table_nav"] : "";
357  $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'update'). $table_nav);
358 
359  // chat server settings
360  $sec_l = new ilFormSectionHeaderGUI();
361  $sec_l->setTitle($this->lng->txt('chat_add_smiley'));
362  $this->form_gui->addItem($sec_l);
363 
364  $inp = new ilImageFileInputGUI($this->lng->txt('chat_image_path'), 'chat_image_path');
365  $inp->setRequired(true);
366  $this->form_gui->addItem($inp);
367 
368  $inp = new ilTextAreaInputGUI($this->lng->txt('chat_smiley_keywords'), 'chat_smiley_keywords');
369  $inp->setRequired(true);
370  $inp->setUseRte(false);
371  $inp->setInfo($this->lng->txt('chat_smiley_keywords_one_per_line_note'));
372  $this->form_gui->addItem($inp);
373 
374  //$this->form_gui->addCommandButton('initialDB', $this->lng->txt('setup'));
375  $this->form_gui->addCommandButton('uploadSmiley', $this->lng->txt('chat_upload_smiley'));
376  //$this->form_gui->addCommandButton('cancel', $this->lng->txt('cancel'));
377  }
378 
379  public function initSmiliesEditForm()
380  {
381  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
382  $this->form_gui = new ilPropertyFormGUI();
383 
384  $table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=".$_REQUEST["_table_nav"] : "";
385 
386  $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'update') . $table_nav);
387 
388  // chat server settings
389  $sec_l = new ilFormSectionHeaderGUI();
390  $sec_l->setTitle($this->lng->txt('chat_edit_smiley'));
391  $this->form_gui->addItem($sec_l);
392 
393  include_once "Modules/Chat/classes/class.ilChatSmiliesCurrentSmileyFormElement.php";
394 
395  $inp = new ilChatSmiliesCurrentSmileyFormElement($this->lng->txt('chat_current_smiley_image_path'), 'chat_current_smiley_image_path');
396  $this->form_gui->addItem($inp);
397 
398  $inp = new ilImageFileInputGUI($this->lng->txt('chat_image_path'), 'chat_image_path');
399  $inp->setRequired(false);
400  $inp->setInfo($this->lng->txt('chat_smiley_image_only_if_changed'));
401  $this->form_gui->addItem($inp);
402 
403  $inp = new ilTextAreaInputGUI($this->lng->txt('chat_smiley_keywords'), 'chat_smiley_keywords');
404  $inp->setUseRte(false);
405  $inp->setRequired(true);
406  $inp->setInfo($this->lng->txt('chat_smiley_keywords_one_per_line_note'));
407  $this->form_gui->addItem($inp);
408 
409  $inp = new ilHiddenInputGUI('chat_smiley_id');
410  $this->form_gui->addItem($inp);
411 
412 
413  $this->form_gui->addCommandButton('updateSmilies', $this->lng->txt('submit'));
414  $this->form_gui->addCommandButton('editSmilies', $this->lng->txt('cancel'));
415  }
416 
417 
418  public function getValues()
419  {
420  global $ilSetting;
421 
422  $data = array();
423  $data['chat_internal_ip'] = $this->object->server_conf->getInternalIp();
424  $data['chat_external_ip'] = $this->object->server_conf->getExternalIp();
425  $data['chat_port'] = $this->object->server_conf->getPort();
426  $data['chat_ssl_status'] = $this->object->server_conf->getSSLStatus();
427  $data['chat_ssl_port'] = $this->object->server_conf->getSSLPort();
428  $data['chat_moderator'] = $this->object->server_conf->getModeratorPassword();
429  $data['chat_moderator_retype'] = $this->object->server_conf->getModeratorPassword();
430  $data['chat_logfile'] = $this->object->server_conf->getLogfile();
431  $data['chat_loglevel'] = $this->object->server_conf->getLogLevel();
432  $data['chat_allowed'] = $this->object->server_conf->getAllowedHosts();
433  $data['chat_active'] = $this->object->server_conf->getActiveStatus();
434  $data['chat_new_invitation_sound_status'] = (bool)$ilSetting->get('chat_new_invitation_sound_status');
435  $data['chat_new_message_sound_status'] = (bool)$ilSetting->get('chat_new_message_sound_status');
436  $data['chat_sound_status'] = (int)$ilSetting->get('chat_sound_status');
437  $data['chat_message_notify_status'] = (int) $ilSetting->get('chat_message_notify_status');
438  $data['chat_smilies_status'] = (int)$ilSetting->get('chat_smilies_status');
439  $data['chat_export_status'] = (int)$ilSetting->get('chat_export_status');
440  $data['chat_export_period'] = (int)$ilSetting->get('chat_export_period');
441 
442  $this->form_gui->setValuesByArray($data);
443  }
444 
445  public function editObject()
446  {
447  global $rbacsystem;
448 
449  $this->tabs_gui->setTabActive('settings');
450 
451  if(!$rbacsystem->checkAccess('read', $this->ref_id))
452  {
453  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilias->error_obj->MESSAGE);
454  }
455 
456  if(null === $this->form_gui)
457  {
458  $this->initForm('edit');
459  $this->getValues();
460  }
461 
462  $this->tpl->setContent($this->form_gui->getHTML());
463  }
464 
465  public function showEditSmileyEntryFormObject() {
466  global $rbacsystem;
467  $this->tabs_gui->setTabActive('edit_smilies');
468 
469  if(!$rbacsystem->checkAccess('read', $this->ref_id)) {
470  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilias->error_obj->MESSAGE);
471  }
472 
473  $this->initSmiliesEditForm();
474  include_once "Modules/Chat/classes/class.ilChatSmilies.php";
475  $smiley = ilChatSmilies::_getSmiley($_REQUEST["smiley_id"]);
476  $form_data = array(
477  "chat_smiley_id" => $smiley["smiley_id"],
478  "chat_smiley_keywords" => $smiley["smiley_keywords"],
479  "chat_current_smiley_image_path" => $smiley["smiley_fullpath"],
480  );
481  $this->form_gui->setValuesByArray($form_data);
482 
483  $tpl = new ilTemplate("tpl.chat_edit_smilies.html", true, true, "Modules/Chat");
484  $tpl->setVariable("SMILEY_FORM", $this->form_gui->getHTML());
485 
486  $this->tpl->setContent($tpl->get());
487  }
488 
489  public function showDeleteSmileyFormObject() {
490  global $rbacsystem, $lng, $ilCtrl;
491  $this->tabs_gui->setTabActive('edit_smilies');
492 
493  if(!$rbacsystem->checkAccess('write', $this->ref_id)) {
494  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE);
495  }
496 
497  $tpl = new ilTemplate("tpl.chat_smiley_confirm_delete.html", true, true, "Modules/Chat");
498  $tpl->setVariable("TXT_CONFIRM_DELETE_SMILEY", $lng->txt('chat_confirm_delete_smiley'));
499  $tpl->setVariable("TXT_CONFIRM_DELETE", $lng->txt('submit'));
500  $tpl->setVariable("TXT_CANCEL_DELETE", $lng->txt('cancel'));
501  $tpl->setVariable("SMILEY_ID", $_REQUEST["smiley_id"]);
502  //$tpl->setVariable("TABLE_NAV", $_REQUEST["_table_nav"]);
503 
504  include_once 'Modules/Chat/classes/class.ilChatSmilies.php';
505  $smiley = ilChatSmilies::_getSmiley($_REQUEST["smiley_id"]);
506 
507  $tpl->setVariable("SMILEY_PATH", $smiley["smiley_fullpath"]);
508  $tpl->setVariable("SMILEY_KEYWORDS", $smiley["smiley_keywords"]);
509 
510  $table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=".$_REQUEST["_table_nav"] : "";
511 
512  $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this). $table_nav);
513 
514  $tpl->parseCurrentBlock();
515  $this->tpl->setContent($tpl->get());
516  }
517 
518  public function deleteSmileyObject() {
519  global $rbacsystem, $ilCtrl;
520 
521  if(!$rbacsystem->checkAccess('write', $this->ref_id)) {
522  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE);
523  }
524  include_once 'Modules/Chat/classes/class.ilChatSmilies.php';
525  ilChatSmilies::_deleteSmiley($_REQUEST["chat_smiley_id"]);
526 
527  //$this->editSmiliesObject();
528  $ilCtrl->redirect($this, "editSmilies");
529  }
530 
531  public function editSmiliesObject()
532  {
533  global $rbacsystem;
534 
535  $this->tabs_gui->setTabActive('edit_smilies');
536 
537  if(!$rbacsystem->checkAccess('read', $this->ref_id)) {
538  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilias->error_obj->MESSAGE);
539  }
540  include_once 'Modules/Chat/classes/class.ilChatSmilies.php';
542 
543  $this->initSmiliesForm('edit');
544  include_once "Modules/Chat/classes/class.ilChatSmiliesGUI.php";
546 
547  $tpl = new ilTemplate("tpl.chat_edit_smilies.html", true, true, "Modules/Chat");
548  $tpl->setVariable("SMILEY_TABLE", $table);
549  $tpl->setVariable("SMILEY_FORM", $this->form_gui->getHTML());
550 
551  $this->tpl->setContent($tpl->get());
552 
553  }
554 
555  public function updateSmiliesObject() {
556  global $rbacsystem, $ilCtrl;
557  if(!$rbacsystem->checkAccess('write', $this->ref_id)) {
558  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE);
559  }
560  $this->initSmiliesEditForm();
561 
562  include_once "Modules/Chat/classes/class.ilChatSmilies.php";
563 
564  $keywords = ilChatSmilies::_prepareKeywords(ilUtil::stripSlashes($_REQUEST["chat_smiley_keywords"]));
565  $keywordscheck = count($keywords) > 0;
566 
567  if(!$this->form_gui->checkInput() || !$keywordscheck) {
568  $this->tabs_gui->setTabActive('edit_properties');
569  $this->form_gui->setValuesByPost();
570  $this->tpl->setContent($this->form_gui->getHtml());
571  return;
572  }
573  else {
574  $data = array();
575  $data["smiley_keywords"] = join("\n", $keywords);
576  $data["smiley_id"] = $_REQUEST["chat_smiley_id"];
577 
578  if ($_FILES["chat_image_path"]) {
579  move_uploaded_file($_FILES["chat_image_path"]["tmp_name"], ilChatSmilies::_getSmiliesBasePath() . $_FILES["chat_image_path"]["name"]);
580  $data["smiley_path"] = $_FILES["chat_image_path"]["name"];
581  }
582 
584  }
585  //$this->editSmiliesObject();
586  $ilCtrl->redirect($this, "editSmilies");
587  }
588 
589  public function updateObject()
590  {
591  global $rbacsystem, $ilSetting;
592 
593  if(!$rbacsystem->checkAccess('write', $this->ref_id))
594  {
595  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE);
596  }
597 
598  $this->tabs_gui->setTabActive('settings');
599 
600  $this->initForm('edit');
601  if(!$this->form_gui->checkInput())
602  {
603  $this->form_gui->setValuesByPost();
604  $this->tpl->setContent($this->form_gui->getHtml());
605  return;
606  }
607  else
608  {
609  $this->object->server_conf->setInternalIp(ilUtil::stripSlashes($_POST['chat_internal_ip']));
610  $this->object->server_conf->setExternalIp(ilUtil::stripSlashes($_POST['chat_external_ip']));
611  $this->object->server_conf->setPort(ilUtil::stripSlashes($_POST['chat_port']));
612  $this->object->server_conf->setSSLStatus((int)$_POST['chat_ssl_status'] ? 1 : 0);
613  $this->object->server_conf->setSSLPort(ilUtil::stripSlashes($_POST['chat_ssl_port']));
614  $this->object->server_conf->setModeratorPassword(ilUtil::stripSlashes($_POST['chat_moderator']));
615  $this->object->server_conf->setLogfile(ilUtil::stripSlashes($_POST['chat_logfile']));
616  $this->object->server_conf->setLogLevel(ilUtil::stripSlashes($_POST['chat_loglevel']));
617  $this->object->server_conf->setAllowedHosts(ilUtil::stripSlashes($_POST['chat_allowed']));
618 
619  $this->object->server_conf->validate();
620 
621  $ilSetting->set('chat_sound_status', (int)$_POST['chat_sound_status']);
622  $ilSetting->set('chat_new_invitation_sound_status', (int)$_POST['chat_new_invitation_sound_status']);
623  $ilSetting->set('chat_new_message_sound_status', (int)$_POST['chat_new_message_sound_status']);
624  $ilSetting->set('chat_message_notify_status', (int)$_POST['chat_message_notify_status']);
625  $ilSetting->set('chat_smilies_status', (int)$_POST['chat_smilies_status']);
626  $ilSetting->set('chat_export_status', (int)$_POST['chat_export_status']);
627  $ilSetting->set('chat_export_period', (int)$_POST['chat_export_period']);
628 
629  $this->object->server_conf->setActiveStatus((bool)$_POST['chat_active']);
630  $this->object->server_conf->updateStatus();
631 
632  if(!$this->object->server_conf->update())
633  {
634  ilUtil::sendFailure($this->object->server_conf->getErrorMessage());
635  $this->form_gui->setValuesByPost();
636  $this->tpl->setContent($this->form_gui->getHtml());
637  return;
638  }
639  else
640  {
641  $this->form_gui->setValuesByPost();
642  }
643  }
644 
645  ilUtil::sendSuccess($this->lng->txt('chat_settings_saved'), true);
646  return $this->editObject();
647  }
648 
654  function getAdminTabs(&$tabs_gui)
655  {
656  global $rbacsystem,$rbacreview;
657 
658  $this->ctrl->setParameter($this,'ref_id',$this->object->getRefId());
659 
660  if($rbacsystem->checkAccess('read',$this->object->getRefId()))
661  {
662  $force_active = ($_GET['cmd'] == '' || $_GET['cmd'] == 'view')
663  ? true
664  : false;
665  $tabs_gui->addTarget('chat_rooms',
666  $this->ctrl->getLinkTarget($this, 'view'), array('view', ''), get_class($this),
667  '', $force_active);
668  }
669  if($rbacsystem->checkAccess('write',$this->object->getRefId()))
670  {
671  $force_active_edit = ($_GET["cmd"] == "edit") ? true : false;
672  $force_active_smilies = ($_GET["cmd"] == "edit") ? true : false;
673  $tabs_gui->addTarget("settings", $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this),"", $force_active_edit);
674  $tabs_gui->addTarget("edit_smilies", $this->ctrl->getLinkTarget($this, "editSmilies"), "edit_smilies", get_class($this),"", $force_active_smilies);
675  }
676  if($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
677  {
678  $tabs_gui->addTarget('perm_settings',
679  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), 'perm'), array('perm','info','owner'), 'ilpermissiongui');
680  }
681  }
682 } // END class.ilObjChatServerGUI
683 ?>