ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilChatroomAdminViewGUI Class Reference

Class ilChatroomAdminViewGUI. More...

+ Inheritance diagram for ilChatroomAdminViewGUI:
+ Collaboration diagram for ilChatroomAdminViewGUI:

Public Member Functions

 __construct (ilChatroomObjectGUI $gui)
 Constructor. More...
 
 executeDefault ($method)
 {} More...
 
 saveSettings ()
 Saves settings fetched from $_POST. More...
 
 serversettings (ilPropertyFormGUI $form=null)
 Prepares view form and displays it. More...
 
 forcePublicRoom ()
 
 createPublicRoom ()
 Creates a public chatroom. More...
 
 saveClientSettings ()
 Saves client settings fetched from $_POST. More...
 
 clientsettings (ilPropertyFormGUI $form=null)
 
- Public Member Functions inherited from ilChatroomGUIHandler
 __construct (ilChatroomObjectGUI $gui)
 
 sendResponse ($response)
 Sends a json encoded response and exits the php process. More...
 
 hasPermission ($permission)
 Checks for access with ilRbacSystem. More...
 
 execute ($method)
 Executes given $method if existing, otherwise executes executeDefault() method. More...
 
 executeDefault ($requestedMethod)
 
 redirectIfNoPermission ($permission)
 Checks for requested permissions and redirects if the permission check failed. More...
 
 isSuccessful ($response)
 Checks for success param in an json decoded response. More...
 

Data Fields

const CHATROOM_README_PATH = '/Modules/Chatroom/README.md'
 

Protected Member Functions

 checkServerConnection (array $serverSettings)
 Checks for server connection. More...
 
 createSettingTemplate (ilPropertyFormGUI $form)
 
 getReadmePath ()
 Get the path to the README.txt file. More...
 
- Protected Member Functions inherited from ilChatroomGUIHandler
 getRoomByObjectId ($objectId)
 
 exitIfNoRoomExists ($room)
 Checks if a ilChatroom exists. More...
 
 exitIfNoRoomPermission ($room, $subRoom, $chat_user)
 Check if user can moderate a chatroom. More...
 
 canModerate ($room, $subRoom, $user_id)
 Checks if the user has permission to moderate a ilChatroom. More...
 
 isMainRoom ($subRoomId)
 

Protected Attributes

 $commonSettings
 
 $ilTpl
 
- Protected Attributes inherited from ilChatroomGUIHandler
 $gui
 
 $ilUser
 
 $ilCtrl
 
 $ilLng
 
 $webDirectory
 
 $upload
 

Private Member Functions

 defaultActions ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilChatroomAdminViewGUI::__construct ( ilChatroomObjectGUI  $gui)

Constructor.

Parameters
ilChatroomObjectGUI$gui

Definition at line 34 of file class.ilChatroomAdminViewGUI.php.

References $DIC.

