ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilChatroomViewGUI Class Reference

Class ilChatroomViewGUI. More...

+ Inheritance diagram for ilChatroomViewGUI:
+ Collaboration diagram for ilChatroomViewGUI:

Public Member Functions

 joinWithCustomName ()
 Joins user to chatroom with custom username, fetched from $_REQUEST['custom_username_text'] or by calling buld method. More...
 
 renderFileUploadForm (ilTemplate $roomTpl)
 Prepares Fileupload form and displays it. More...
 
 executeDefault ($requestedMethod)
 Chatroom and Chatuser get prepared before $this->showRoom method is called. More...
 
 invitePD ()
 
 logout ()
 Performs logout. More...
 
 lostConnection ()
 
- Public Member Functions inherited from ilChatroomGUIHandler
 __construct (ilChatroomObjectGUI $gui)
 
 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...
 
 sendResponse ($response)
 Sends a json encoded response and exits the php process. More...
 
 hasPermission ($permission)
 Checks for access with ilRbacSystem. More...
 

Protected Member Functions

 renderSendMessageBox (ilTemplate $roomTpl)
 
 renderLanguageVariables (ilTemplate $roomTpl)
 
 renderRightUsersBlock (ilTemplate $roomTpl)
 
- 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)
 

Private Member Functions

 setupTemplate ()
 Adds CSS and JavaScript files that should be included in the header. More...
 
 showRoom (ilChatroom $room, ilChatroomUser $chat_user)
 Prepares and displays chatroom and connects user to it. More...
 
 cancelJoin ($message)
 Calls ilUtil::sendFailure method using given $message as parameter. More...
 
 showNameSelection (ilChatroomUser $chat_user)
 Prepares and displays name selection. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilChatroomGUIHandler
 $gui
 
 $ilUser
 
 $ilCtrl
 
 $ilLng
 
 $webDirectory
 
 $obj_service
 
 $upload
 
 $rbacsystem
 
 $mainTpl
 
 $ilias
 
 $navigationHistory
 
 $tree
 
 $tabs
 

Detailed Description

Class ilChatroomViewGUI.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilChatroomViewGUI.php.

Member Function Documentation

◆ cancelJoin()

ilChatroomViewGUI::cancelJoin (   $message)
private

Calls ilUtil::sendFailure method using given $message as parameter.

Parameters
string$message

Definition at line 243 of file class.ilChatroomViewGUI.php.

References $message, and ilUtil\sendFailure().

Referenced by executeDefault(), and showRoom().

