ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 const CHATROOM_README_PATH = '/Modules/Chatroom/README.md';
19
23 protected $commonSettings;
24
28 protected $ilTpl;
29
35 {
36 global $DIC;
37
38 parent::__construct($gui);
39 $this->commonSettings = new ilSetting('common');
40 $this->ilTpl = $DIC->ui()->mainTemplate();
41 }
42
46 public function executeDefault($method)
47 {
48 $this->ilCtrl->redirect($this->gui, 'view-clientsettings');
49 }
50
54 public function saveSettings()
55 {
56 $this->redirectIfNoPermission('write');
57
59 $form = $factory->getGeneralSettingsForm();
60
61 if (!$form->checkInput()) {
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 $this->redirectIfNoPermission('read');
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) {
113 $form = $factory->getGeneralSettingsForm();
114 $form->setValuesByArray($serverSettings);
115 }
116
117 $this->checkServerConnection($serverSettings);
118
119 $form->setTitle($this->ilLng->txt('chatserver_settings_title'));
120 if (ilChatroom::checkUserPermissions('write', $this->gui->ref_id, false)) {
121 $form->addCommandButton('view-saveSettings', $this->ilLng->txt('save'));
122 }
123 $form->setFormAction($this->ilCtrl->getFormAction($this->gui, 'view-saveSettings'));
124
125 $settingsTpl = $this->createSettingTemplate($form);
126 $this->ilTpl->setVariable('ADM_CONTENT', $settingsTpl->get());
127 }
128
132 private function defaultActions()
133 {
134 $chatSettings = new ilSetting('chatroom');
135 if ($chatSettings->get('chat_enabled', false)) {
136 $this->forcePublicRoom();
137 }
138 }
139
143 public function forcePublicRoom()
144 {
146 if (!$ref_id) {
147 $this->createPublicRoom();
148 return;
149 }
150
151 $instance = ilObjectFactory::getInstanceByRefId($ref_id, false);
152 if (!$instance) {
153 $this->createPublicRoom();
154 return;
155 }
156
157 $obj_id = ilObject::_lookupObjId($ref_id);
158 if (!$obj_id) {
159 $this->createPublicRoom();
160 return;
161 }
162
163 if (!ilObject::_hasUntrashedReference($obj_id)) {
164 $this->createPublicRoom();
165 return;
166 }
167
168 require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
169 ilChatroomInstaller::ensureCorrectPublicChatroomTreeLocation($ref_id);
170 }
171
175 public function createPublicRoom()
176 {
177 require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
178 ilChatroomInstaller::createDefaultPublicRoom(true);
179 ilUtil::sendSuccess($this->ilLng->txt('public_chat_created'), true);
180 }
181
186 protected function checkServerConnection(array $serverSettings)
187 {
188 require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
189
190 if (
191 $serverSettings['port'] &&
192 $serverSettings['address'] &&
194 ) {
195 ilUtil::sendInfo($this->ilLng->txt('chat_cannot_connect_to_server'));
196 }
197 }
198
204 {
205 $furtherInformation = sprintf($this->ilLng->txt('server_further_information'), $this->getReadmePath());
206 $serverTpl = new ilTemplate('tpl.chatroom_serversettings.html', true, true, 'Modules/Chatroom');
207 $serverTpl->setVariable('VAL_SERVERSETTINGS_FORM', $form->getHTML());
208 $serverTpl->setVariable('LBL_SERVERSETTINGS_FURTHER_INFORMATION', $furtherInformation);
209
210 return $serverTpl;
211 }
212
217 protected function getReadmePath()
218 {
220 }
221
225 public function saveClientSettings()
226 {
227 $this->redirectIfNoPermission('write');
228
230 $form = $factory->getClientSettingsForm();
231
232 if (!$form->checkInput()) {
233 $form->setValuesByPost();
234 $this->clientsettings($form);
235 return;
236 }
237
238 $settings = array(
239 'name' => (string) $form->getInput('client_name'),
240 'enable_osd' => (boolean) $form->getInput('enable_osd'),
241 'enable_osc' => (boolean) $form->getInput('enable_osc'),
242 'osd_intervall' => (int) $form->getInput('osd_intervall'),
243 'chat_enabled' => ((boolean) $form->getInput('chat_enabled')),
244 'enable_smilies' => (boolean) $form->getInput('enable_smilies'),
245 'play_invitation_sound' => (boolean) $form->getInput('play_invitation_sound'),
246 'auth' => $form->getInput('auth')
247 );
248
249 if (!$settings['chat_enabled']) {
250 $settings['enable_osc'] = false;
251 }
252
253 $notificationSettings = new ilSetting('notifications');
254 $notificationSettings->set('osd_polling_intervall', (int) $form->getInput('osd_intervall'));
255 $notificationSettings->set('enable_osd', (boolean) $form->getInput('enable_osd'));
256
257 $chatSettings = new ilSetting('chatroom');
258 $chatSettings->set('chat_enabled', $settings['chat_enabled']);
259 $chatSettings->set('enable_osc', $settings['enable_osc']);
260 $chatSettings->set('play_invitation_sound', (boolean) $form->getInput('play_invitation_sound'));
261
262 $adminSettings = new ilChatroomAdmin($this->gui->object->getId());
263 $adminSettings->saveClientSettings((object) $settings);
264
265 $fileHandler = new ilChatroomConfigFileHandler();
266 $fileHandler->createClientConfigFile($settings);
267
268 ilUtil::sendSuccess($this->ilLng->txt('settings_has_been_saved'), true);
269 $this->ilCtrl->redirect($this->gui, 'view-clientsettings');
270 }
271
275 public function clientsettings(ilPropertyFormGUI $form = null)
276 {
277 $this->redirectIfNoPermission('read');
278
279 $this->defaultActions();
280 $this->gui->switchToVisibleMode();
281
282 $adminSettings = new ilChatroomAdmin($this->gui->object->getId());
283 $serverSettings = $adminSettings->loadGeneralSettings();
284
285 if ($form === null) {
286 $clientSettings = $adminSettings->loadClientSettings();
288 $form = $factory->getClientSettingsForm();
289 $form->setValuesByArray($clientSettings);
290 }
291
292 $this->checkServerConnection($serverSettings);
293
294 $form->setTitle($this->ilLng->txt('general_settings_title'));
295 if (ilChatroom::checkUserPermissions('write', $this->gui->ref_id, false)) {
296 $form->addCommandButton('view-saveClientSettings', $this->ilLng->txt('save'));
297 }
298 $form->setFormAction($this->ilCtrl->getFormAction($this->gui, 'view-saveClientSettings'));
299
300 $settingsTpl = $this->createSettingTemplate($form);
301 $this->ilTpl->setVariable('ADM_CONTENT', $settingsTpl->get());
302 }
303}
sprintf('%.4f', $callTime)
$factory
Definition: metadata.php:47
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.
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
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.
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7