ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilChatroomAdminViewGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
5require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
6require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
7require_once 'Modules/Chatroom/classes/class.ilChatroomConfigFileHandler.php';
8
17{
18
19 const CHATROOM_README_PATH = '/Modules/Chatroom/chat/README.txt';
20
24 protected $commonSettings;
25
29 protected $ilTpl;
30
36 {
37 global $tpl;
38
39 parent::__construct($gui);
40 $this->commonSettings = new ilSetting('common');
41 $this->ilTpl = $tpl;
42 }
43
47 public function executeDefault($method)
48 {
49 $this->ilCtrl->redirect($this->gui, 'view-clientsettings');
50 }
51
55 public function saveSettings()
56 {
57 $factory = new ilChatroomFormFactory();
58 $form = $factory->getGeneralSettingsForm();
59
60 if(!$form->checkInput())
61 {
62 $form->setValuesByPost();
63 $this->serversettings($form);
64 return;
65 }
66
67 $settings = array(
68 'protocol' => $form->getInput('protocol'),
69 'port' => $form->getInput('port'),
70 'address' => $form->getInput('address'),
71 'cert' => $form->getInput('cert'),
72 'key' => $form->getInput('key'),
73 'dhparam' => $form->getInput('dhparam'),
74 'log' => $form->getInput('log'),
75 'error_log' => $form->getInput('error_log'),
76 'ilias_proxy' => $form->getInput('ilias_proxy'),
77 'ilias_url' => $form->getInput('ilias_url'),
78 'client_proxy' => $form->getInput('client_proxy'),
79 'client_url' => $form->getInput('client_url'),
80 'sub_directory'=> $form->getInput('sub_directory'),
81 'deletion_mode'=> $form->getInput('deletion_mode'),
82 'deletion_unit'=> $form->getInput('deletion_unit'),
83 'deletion_value'=> $form->getInput('deletion_value'),
84 'deletion_time' => $form->getInput('deletion_time'),
85 );
86
87 $adminSettings = new ilChatroomAdmin($this->gui->object->getId());
88 $adminSettings->saveGeneralSettings((object)$settings);
89
90 $fileHandler = new ilChatroomConfigFileHandler();
91 $fileHandler->createServerConfigFile($settings);
92
93 ilUtil::sendSuccess($this->ilLng->txt('settings_has_been_saved'), true);
94 $this->ilCtrl->redirect($this->gui, 'view-serversettings');
95 }
96
101 public function serversettings(ilPropertyFormGUI $form = null)
102 {
103 ilChatroom::checkUserPermissions('read', $this->gui->ref_id);
104
105 $this->defaultActions();
106 $this->gui->switchToVisibleMode();
107
108 $adminSettings = new ilChatroomAdmin($this->gui->object->getId());
109 $serverSettings = $adminSettings->loadGeneralSettings();
110
111 if($form === null)
112 {
113 $factory = new ilChatroomFormFactory();
114 $form = $factory->getGeneralSettingsForm();
115 $form->setValuesByArray($serverSettings);
116 }
117
118 $this->checkServerConnection($serverSettings);
119
120 $form->setTitle($this->ilLng->txt('chatserver_settings_title'));
121 $form->addCommandButton('view-saveSettings', $this->ilLng->txt('save'));
122 $form->setFormAction($this->ilCtrl->getFormAction($this->gui, 'view-saveSettings'));
123
124 $settingsTpl = $this->createSettingTemplate($form);
125 $this->ilTpl->setVariable('ADM_CONTENT', $settingsTpl->get());
126 }
127
131 private function defaultActions()
132 {
133 $chatSettings = new ilSetting('chatroom');
134 if($chatSettings->get('chat_enabled', false))
135 {
136 $this->forcePublicRoom();
137 }
138 }
139
143 public function forcePublicRoom()
144 {
146 if(!$ref_id)
147 {
148 $this->createPublicRoom();
149 return;
150 }
151
153 if(!$instance)
154 {
155 $this->createPublicRoom();
156 return;
157 }
158
160 if(!$obj_id)
161 {
162 $this->createPublicRoom();
163 return;
164 }
165
167 {
168 $this->createPublicRoom();
169 return;
170 }
171
172 require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
173 ilChatroomInstaller::ensureCorrectPublicChatroomTreeLocation($ref_id);
174 }
175
179 public function createPublicRoom()
180 {
181 require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
182 ilChatroomInstaller::createDefaultPublicRoom(true);
183 ilUtil::sendSuccess($this->ilLng->txt('public_chat_created'), true);
184 }
185
190 protected function checkServerConnection(array $serverSettings)
191 {
192 require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
193
194 if(
195 $serverSettings['port'] &&
196 $serverSettings['address'] &&
198 )
199 {
200 ilUtil::sendInfo($this->ilLng->txt('chat_cannot_connect_to_server'));
201 }
202 }
203
208 protected function createSettingTemplate(ilPropertyFormGUI $form)
209 {
210 $furtherInformation = sprintf($this->ilLng->txt('server_further_information'), $this->getReadmePath());
211 $serverTpl = new ilTemplate('tpl.chatroom_serversettings.html', true, true, 'Modules/Chatroom');
212 $serverTpl->setVariable('VAL_SERVERSETTINGS_FORM', $form->getHTML());
213 $serverTpl->setVariable('LBL_SERVERSETTINGS_FURTHER_INFORMATION', $furtherInformation);
214
215 return $serverTpl;
216 }
217
222 protected function getReadmePath()
223 {
225 }
226
230 public function saveClientSettings()
231 {
232 $factory = new ilChatroomFormFactory();
233 $form = $factory->getClientSettingsForm();
234
235 if(!$form->checkInput())
236 {
237 $form->setValuesByPost();
238 $this->clientsettings($form);
239 return;
240 }
241
242 $settings = array(
243 'name' => (string)$form->getInput('client_name'),
244 'enable_osd' => (boolean)$form->getInput('enable_osd'),
245 'enable_osc' => (boolean)$form->getInput('enable_osc'),
246 'osd_intervall' => (int)$form->getInput('osd_intervall'),
247 'chat_enabled' => ((boolean)$form->getInput('chat_enabled')),
248 'enable_smilies' => (boolean)$form->getInput('enable_smilies'),
249 'play_invitation_sound' => (boolean)$form->getInput('play_invitation_sound'),
250 'auth' => $form->getInput('auth')
251 );
252
253 if (!$settings['chat_enabled']) {
254 $settings['enable_osc'] = false;
255 }
256
257 $notificationSettings = new ilSetting('notifications');
258 $notificationSettings->set('osd_polling_intervall', (int)$form->getInput('osd_intervall'));
259 $notificationSettings->set('enable_osd', (boolean)$form->getInput('enable_osd'));
260
261 $chatSettings = new ilSetting('chatroom');
262 $chatSettings->set('chat_enabled', $settings['chat_enabled']);
263 $chatSettings->set('enable_osc', $settings['enable_osc']);
264 $chatSettings->set('play_invitation_sound', (boolean)$form->getInput('play_invitation_sound'));
265
266 $adminSettings = new ilChatroomAdmin($this->gui->object->getId());
267 $adminSettings->saveClientSettings((object)$settings);
268
269 $fileHandler = new ilChatroomConfigFileHandler();
270 $fileHandler->createClientConfigFile($settings);
271
272 ilUtil::sendSuccess($this->ilLng->txt('settings_has_been_saved'), true);
273 $this->ilCtrl->redirect($this->gui, 'view-clientsettings');
274 }
275
279 public function clientsettings(ilPropertyFormGUI $form = null)
280 {
281 ilChatroom::checkUserPermissions('read', $this->gui->ref_id);
282
283 $this->defaultActions();
284 $this->gui->switchToVisibleMode();
285
286 $adminSettings = new ilChatroomAdmin($this->gui->object->getId());
287 $serverSettings = $adminSettings->loadGeneralSettings();
288
289 if($form === null)
290 {
291 $clientSettings = $adminSettings->loadClientSettings();
292 $factory = new ilChatroomFormFactory();
293 $form = $factory->getClientSettingsForm();
294 $form->setValuesByArray($clientSettings);
295 }
296
297 $this->checkServerConnection($serverSettings);
298
299 $form->setTitle($this->ilLng->txt('general_settings_title'));
300 $form->addCommandButton('view-saveClientSettings', $this->ilLng->txt('save'));
301 $form->setFormAction($this->ilCtrl->getFormAction($this->gui, 'view-saveClientSettings'));
302
303 $settingsTpl = $this->createSettingTemplate($form);
304 $this->ilTpl->setVariable('ADM_CONTENT', $settingsTpl->get());
305 }
306}
sprintf('%.4f', $callTime)
global $tpl
Definition: ilias.php:8
An exception for terminatinating execution or to throw for unit testing.
Class ilChatroomAdminViewGUI.
saveSettings()
Saves settings fetched from $_POST.
__construct(ilChatroomObjectGUI $gui)
Constructor.
serversettings(ilPropertyFormGUI $form=null)
Prepares view form and displays it.
createPublicRoom()
Creates a public chatroom.
checkServerConnection(array $serverSettings)
Checks for server connection.
saveClientSettings()
Saves client settings fetched from $_POST.
clientsettings(ilPropertyFormGUI $form=null)
getReadmePath()
Get the path to the README.txt file.
createSettingTemplate(ilPropertyFormGUI $form)
Class ilChatroomAdmin.
Class ilChatroomFormFactory.
Class ilChatroomGUIHandler.
static checkServerConnection($use_cache=true)
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
This class provides processing control methods.
getFormAction($a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get form action url for gui class object.
redirect($a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to another command.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupObjId($a_id)
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
This class represents a property form user interface.
ILIAS Setting Class.
special template class to simplify handling of ITX/PEAR
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _getHttpPath()
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$ref_id
Definition: sahs_server.php:39