244  {
246  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$message
Definition: xapiexit.php:14
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeDefault()

ilChatroomViewGUI::executeDefault (   $requestedMethod)

Chatroom and Chatuser get prepared before $this->showRoom method is called.

If custom usernames are allowed, $this->showNameSelection method is called if user isn't already registered in the Chatroom.

Definition at line 370 of file class.ilChatroomViewGUI.php.

References ilChatroom\byObjectId(), cancelJoin(), exit, ilCtrl\redirect(), ilChatroomGUIHandler\redirectIfNoPermission(), setupTemplate(), showNameSelection(), and showRoom().

371  {
372  include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
373 
374  $this->redirectIfNoPermission('read');
375 
376  $this->gui->switchToVisibleMode();
377  $this->setupTemplate();
378 
379  $chatSettings = new ilSetting('chatroom');
380  if (!$chatSettings->get('chat_enabled')) {
381  $this->ilCtrl->redirect($this->gui, 'settings-general');
382  exit;
383  }
384 
385  $room = ilChatroom::byObjectId($this->gui->object->getId());
386 
387  if (!$room->getSetting('allow_anonymous') && $this->ilUser->isAnonymous()) {
388  $this->cancelJoin($this->ilLng->txt('chat_anonymous_not_allowed'));
389  return;
390  }
391 
392  $chat_user = new ilChatroomUser($this->ilUser, $room);
393 
394  if ($room->getSetting('allow_custom_usernames')) {
395  if ($room->isSubscribed($chat_user->getUserId())) {
396  $chat_user->setUsername($chat_user->getUsername());
397  $this->showRoom($room, $chat_user);
398  } else {
399  $this->showNameSelection($chat_user);
400  }
401  } else {
402  $chat_user->setUsername($this->ilUser->getLogin());
403  $this->showRoom($room, $chat_user);
404  }
405  }
This class provides processing control methods.
exit
Definition: login.php:29
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
setupTemplate()
Adds CSS and JavaScript files that should be included in the header.
showRoom(ilChatroom $room, ilChatroomUser $chat_user)
Prepares and displays chatroom and connects user to it.
cancelJoin($message)
Calls ilUtil::sendFailure method using given $message as parameter.
Class ilChatroomUser.
showNameSelection(ilChatroomUser $chat_user)
Prepares and displays name selection.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
redirect($a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to another command.
+ Here is the call graph for this function:

◆ invitePD()

ilChatroomViewGUI::invitePD ( )

Definition at line 410 of file class.ilChatroomViewGUI.php.

References $_SESSION, ilChatroom\byObjectId(), ilCtrl\redirect(), and ilCtrl\setParameter().

411  {
412  $chatSettings = new ilSetting('chatroom');
413  if (!$chatSettings->get('chat_enabled')) {
414  $this->ilCtrl->redirect($this->gui, 'settings-general');
415  }
416 
417  $room = ilChatroom::byObjectId($this->gui->object->getId());
418  $chat_user = new ilChatroomUser($this->ilUser, $room);
419  $user_id = $_REQUEST['usr_id'];
420  $connector = $this->gui->getConnector();
421  $title = $room->getUniquePrivateRoomTitle($chat_user->buildLogin());
422  $subRoomId = $room->addPrivateRoom($title, $chat_user, array('public' => false));
423 
424  $room->inviteUserToPrivateRoom($user_id, $subRoomId);
425  $connector->sendCreatePrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), $title);
426  $connector->sendInviteToPrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), $user_id);
427 
428  $room->sendInvitationNotification($this->gui, $chat_user, $user_id, $subRoomId);
429 
430  $_REQUEST['sub'] = $subRoomId;
431 
432  $_SESSION['show_invitation_message'] = $user_id;
433 
434  $this->ilCtrl->setParameter($this->gui, 'sub', $subRoomId);
435  $this->ilCtrl->redirect($this->gui, 'view');
436  }
setParameter($a_obj, $a_parameter, $a_value)
Set parameters that should be passed a form and link of a gui class.
This class provides processing control methods.
$_SESSION["AccountId"]
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
redirect($a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to another command.
+ Here is the call graph for this function:

◆ joinWithCustomName()

ilChatroomViewGUI::joinWithCustomName ( )

Joins user to chatroom with custom username, fetched from $_REQUEST['custom_username_text'] or by calling buld method.

If sucessful, $this->showRoom method is called, otherwise $this->showNameSelection.

Definition at line 21 of file class.ilChatroomViewGUI.php.

References $failure, ilChatroom\byObjectId(), ilChatroomGUIHandler\redirectIfNoPermission(), ilUtil\sendFailure(), setupTemplate(), showNameSelection(), and showRoom().

22  {
23  $this->redirectIfNoPermission('read');
24 
25  $this->gui->switchToVisibleMode();
26  $this->setupTemplate();
27  $room = ilChatroom::byObjectId($this->gui->object->getId());
28  $chat_user = new ilChatroomUser($this->ilUser, $room);
29  $failure = false;
30  $username = '';
31 
32  if ($_REQUEST['custom_username_radio'] == 'custom_username') {
33  $username = $_REQUEST['custom_username_text'];
34  } elseif (method_exists($chat_user, 'build' . $_REQUEST['custom_username_radio'])) {
35  $username = $chat_user->{'build' . $_REQUEST['custom_username_radio']}();
36  } else {
37  $failure = true;
38  }
39 
40  if (!$failure && trim($username) != '') {
41  if (!$room->isSubscribed($chat_user->getUserId())) {
42  $chat_user->setUsername($chat_user->buildUniqueUsername($username));
43  }
44 
45  $this->showRoom($room, $chat_user);
46  } else {
47  ilUtil::sendFailure($this->ilLng->txt('no_username_given'));
48  $this->showNameSelection($chat_user);
49  }
50  }
$failure
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
setupTemplate()
Adds CSS and JavaScript files that should be included in the header.
showRoom(ilChatroom $room, ilChatroomUser $chat_user)
Prepares and displays chatroom and connects user to it.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilChatroomUser.
showNameSelection(ilChatroomUser $chat_user)
Prepares and displays name selection.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
+ Here is the call graph for this function:

◆ logout()

ilChatroomViewGUI::logout ( )

Performs logout.

Todo:
logout user from room

Definition at line 441 of file class.ilChatroomViewGUI.php.

References ilCtrl\redirectByClass(), and ilCtrl\setParameterByClass().

442  {
446  $pid = $this->tree->getParentId($this->gui->getRefId());
447  $this->ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', $pid);
448  $this->ilCtrl->redirectByClass('ilrepositorygui', '');
449  }
This class provides processing control methods.
redirectByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to other gui class using class name.
setParameterByClass($a_class, $a_parameter, $a_value)
Same as setParameterByClass, except that a class name is passed.
+ Here is the call graph for this function:

◆ lostConnection()

ilChatroomViewGUI::lostConnection ( )

Definition at line 454 of file class.ilChatroomViewGUI.php.

References $_GET, $DIC, $response, ANONYMOUS_USER_ID, ilChatroom\byObjectId(), exit, ilUserUtil\getNamePresentation(), ilChatroomUser\getUserInformation(), login(), ilCtrl\redirectByClass(), ilUtil\sendFailure(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), and ilStr\subStr().

455  {
456  if (isset($_GET['msg'])) {
457  switch ($_GET['msg']) {
458  case 'kicked':
459  ilUtil::sendFailure($this->ilLng->txt('kicked'), true);
460  break;
461 
462  case 'banned':
463  ilUtil::sendFailure($this->ilLng->txt('banned'), true);
464  break;
465 
466  default:
467  ilUtil::sendFailure($this->ilLng->txt('lost_connection'), true);
468  break;
469  }
470  } else {
471  ilUtil::sendFailure($this->ilLng->txt('lost_connection'), true);
472  }
473 
474  $this->ilCtrl->redirectByClass('ilinfoscreengui', 'info');
475  }
This class provides processing control methods.
$_GET["client_id"]
redirectByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to other gui class using class name.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ renderFileUploadForm()

ilChatroomViewGUI::renderFileUploadForm ( ilTemplate  $roomTpl)

Prepares Fileupload form and displays it.

Parameters
ilTemplate$roomTpl

Definition at line 252 of file class.ilChatroomViewGUI.php.

References HTML_Template_IT\setVariable().

Referenced by showRoom().

253  {
254  // @todo: Not implemented yet
255  return;
256 
257  require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
258  $formFactory = new ilChatroomFormFactory();
259  $file_upload = $formFactory->getFileUploadForm();
260  //$file_upload->setFormAction( $ilCtrl->getFormAction($this->gui, 'UploadFile-uploadFile') );
261  $roomTpl->setVariable('FILE_UPLOAD', $file_upload->getHTML());
262  }
Class ilChatroomFormFactory.
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:615
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderLanguageVariables()

ilChatroomViewGUI::renderLanguageVariables ( ilTemplate  $roomTpl)
protected
Parameters
ilTemplate$roomTpl

Definition at line 279 of file class.ilChatroomViewGUI.php.

References HTML_Template_IT\setVariable().

Referenced by showRoom().

280  {
281  $js_translations = array(
282  'LBL_MAINROOM' => 'chat_mainroom',
283  'LBL_LEAVE_PRIVATE_ROOM' => 'leave_private_room',
284  'LBL_LEFT_PRIVATE_ROOM' => 'left_private_room',
285  'LBL_JOIN' => 'chat_join',
286  'LBL_DELETE_PRIVATE_ROOM' => 'delete_private_room',
287  'LBL_DELETE_PRIVATE_ROOM_QUESTION' => 'delete_private_room_question',
288  'LBL_INVITE_TO_PRIVATE_ROOM' => 'invite_to_private_room',
289  'LBL_KICK' => 'chat_kick',
290  'LBL_BAN' => 'chat_ban',
291  'LBL_KICK_QUESTION' => 'kick_question',
292  'LBL_BAN_QUESTION' => 'ban_question',
293  'LBL_ADDRESS' => 'chat_address',
294  'LBL_WHISPER' => 'chat_whisper',
295  'LBL_CONNECT' => 'chat_connection_established',
296  'LBL_DISCONNECT' => 'chat_connection_disconnected',
297  'LBL_TO_MAINROOM' => 'chat_to_mainroom',
298  'LBL_CREATE_PRIVATE_ROOM_JS' => 'chat_create_private_room_button',
299  'LBL_WELCOME_TO_CHAT' => 'welcome_to_chat',
300  'LBL_USER_INVITED' => 'user_invited',
301  'LBL_USER_KICKED' => 'user_kicked',
302  'LBL_USER_INVITED_SELF' => 'user_invited_self',
303  'LBL_PRIVATE_ROOM_CLOSED' => 'private_room_closed',
304  'LBL_PRIVATE_ROOM_ENTERED' => 'private_room_entered',
305  'LBL_PRIVATE_ROOM_LEFT' => 'private_room_left',
306  'LBL_PRIVATE_ROOM_ENTERED_USER' => 'private_room_entered_user',
307  'LBL_KICKED_FROM_PRIVATE_ROOM' => 'kicked_from_private_room',
308  'LBL_OK' => 'ok',
309  'LBL_INVITE' => 'chat_invite',
310  'LBL_CANCEL' => 'cancel',
311  'LBL_WHISPER_TO' => 'whisper_to',
312  'LBL_SPEAK_TO' => 'speak_to',
313  'LBL_HISTORY_CLEARED' => 'history_cleared',
314  'LBL_CLEAR_ROOM_HISTORY' => 'clear_room_history',
315  'LBL_CLEAR_ROOM_HISTORY_QUESTION' => 'clear_room_history_question',
316  'LBL_END_WHISPER' => 'end_whisper',
317  'LBL_TIMEFORMAT' => 'lang_timeformat_no_sec',
318  'LBL_DATEFORMAT' => 'lang_dateformat'
319  );
320  foreach ($js_translations as $placeholder => $lng_variable) {
321  $roomTpl->setVariable($placeholder, json_encode($this->ilLng->txt($lng_variable)));
322  }
323 
324  $roomTpl->setVariable('LBL_CREATE_PRIVATE_ROOM', $this->ilLng->txt('chat_create_private_room_button'));
325  $roomTpl->setVariable('LBL_CREATE_PRIVATE_ROOM_TEXT', $this->ilLng->txt('create_private_room_text'));
326  $roomTpl->setVariable('LBL_LAYOUT', $this->ilLng->txt('layout'));
327  $roomTpl->setVariable('LBL_SHOW_SETTINGS', $this->ilLng->txt('show_settings'));
328  $roomTpl->setVariable('LBL_USER_IN_ROOM', $this->ilLng->txt('user_in_room'));
329  $roomTpl->setVariable('LBL_USER_IN_ILIAS', $this->ilLng->txt('user_in_ilias'));
330  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:615
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderRightUsersBlock()

ilChatroomViewGUI::renderRightUsersBlock ( ilTemplate  $roomTpl)
protected
Parameters
ilTemplate$roomTpl

Definition at line 335 of file class.ilChatroomViewGUI.php.

References HTML_Template_IT\setVariable().

Referenced by showRoom().

336  {
337  $roomTpl->setVariable('LBL_NO_FURTHER_USERS', $this->ilLng->txt('no_further_users'));
338  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:615
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderSendMessageBox()

ilChatroomViewGUI::renderSendMessageBox ( ilTemplate  $roomTpl)
protected
Parameters
ilTemplate$roomTpl

Definition at line 267 of file class.ilChatroomViewGUI.php.

References HTML_Template_IT\setVariable().

Referenced by showRoom().

268  {
269  $roomTpl->setVariable('LBL_MESSAGE', $this->ilLng->txt('chat_message'));
270  $roomTpl->setVariable('LBL_TOALL', $this->ilLng->txt('chat_message_to_all'));
271  $roomTpl->setVariable('LBL_OPTIONS', $this->ilLng->txt('chat_message_options'));
272  $roomTpl->setVariable('LBL_DISPLAY', $this->ilLng->txt('chat_message_display'));
273  $roomTpl->setVariable('LBL_SEND', $this->ilLng->txt('send'));
274  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:615
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setupTemplate()

ilChatroomViewGUI::setupTemplate ( )
private

Adds CSS and JavaScript files that should be included in the header.

Definition at line 55 of file class.ilChatroomViewGUI.php.

Referenced by executeDefault(), and joinWithCustomName().

56  {
57  $this->mainTpl->addJavaScript('Modules/Chatroom/js/chat.js');
58  $this->mainTpl->addJavaScript('Modules/Chatroom/js/iliaschat.jquery.js');
59  $this->mainTpl->addJavaScript('node_modules/jquery-outside-events/jquery.ba-outside-events.js');
60 
61  $this->mainTpl->addJavaScript('./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js');
62 
63  $this->mainTpl->addCSS('Modules/Chatroom/templates/default/style.css');
64 
65  $this->mainTpl->setPermanentLink($this->gui->object->getType(), $this->gui->object->getRefId());
66  }
+ Here is the caller graph for this function:

◆ showNameSelection()

ilChatroomViewGUI::showNameSelection ( ilChatroomUser  $chat_user)
private

Prepares and displays name selection.

Fetches name option by calling getChatNameSuggestions method on given $chat_user object.

Parameters
ilChatroomUser$chat_user

Definition at line 346 of file class.ilChatroomViewGUI.php.

References ilChatroomUser\getChatNameSuggestions(), ilCtrl\getFormAction(), and ilCtrl\saveParameter().

Referenced by executeDefault(), and joinWithCustomName().

347  {
348  require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
349 
350  $name_options = $chat_user->getChatNameSuggestions();
351  $formFactory = new ilChatroomFormFactory();
352  $selectionForm = $formFactory->getUserChatNameSelectionForm($name_options);
353 
354  $this->ilCtrl->saveParameter($this->gui, 'sub');
355 
356  $selectionForm->addCommandButton('view-joinWithCustomName', $this->ilLng->txt('enter'));
357  $selectionForm->setFormAction(
358  $this->ilCtrl->getFormAction($this->gui, 'view-joinWithCustomName')
359  );
360 
361  $this->mainTpl->setVariable('ADM_CONTENT', $selectionForm->getHtml());
362  }
This class provides processing control methods.
Class ilChatroomFormFactory.
getFormAction( $a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=false)
Get form action url for gui class object.
saveParameter($a_obj, $a_parameter)
Set parameters that should be passed in every form and link of a gui class.
getChatNameSuggestions()
Returns an array of chat-name suggestions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showRoom()

ilChatroomViewGUI::showRoom ( ilChatroom  $room,
ilChatroomUser  $chat_user 
)
private

Prepares and displays chatroom and connects user to it.

Parameters
ilChatroom$room
ilChatroomUser$chat_user

Definition at line 73 of file class.ilChatroomViewGUI.php.

References $_GET, $response, cancelJoin(), ilChatroom\checkUserPermissions(), ilChatroom\connectUser(), ilChatroom\getActivePrivateRooms(), ilChatroom\getConnectedUsers(), ilUtil\getImagePath(), ilPanelGUI\getInstance(), ilChatroom\getLastMessages(), ilCtrl\getLinkTarget(), ilCtrl\getLinkTargetByClass(), ilChatroom\getRoomId(), ilChatroom\getSetting(), ilChatroomUser\getUserId(), ilChatroomUser\getUsername(), ilPanelGUI\HEADING_STYLE_BLOCK, ilModalGUI\initJS(), ilChatroom\isAllowedToEnterPrivateRoom(), ilChatroom\isSubscribed(), ilChatroomGUIHandler\isSuccessful(), ilChatroom\isUserBanned(), ilPanelGUI\PANEL_STYLE_SECONDARY, ilCtrl\redirectByClass(), ilChatroomGUIHandler\redirectIfNoPermission(), renderFileUploadForm(), renderLanguageVariables(), renderRightUsersBlock(), renderSendMessageBox(), ilUtil\sendFailure(), and ilChatroom\subscribeUserToPrivateRoom().

Referenced by executeDefault(), and joinWithCustomName().

74  {
75  $this->redirectIfNoPermission('read');
76 
77  $user_id = $chat_user->getUserId();
78 
79  $this->navigationHistory->addItem($_GET['ref_id'], $this->ilCtrl->getLinkTargetByClass('ilrepositorygui', 'view'), 'chtr');
80 
81  if ($room->isUserBanned($user_id)) {
82  $this->cancelJoin($this->ilLng->txt('banned'));
83  return;
84  }
85 
86  $scope = $room->getRoomId();
87  $connector = $this->gui->getConnector();
88  $response = @$connector->connect($scope, $user_id);
89 
90  if (!$response) {
91  ilUtil::sendFailure($this->ilLng->txt('unable_to_connect'), true);
92  $this->ilCtrl->redirectByClass('ilinfoscreengui', 'info');
93  }
94 
95  if (!$room->isSubscribed($chat_user->getUserId())) {
96  $room->connectUser($chat_user);
97  }
98 
99  $subScope = 0;
100  $response = $connector->sendEnterPrivateRoom($scope, $subScope, $user_id);
101  if (!$response) {
102  ilUtil::sendFailure($this->ilLng->txt('unable_to_connect'), true);
103  $this->ilCtrl->redirectByClass('ilinfoscreengui', 'info');
104  }
105 
106  $connection_info = json_decode($response);
107  $settings = $connector->getSettings();
108  $known_private_room = $room->getActivePrivateRooms($this->ilUser->getId());
109 
110  $initial = new stdClass();
111  $initial->users = $room->getConnectedUsers();
112  $initial->private_rooms = array_values($known_private_room);
113  $initial->redirect_url = $this->ilCtrl->getLinkTarget($this->gui, 'view-lostConnection', '', false, false);
114  $initial->profile_image_url = $this->ilCtrl->getLinkTarget($this->gui, 'view-getUserProfileImages', '', true, false);
115  $initial->no_profile_image_url = ilUtil::getImagePath('no_photo_xxsmall.jpg');
116  $initial->private_rooms_enabled = (boolean) $room->getSetting('private_rooms_enabled');
117  $initial->subdirectory = $settings->getSubDirectory();
118 
119  $initial->userinfo = array(
120  'moderator' => ilChatroom::checkUserPermissions('moderate', (int) $_GET['ref_id'], false),
121  'id' => $chat_user->getUserId(),
122  'login' => $chat_user->getUsername()
123  );
124 
125  $smileys = array();
126 
127  include_once('Modules/Chatroom/classes/class.ilChatroomSmilies.php');
128 
129  if ($settings->getSmiliesEnabled()) {
130  $smileys_array = ilChatroomSmilies::_getSmilies();
131  foreach ($smileys_array as $smiley_array) {
132  $new_keys = array();
133  $new_val = '';
134  foreach ($smiley_array as $key => $value) {
135  if ($key == 'smiley_keywords') {
136  $new_keys = explode("\n", $value);
137  }
138 
139  if ($key == 'smiley_fullpath') {
140  $new_val = $value;
141  }
142  }
143 
144  if (!$new_keys || !$new_val) {
145  continue;
146  }
147 
148  foreach ($new_keys as $new_key) {
149  $smileys[$new_key] = $new_val;
150  }
151  }
152 
153  $initial->smileys = $smileys;
154  } else {
155  $initial->smileys = '{}';
156  }
157 
158  $initial->messages = array();
159 
160  if (isset($_REQUEST['sub'])) {
161  if ($known_private_room[$_REQUEST['sub']]) {
162  if (!$room->isAllowedToEnterPrivateRoom($chat_user->getUserId(), $_REQUEST['sub'])) {
163  $initial->messages[] = array(
164  'type' => 'error',
165  'message' => $this->ilLng->txt('not_allowed_to_enter'),
166  );
167  } else {
168  $scope = $room->getRoomId();
169  $params = array();
170  $params['user'] = $chat_user->getUserId();
171  $params['sub'] = $_REQUEST['sub'];
172 
173  $params['message'] = json_encode(
174  array(
175  'type' => 'private_room_entered',
176  'user' => $user_id
177  )
178  );
179 
180  $connector = $this->gui->getConnector();
181  $response = $connector->sendEnterPrivateRoom($scope, $_REQUEST['sub'], $chat_user->getUserId());
182 
183  if ($this->isSuccessful($response)) {
184  $room->subscribeUserToPrivateRoom($params['sub'], $params['user']);
185  }
186 
187  $initial->enter_room = $_REQUEST['sub'];
188  }
189  } else {
190  $initial->messages[] = array(
191  'type' => 'error',
192  'message' => $this->ilLng->txt('user_invited'),
193  );
194  }
195  }
196 
197  if ((int) $room->getSetting('display_past_msgs')) {
198  $initial->messages = array_merge($initial->messages, array_reverse($room->getLastMessages($room->getSetting('display_past_msgs'), $chat_user)));
199  }
200 
201  $roomTpl = new ilTemplate('tpl.chatroom.html', true, true, 'Modules/Chatroom');
202  $roomTpl->setVariable('SESSION_ID', $connection_info->{'session-id'});
203  $roomTpl->setVariable('BASEURL', $settings->generateClientUrl());
204  $roomTpl->setVariable('INSTANCE', $settings->getInstance());
205  $roomTpl->setVariable('SCOPE', $scope);
206  $roomTpl->setVariable('MY_ID', $user_id);
207  $roomTpl->setVariable('INITIAL_DATA', json_encode($initial));
208  $roomTpl->setVariable('POSTURL', $this->ilCtrl->getLinkTarget($this->gui, 'postMessage', '', true, true));
209 
210  $roomTpl->setVariable('ACTIONS', $this->ilLng->txt('actions'));
211  $roomTpl->setVariable('LBL_CREATE_PRIVATE_ROOM', $this->ilLng->txt('create_private_room_label'));
212  $roomTpl->setVariable('LBL_USER', $this->ilLng->txt('user'));
213  $roomTpl->setVariable('LBL_USER_TEXT', $this->ilLng->txt('invite_username'));
214  $roomTpl->setVariable('LBL_AUTO_SCROLL', $this->ilLng->txt('auto_scroll'));
215 
216  $roomTpl->setVariable('INITIAL_USERS', json_encode($room->getConnectedUsers()));
217 
218  $this->renderFileUploadForm($roomTpl);
219  $this->renderSendMessageBox($roomTpl);
220  $this->renderLanguageVariables($roomTpl);
221 
222  require_once 'Services/UIComponent/Modal/classes/class.ilModalGUI.php';
224 
225  $roomRightTpl = new ilTemplate('tpl.chatroom_right.html', true, true, 'Modules/Chatroom');
226  $this->renderRightUsersBlock($roomRightTpl);
227 
228  require_once 'Services/UIComponent/Panel/classes/class.ilPanelGUI.php';
229  $right_content_panel = ilPanelGUI::getInstance();
230  $right_content_panel->setHeading($this->ilLng->txt('users'));
231  $right_content_panel->setPanelStyle(ilPanelGUI::PANEL_STYLE_SECONDARY);
232  $right_content_panel->setHeadingStyle(ilPanelGUI::HEADING_STYLE_BLOCK);
233  $right_content_panel->setBody($roomRightTpl->get());
234 
235  $this->mainTpl->setContent($roomTpl->get());
236  $this->mainTpl->setRightContent($right_content_panel->getHTML());
237  }
getLinkTargetByClass( $a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=false)
Get link target for command using gui class name.
getUserId()
Returns Ilias User ID.
This class provides processing control methods.
getActivePrivateRooms($userid)
getRoomId()
Returns roomID from $this->roomId.
renderLanguageVariables(ilTemplate $roomTpl)
$_GET["client_id"]
isUserBanned($user_id)
Returns true if there's an entry in banTable matching roomId and given $user_id.
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
getLastMessages($number, $chatuser=null)
getSetting($name)
Returns setting from $this->settings array by given name.
static initJS(ilGlobalTemplateInterface $a_main_tpl=null)
Init javascript.
isSubscribed($chat_userid)
Returns true if entry exists in userTable matching given $chat_userid and $this->roomId.
renderSendMessageBox(ilTemplate $roomTpl)
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
redirectByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to other gui class using class name.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
subscribeUserToPrivateRoom($room_id, $user_id)
isSuccessful($response)
Checks for success param in an json decoded response.
connectUser(ilChatroomUser $user)
Connects user by inserting userdata into userTable.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
renderFileUploadForm(ilTemplate $roomTpl)
Prepares Fileupload form and displays it.
static getInstance()
Get instance.
cancelJoin($message)
Calls ilUtil::sendFailure method using given $message as parameter.
getLinkTarget( $a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=false)
Get link target for command using gui object.
const PANEL_STYLE_SECONDARY
getUsername()
Returns username from Object or SESSION.
const HEADING_STYLE_BLOCK
$response
renderRightUsersBlock(ilTemplate $roomTpl)
getConnectedUsers($only_data=true)
Returns an array of connected users.
isAllowedToEnterPrivateRoom($chat_userid, $proom_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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