ILIAS  Release_3_10_x_branch Revision 61812
 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-2001 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  function ilObjChatServerGUI($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  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("./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  $cmd .= 'Object';
76  $this->$cmd();
77 
78  break;
79  }
80  return true;
81  }
82 
83  public function initForm($a_mode)
84  {
85  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
86  $this->form_gui = new ilPropertyFormGUI();
87  $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'update'));
88 
89  if($this->object->server_conf->isAlive() or $this->object->server_conf->getActiveStatus())
90  {
91  // activation/deactivation of chat module
92  $sec_cd = new ilFormSectionHeaderGUI();
93  $sec_cd->setTitle($this->lng->txt('chat_ilias'));
94  $this->form_gui->addItem($sec_cd);
95 
96  $sel = new ilSelectInputGUI($this->lng->txt('chat_status'), 'chat_active');
97  $options = array(
98  1 => $this->lng->txt('chat_active'),
99  0 => $this->lng->txt('chat_inactive')
100  );
101  $sel->setOptions($options);
102  $sel->setValue(1);
103  $this->form_gui->addItem($sel);
104  }
105  else if(!$this->object->server_conf->isAlive() && $this->ctrl->getCmd() != 'update')
106  {
107  ilUtil::sendInfo($this->lng->txt('chat_cannot_connect_to_server'));
108  }
109 
110  // chat server settings
111  $sec_l = new ilFormSectionHeaderGUI();
112  $sec_l->setTitle($this->lng->txt('chat_server_settings'));
113  $this->form_gui->addItem($sec_l);
114 
115  // sever internal ip
116  $inp = new ilTextInputGUI($this->lng->txt('chat_server_internal_ip'), 'chat_internal_ip');
117  $inp->setRequired(true);
118  $inp->setSize(40);
119  $inp->setMaxLength(128);
120  $this->form_gui->addItem($inp);
121 
122  // server address
123  $inp = new ilTextInputGUI($this->lng->txt('chat_server_external_ip'), 'chat_external_ip');
124  $inp->setRequired(true);
125  $inp->setSize(40);
126  $inp->setMaxLength(128);
127  $this->form_gui->addItem($inp);
128 
129  // server port
130  $inp = new ilTextInputGUI($this->lng->txt('chat_server_port'), 'chat_port');
131  $inp->setRequired(true);
132  $inp->setSize(5);
133  $inp->setMaxLength(5);
134  $this->form_gui->addItem($inp);
135 
136  // ssl
137  $chb = new ilCheckboxInputGUI($this->lng->txt('chat_server_ssl_settings'), 'chat_ssl_status');
138  $chb->setOptionTitle($this->lng->txt('chat_server_ssl_active'));
139  $chb->setChecked(false);
140  $inp = new ilTextInputGUI($this->lng->txt('chat_server_ssl_port'), 'chat_ssl_port');
141  $inp->setSize(5);
142  $inp->setMaxLength(5);
143  $chb->addSubItem($inp);
144  $this->form_gui->addItem($chb);
145 
146  // moderator password
147  $inp = new ilPasswordInputGUI($this->lng->txt('chat_moderator_password'), 'chat_moderator');
148  $inp->setRequired(true);
149  $inp->setSize(9);
150  $inp->setMaxLength(16);
151  $this->form_gui->addItem($inp);
152 
153  // logfile path
154  $inp = new ilTextInputGUI($this->lng->txt('chat_server_logfile'), 'chat_logfile');
155  $inp->setSize(40);
156  $inp->setMaxLength(256);
157  $this->form_gui->addItem($inp);
158 
159  // log level
160  $sel = new ilSelectInputGUI($this->lng->txt('chat_server_loglevel'), 'chat_loglevel');
161  $options = array(
162  1 => $this->lng->txt('chat_level_fatal'),
163  2 => $this->lng->txt('chat_level_error'),
164  3 => $this->lng->txt('chat_level_info'),
165  5 => $this->lng->txt('chat_level_debug'),
166  6 => $this->lng->txt('chat_level_all')
167  );
168  $sel->setOptions($options);
169  $sel->setValue(1);
170  $this->form_gui->addItem($sel);
171 
172  // allowed hosts
173  $inp = new ilTextInputGUI($this->lng->txt('chat_server_allowed'), 'chat_allowed');
174  $inp->setInfo($this->lng->txt('chat_server_allowed_b'));
175  $inp->setRequired(true);
176  $inp->setSize(40);
177  $inp->setMaxLength(256);
178  $this->form_gui->addItem($inp);
179 
180  // chat general settings
181  $sec_cd = new ilFormSectionHeaderGUI();
182  $sec_cd->setTitle($this->lng->txt('chat_general_settings'));
183  $this->form_gui->addItem($sec_cd);
184 
185  // sound activation/deactivation for new chat invitations
186  $rg = new ilRadioGroupInputGUI($this->lng->txt('chat_sounds'), 'chat_sound_status');
187  $rg->setValue(0);
188  $ro = new ilRadioOption($this->lng->txt('chat_sound_status_activate'), 1);
189  $chb = new ilCheckboxInputGUI('', 'chat_new_invitation_sound_status');
190  $chb->setOptionTitle($this->lng->txt('chat_new_invitation_sound_status'));
191  $chb->setChecked(false);
192  $ro->addSubItem($chb);
193  $rg->addOption($ro);
194  $ro = new ilRadioOption($this->lng->txt('chat_sound_status_deactivate'), 0);
195  $rg->addOption($ro);
196  $this->form_gui->addItem($rg);
197 
198  $this->form_gui->addCommandButton('update', $this->lng->txt('save'));
199  $this->form_gui->addCommandButton('cancel', $this->lng->txt('cancel'));
200  }
201 
202  public function getValues()
203  {
204  global $ilSetting;
205 
206  $data = array();
207  $data['chat_internal_ip'] = $this->object->server_conf->getInternalIp();
208  $data['chat_external_ip'] = $this->object->server_conf->getExternalIp();
209  $data['chat_port'] = $this->object->server_conf->getPort();
210  $data['chat_ssl_status'] = $this->object->server_conf->getSSLStatus();
211  $data['chat_ssl_port'] = $this->object->server_conf->getSSLPort();
212  $data['chat_moderator'] = $this->object->server_conf->getModeratorPassword();
213  $data['chat_logfile'] = $this->object->server_conf->getLogfile();
214  $data['chat_loglevel'] = $this->object->server_conf->getLogLevel();
215  $data['chat_allowed'] = $this->object->server_conf->getAllowedHosts();
216  $data['chat_active'] = $this->object->server_conf->getActiveStatus();
217  $data['chat_new_invitation_sound_status'] = (bool)$ilSetting->get('chat_new_invitation_sound_status');
218  $data['chat_sound_status'] = (int)$ilSetting->get('chat_sound_status');
219 
220  $this->form_gui->setValuesByArray($data);
221  }
222 
223  public function editObject()
224  {
225  global $rbacsystem;
226 
227  $this->tabs_gui->setTabActive('edit_properties');
228 
229  if(!$rbacsystem->checkAccess('read', $this->ref_id))
230  {
231  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilias->error_obj->MESSAGE);
232  }
233 
234  $this->initForm('edit');
235  $this->getValues();
236  $this->tpl->setContent($this->form_gui->getHTML());
237  }
238 
239  public function updateObject()
240  {
241  global $rbacsystem, $ilSetting;
242 
243  if(!$rbacsystem->checkAccess('write', $this->ref_id))
244  {
245  $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE);
246  }
247 
248  $this->initForm('edit');
249 
250  if(!$this->form_gui->checkInput())
251  {
252  $this->tabs_gui->setTabActive('edit_properties');
253 
254  $this->form_gui->setValuesByPost();
255 
256  $this->tpl->setContent($this->form_gui->getHtml());
257  return;
258  }
259  else
260  {
261  $this->object->server_conf->setInternalIp(ilUtil::stripSlashes($_POST['chat_internal_ip']));
262  $this->object->server_conf->setExternalIp(ilUtil::stripSlashes($_POST['chat_external_ip']));
263  $this->object->server_conf->setPort(ilUtil::stripSlashes($_POST['chat_port']));
264  $this->object->server_conf->setSSLStatus((int)$_POST['chat_ssl_status'] ? 1 : 0);
265  $this->object->server_conf->setSSLPort(ilUtil::stripSlashes($_POST['chat_ssl_port']));
266  $this->object->server_conf->setModeratorPassword(ilUtil::stripSlashes($_POST['chat_moderator']));
267  $this->object->server_conf->setLogfile(ilUtil::stripSlashes($_POST['chat_logfile']));
268  $this->object->server_conf->setLogLevel(ilUtil::stripSlashes($_POST['chat_loglevel']));
269  $this->object->server_conf->setAllowedHosts(ilUtil::stripSlashes($_POST['chat_allowed']));
270 
271  $this->object->server_conf->validate();
272 
273  $ilSetting->set('chat_sound_status', (int)$_POST['chat_sound_status']);
274  $ilSetting->set('chat_new_invitation_sound_status', (int)$_POST['chat_new_invitation_sound_status']);
275 
276  $this->object->server_conf->setActiveStatus((bool)$_POST['chat_active']);
277  $this->object->server_conf->updateStatus();
278 
279  if(!$this->object->server_conf->update())
280  {
281  ilUtil::sendInfo($this->object->server_conf->getErrorMessage());
282  return $this->editObject();
283  }
284  }
285 
286  ilUtil::sendInfo($this->lng->txt('chat_settings_saved'), true);
287  return $this->editObject();
288  }
289 
295  function getAdminTabs(&$tabs_gui)
296  {
297  global $rbacsystem,$rbacreview;
298 
299  $this->ctrl->setParameter($this,"ref_id",$this->object->getRefId());
300 
301  if($rbacsystem->checkAccess('read',$this->object->getRefId()))
302  {
303  $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "view")
304  ? true
305  : false;
306  $tabs_gui->addTarget("chat_rooms",
307  $this->ctrl->getLinkTarget($this, "view"), array("view", ""), get_class($this),
308  "", $force_active);
309  }
310  if($rbacsystem->checkAccess('write',$this->object->getRefId()))
311  {
312  $force_active = ($_GET["cmd"] == "edit")
313  ? true
314  : false;
315  $tabs_gui->addTarget("edit_properties",
316  $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this),
317  "", $force_active);
318  }
319  if($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
320  {
321  $tabs_gui->addTarget("perm_settings",
322  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
323  }
324  }
325 } // END class.ilObjChatServerGUI
326 ?>