4 require_once
'Modules/Chatroom/classes/class.ilChatroom.php';
32 $this->commonSettings =
new ilSetting(
'common');
38 private function showSoapWarningIfNeeded()
45 if(!$this->commonSettings->get(
'soap_user_administration'))
54 public function saveSettings()
62 require_once
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
64 $form = $factory->getGeneralSettingsForm();
66 if(!$form->checkInput())
68 $form->setValuesByPost();
69 $this->serversettings($form);
75 $form->setValuesByPost();
77 $this->serversettings($form);
82 'protocol' => $form->getInput(
'protocol'),
83 'instance' => $form->getInput(
'instance'),
84 'port' => $form->getInput(
'port'),
85 'address' => $form->getInput(
'address'),
86 'priv_hosts' => $form->getInput(
'priv_hosts'),
87 'keystore' => $form->getInput(
'keystore'),
88 'keypass' => $form->getInput(
'keypass'),
89 'storepass' => $form->getInput(
'storepass')
92 require_once
'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
94 $adminSettings->saveGeneralSettings((
object)$settings);
99 $ilCtrl->redirect($this->gui,
'view-serversettings');
105 public function saveClientSettings()
113 require_once
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
115 $form = $factory->getClientSettingsForm();
117 if(!$form->checkInput())
119 $form->setValuesByPost();
120 $this->clientsettings($form);
125 'hash' => $form->getInput(
'name'),
126 'name' => $form->getInput(
'name'),
127 'url' => $form->getInput(
'url'),
128 'user' => $form->getInput(
'user'),
129 'password' => $form->getInput(
'password'),
130 'client' => CLIENT_ID,
131 'enable_osd' => (boolean)$form->getInput(
'enable_osd'),
132 'osd_intervall' => (int)$form->getInput(
'osd_intervall'),
133 'chat_enabled' => ((boolean)$form->getInput(
'chat_enabled')) && ((
boolean)$this->commonSettings->get(
'soap_user_administration')),
134 'enable_smilies' => (
boolean)$form->getInput(
'enable_smilies'),
135 'play_invitation_sound' => (boolean)$form->getInput(
'play_invitation_sound')
138 $notificationSettings =
new ilSetting(
'notifications');
139 $notificationSettings->set(
'osd_polling_intervall', (
int)$form->getInput(
'osd_intervall'));
140 $notificationSettings->set(
'enable_osd', (
boolean)$form->getInput(
'enable_osd'));
142 $chatSettings =
new ilSetting(
'chatroom');
143 $chatSettings->set(
'chat_enabled', $settings[
'chat_enabled']);
144 $chatSettings->set(
'play_invitation_sound', (
boolean)$form->getInput(
'play_invitation_sound'));
146 require_once
'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
148 $adminSettings->saveClientSettings((
object)$settings);
154 $ilCtrl->redirect($this->gui,
'view-clientsettings');
166 $handle = fopen($srv_prp_path .
'client.properties',
'w');
170 throw new Exception(
'Cannot write to file');
186 $content =
'hash = ' . $settings[
'hash'] . $linebreak;
187 $content .=
'name = ' . $settings[
'name'] . $linebreak;
188 $content .=
'url = ' . $settings[
'url'] . $linebreak;
189 $content .=
'user = ' . $settings[
'user'] . $linebreak;
190 $content .=
'password = ' . $settings[
'password'] . $linebreak;
191 $content .=
'client = ' . $settings[
'client'];
205 $handle = fopen($srv_prp_path .
'server.properties',
'w');
209 throw new Exception(
'Cannot write to file');
225 $content =
'host = ' . $settings[
'address'] . $linebreak;
226 $content .=
'port = ' . $settings[
'port'] . $linebreak;
227 $content .=
'privileged_hosts = ' . $settings[
'priv_hosts'] . $linebreak;
229 $settings[
'protocol'] ==
'https' ?
$https = 1 :
$https = 0;
231 $content .=
'https = ' .
$https . $linebreak;
232 $content .=
'keystore = ' . $settings[
'keystore'] . $linebreak;
233 $content .=
'keypass = ' . $settings[
'keypass'] . $linebreak;
234 $content .=
'storepass = ' . $settings[
'storepass'];
248 if(!file_exists($srv_prp_path))
252 throw new Exception(
'Directory cannot be created');
256 return $srv_prp_path;
268 $ipnumbers = preg_replace(
"/[^0-9.,]+/",
"", $ipnumbers);
269 $ips = explode(
',', $ipnumbers);
273 $ip_parts = explode(
'.', $ip);
275 if(!($ip_parts[0] <= 255 && $ip_parts[1] <= 255 && $ip_parts[2] <= 255 && $ip_parts[3] <= 255 &&
276 preg_match(
"!^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$!", $ip))
300 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
305 $this->gui->switchToVisibleMode();
306 $this->showSoapWarningIfNeeded();
308 require_once
'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
310 $serverSettings = (array)$adminSettings->loadGeneralSettings();
313 require_once
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
315 $form = $factory->getGeneralSettingsForm();
317 if(!$serverSettings[
'protocol'])
319 $serverSettings[
'protocol'] =
'http';
322 $form->setValuesByArray($serverSettings);
325 require_once
'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
332 $form->setTitle($lng->txt(
'chatserver_settings_title'));
333 $form->addCommandButton(
'view-saveSettings', $lng->txt(
'save'));
334 $form->setFormAction($ilCtrl->getFormAction($this->gui,
'view-saveSettings'));
335 $serverTpl =
new ilTemplate(
'tpl.chatroom_serversettings.html',
true,
true,
'Modules/Chatroom');
337 $serverTpl->setVariable(
'VAL_SERVERSETTINGS_FORM', $form->getHTML());
338 $serverTpl->setVariable(
'LBL_SERVERSETTINGS_FURTHER_INFORMATION', sprintf($lng->txt(
'server_further_information'),
ilUtil::_getHttpPath() .
'/Modules/Chatroom/server/README.txt'));
340 $tpl->setVariable(
'ADM_CONTENT', $serverTpl->get());
354 $ilCtrl->redirect($this->gui,
'view-clientsettings');
373 $this->gui->switchToVisibleMode();
375 $this->showSoapWarningIfNeeded();
377 require_once
'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
382 require_once
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
384 $form = $factory->getClientSettingsForm();
386 if(!$this->commonSettings->get(
'soap_user_administration'))
388 $form->getItemByPostVar(
'chat_enabled')->setDisabled(!(
boolean)$this->commonSettings->get(
'soap_user_administration'));
389 $form->getItemByPostVar(
'chat_enabled')->setChecked(0);
392 $data = (array)$adminSettings->loadClientSettings();
394 if(!
$data[
'osd_intervall'])
396 $data[
'osd_intervall'] = 60;
411 $data[
'client'] = CLIENT_ID;
415 $form->setValuesByArray(
$data);
418 require_once
'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
420 $serverSettings = (array)$adminSettings->loadGeneralSettings();
426 $form->setTitle($lng->txt(
'general_settings_title'));
427 $form->addCommandButton(
'view-saveClientSettings', $lng->txt(
'save'));
428 $form->setFormAction($ilCtrl->getFormAction($this->gui,
'view-saveClientSettings'));
430 $settingsTpl =
new ilTemplate(
'tpl.chatroom_serversettings.html',
true,
true,
'Modules/Chatroom');
432 $settingsTpl->setVariable(
'VAL_SERVERSETTINGS_FORM', $form->getHTML());
433 $settingsTpl->setVariable(
'LBL_SERVERSETTINGS_FURTHER_INFORMATION', sprintf($lng->txt(
'server_further_information'),
ilUtil::_getHttpPath() .
'/Modules/Chatroom/server/README.txt'));
435 $tpl->setVariable(
'ADM_CONTENT', $settingsTpl->get());
443 $chatSettings =
new ilSetting(
'chatroom');
444 if($chatSettings->get(
'chat_enabled',
false))
458 $this->createPublicRoom();
465 $this->createPublicRoom();
472 $this->createPublicRoom();
478 $this->createPublicRoom();
486 public function createPublicRoom()
493 require_once
'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
494 ilChatroomInstaller::createDefaultPublicRoom(
true);