35  {
36  global $DIC;
37 
38  parent::__construct($gui);
39  $this->commonSettings = new ilSetting('common');
40  $this->ilTpl = $DIC->ui()->mainTemplate();
41  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ checkServerConnection()

ilChatroomAdminViewGUI::checkServerConnection ( array  $serverSettings)
protected

Checks for server connection.

If no connection if possible, show info in gui

Parameters
array$serverSettings

Definition at line 186 of file class.ilChatroomAdminViewGUI.php.

References ilChatroomServerConnector\checkServerConnection(), and ilUtil\sendInfo().

Referenced by clientsettings(), and 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  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static checkServerConnection($use_cache=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clientsettings()

ilChatroomAdminViewGUI::clientsettings ( ilPropertyFormGUI  $form = null)
Parameters
ilPropertyFormGUI$form

Definition at line 275 of file class.ilChatroomAdminViewGUI.php.

References $factory, $form, checkServerConnection(), ilChatroom\checkUserPermissions(), createSettingTemplate(), defaultActions(), ilCtrl\getFormAction(), ilChatroomAdmin\loadGeneralSettings(), and ilChatroomGUIHandler\redirectIfNoPermission().

Referenced by saveClientSettings().

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  }
This class provides processing control methods.
checkServerConnection(array $serverSettings)
Checks for server connection.
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
$factory
Definition: metadata.php:47
setFormAction($a_formaction)
Set FormAction.
Class ilChatroomFormFactory.
setTitle($a_title)
Set Title.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
Class ilChatroomAdmin.
loadGeneralSettings()
Returns an array containing server settings from settingsTable.
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
createSettingTemplate(ilPropertyFormGUI $form)
getFormAction( $a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get form action url for gui class object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createPublicRoom()

ilChatroomAdminViewGUI::createPublicRoom ( )

Creates a public chatroom.

Definition at line 175 of file class.ilChatroomAdminViewGUI.php.

References ilUtil\sendSuccess().

Referenced by forcePublicRoom().

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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createSettingTemplate()

ilChatroomAdminViewGUI::createSettingTemplate ( ilPropertyFormGUI  $form)
protected
Parameters
ilPropertyFormGUI$form
Returns
ilTemplate

Definition at line 203 of file class.ilChatroomAdminViewGUI.php.

References ilPropertyFormGUI\getHTML(), and getReadmePath().

Referenced by clientsettings(), and serversettings().

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  }
special template class to simplify handling of ITX/PEAR
getReadmePath()
Get the path to the README.txt file.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ defaultActions()

ilChatroomAdminViewGUI::defaultActions ( )
private

Definition at line 132 of file class.ilChatroomAdminViewGUI.php.

References forcePublicRoom().

Referenced by clientsettings(), and serversettings().

133  {
134  $chatSettings = new ilSetting('chatroom');
135  if ($chatSettings->get('chat_enabled', false)) {
136  $this->forcePublicRoom();
137  }
138  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeDefault()

ilChatroomAdminViewGUI::executeDefault (   $method)

{}

Definition at line 46 of file class.ilChatroomAdminViewGUI.php.

References ilCtrl\redirect().

47  {
48  $this->ilCtrl->redirect($this->gui, 'view-clientsettings');
49  }
This class provides processing control methods.
redirect($a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to another command.
+ Here is the call graph for this function:

◆ forcePublicRoom()

ilChatroomAdminViewGUI::forcePublicRoom ( )

Definition at line 143 of file class.ilChatroomAdminViewGUI.php.

References ilObjChatroom\_getPublicRefId(), ilObject\_hasUntrashedReference(), ilObject\_lookupObjId(), createPublicRoom(), and ilObjectFactory\getInstanceByRefId().

Referenced by defaultActions().

144  {
145  $ref_id = ilObjChatroom::_getPublicRefId();
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  }
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
createPublicRoom()
Creates a public chatroom.
static _lookupObjId($a_id)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getReadmePath()

ilChatroomAdminViewGUI::getReadmePath ( )
protected

Get the path to the README.txt file.

Returns
string

Definition at line 217 of file class.ilChatroomAdminViewGUI.php.

References ilUtil\_getHttpPath().

Referenced by createSettingTemplate().

218  {
219  return ilUtil::_getHttpPath() . self::CHATROOM_README_PATH;
220  }
static _getHttpPath()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveClientSettings()

ilChatroomAdminViewGUI::saveClientSettings ( )

Saves client settings fetched from $_POST.

Definition at line 225 of file class.ilChatroomAdminViewGUI.php.

References $factory, $form, array, clientsettings(), ilCtrl\redirect(), ilChatroomGUIHandler\redirectIfNoPermission(), ilChatroomAdmin\saveClientSettings(), and ilUtil\sendSuccess().

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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class provides processing control methods.
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
$factory
Definition: metadata.php:47
clientsettings(ilPropertyFormGUI $form=null)
Class ilChatroomFormFactory.
if(isset($_POST['submit'])) $form
Class ilChatroomAdmin.
Create styles array
The data for the language used.
saveClientSettings(stdClass $settings)
Saves given client $settings into settingsTable.
redirect($a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to another command.
+ Here is the call graph for this function:

◆ saveSettings()

ilChatroomAdminViewGUI::saveSettings ( )

Saves settings fetched from $_POST.

Definition at line 54 of file class.ilChatroomAdminViewGUI.php.

References $factory, $form, array, ilCtrl\redirect(), ilChatroomGUIHandler\redirectIfNoPermission(), ilChatroomAdmin\saveGeneralSettings(), ilUtil\sendSuccess(), and serversettings().

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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class provides processing control methods.
saveGeneralSettings(stdClass $settings)
Saves given $settings into settingsTable.
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
$factory
Definition: metadata.php:47
Class ilChatroomFormFactory.
if(isset($_POST['submit'])) $form
Class ilChatroomAdmin.
Create styles array
The data for the language used.
serversettings(ilPropertyFormGUI $form=null)
Prepares view form and displays it.
redirect($a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to another command.
+ Here is the call graph for this function:

◆ serversettings()

ilChatroomAdminViewGUI::serversettings ( ilPropertyFormGUI  $form = null)

Prepares view form and displays it.

Parameters
ilPropertyFormGUI$form

Definition at line 101 of file class.ilChatroomAdminViewGUI.php.

References $factory, $form, checkServerConnection(), ilChatroom\checkUserPermissions(), createSettingTemplate(), defaultActions(), ilCtrl\getFormAction(), ilChatroomAdmin\loadGeneralSettings(), and ilChatroomGUIHandler\redirectIfNoPermission().

Referenced by saveSettings().

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  }
This class provides processing control methods.
checkServerConnection(array $serverSettings)
Checks for server connection.
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
$factory
Definition: metadata.php:47
setFormAction($a_formaction)
Set FormAction.
Class ilChatroomFormFactory.
setTitle($a_title)
Set Title.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
Class ilChatroomAdmin.
loadGeneralSettings()
Returns an array containing server settings from settingsTable.
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
createSettingTemplate(ilPropertyFormGUI $form)
getFormAction( $a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get form action url for gui class object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $commonSettings

ilChatroomAdminViewGUI::$commonSettings
protected

Definition at line 23 of file class.ilChatroomAdminViewGUI.php.

◆ $ilTpl

ilChatroomAdminViewGUI::$ilTpl
protected

Definition at line 28 of file class.ilChatroomAdminViewGUI.php.

◆ CHATROOM_README_PATH

const ilChatroomAdminViewGUI::CHATROOM_README_PATH = '/Modules/Chatroom/README.md'

Definition at line 18 of file class.ilChatroomAdminViewGUI.php.


The documentation for this class was generated from the following file: