ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ($method)
 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 241 of file class.ilChatroomViewGUI.php.

References $message, and ilUtil\sendFailure().

Referenced by executeDefault(), and showRoom().

242  {
244  }
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 (   $method)

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.

Parameters
string$method

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

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

369  {
370  include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
371 
372  $this->redirectIfNoPermission('read');
373 
374  $this->gui->switchToVisibleMode();
375  $this->setupTemplate();
376 
377  $chatSettings = new ilSetting('chatroom');
378  if (!$chatSettings->get('chat_enabled')) {
379  $this->ilCtrl->redirect($this->gui, 'settings-general');
380  exit;
381  }
382 
383  $room = ilChatroom::byObjectId($this->gui->object->getId());
384 
385  if (!$room->getSetting('allow_anonymous') && $this->ilUser->isAnonymous()) {
386  $this->cancelJoin($this->ilLng->txt('chat_anonymous_not_allowed'));
387  return;
388  }
389 
390  $chat_user = new ilChatroomUser($this->ilUser, $room);
391 
392  if ($room->getSetting('allow_custom_usernames')) {
393  if ($room->isSubscribed($chat_user->getUserId())) {
394  $chat_user->setUsername($chat_user->getUsername());
395  $this->showRoom($room, $chat_user);
396  } else {
397  $this->showNameSelection($chat_user);
398  }
399  } else {
400  $chat_user->setUsername($this->ilUser->getLogin());
401  $this->showRoom($room, $chat_user);
402  }
403  }
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 408 of file class.ilChatroomViewGUI.php.

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

409  {
410  $chatSettings = new ilSetting('chatroom');
411  if (!$chatSettings->get('chat_enabled')) {
412  $this->ilCtrl->redirect($this->gui, 'settings-general');
413  }
414 
415  $room = ilChatroom::byObjectId($this->gui->object->getId());
416  $chat_user = new ilChatroomUser($this->ilUser, $room);
417  $user_id = $_REQUEST['usr_id'];
418  $connector = $this->gui->getConnector();
419  $title = $room->getUniquePrivateRoomTitle($chat_user->buildLogin());
420  $subRoomId = $room->addPrivateRoom($title, $chat_user, array('public' => false));
421 
422  $room->inviteUserToPrivateRoom($user_id, $subRoomId);
423  $connector->sendCreatePrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), $title);
424  $connector->sendInviteToPrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), $user_id);
425 
426  $room->sendInvitationNotification($this->gui, $chat_user, $user_id, $subRoomId);
427 
428  $_REQUEST['sub'] = $subRoomId;
429 
430  $_SESSION['show_invitation_message'] = $user_id;
431 
432  $this->ilCtrl->setParameter($this->gui, 'sub', $subRoomId);
433  $this->ilCtrl->redirect($this->gui, 'view');
434  }
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 439 of file class.ilChatroomViewGUI.php.

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

440  {
444  $pid = $this->tree->getParentId($this->gui->getRefId());
445  $this->ilCtrl->setParameterByClass('ilrepositorygui', 'ref_id', $pid);
446  $this->ilCtrl->redirectByClass('ilrepositorygui', '');
447  }
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 452 of file class.ilChatroomViewGUI.php.

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

453  {
454  if (isset($_GET['msg'])) {
455  switch ($_GET['msg']) {
456  case 'kicked':
457  ilUtil::sendFailure($this->ilLng->txt('kicked'), true);
458  break;
459 
460  case 'banned':
461  ilUtil::sendFailure($this->ilLng->txt('banned'), true);
462  break;
463 
464  default:
465  ilUtil::sendFailure($this->ilLng->txt('lost_connection'), true);
466  break;
467  }
468  } else {
469  ilUtil::sendFailure($this->ilLng->txt('lost_connection'), true);
470  }
471 
472  $this->ilCtrl->redirectByClass('ilinfoscreengui', 'info');
473  }
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 250 of file class.ilChatroomViewGUI.php.

References ilGlobalTemplateInterface\setVariable().

Referenced by showRoom().

251  {
252  // @todo: Not implemented yet
253  return;
254 
255  require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
256  $formFactory = new ilChatroomFormFactory();
257  $file_upload = $formFactory->getFileUploadForm();
258  //$file_upload->setFormAction( $ilCtrl->getFormAction($this->gui, 'UploadFile-uploadFile') );
259  $roomTpl->setVariable('FILE_UPLOAD', $file_upload->getHTML());
260  }
Class ilChatroomFormFactory.
setVariable($variable, $value='')
+ 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 277 of file class.ilChatroomViewGUI.php.

References ilGlobalTemplateInterface\setVariable().

Referenced by showRoom().

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

References ilGlobalTemplateInterface\setVariable().

Referenced by showRoom().

334  {
335  $roomTpl->setVariable('LBL_NO_FURTHER_USERS', $this->ilLng->txt('no_further_users'));
336  }
setVariable($variable, $value='')
+ 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 265 of file class.ilChatroomViewGUI.php.

References ilGlobalTemplateInterface\setVariable().

Referenced by showRoom().

266  {
267  $roomTpl->setVariable('LBL_MESSAGE', $this->ilLng->txt('chat_message'));
268  $roomTpl->setVariable('LBL_TOALL', $this->ilLng->txt('chat_message_to_all'));
269  $roomTpl->setVariable('LBL_OPTIONS', $this->ilLng->txt('chat_message_options'));
270  $roomTpl->setVariable('LBL_DISPLAY', $this->ilLng->txt('chat_message_display'));
271  $roomTpl->setVariable('LBL_SEND', $this->ilLng->txt('send'));
272  }
setVariable($variable, $value='')
+ 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('libs/bower/bower_components/jquery-outside-events/jquery.ba-outside-events.min.js');
60 
61  $this->mainTpl->addJavaScript('./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js');
62 
63  $this->mainTpl->addCSS('Modules/Chatroom/templates/default/style.css');
64  }
+ 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 344 of file class.ilChatroomViewGUI.php.

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

Referenced by executeDefault(), and joinWithCustomName().

345  {
346  require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
347 
348  $name_options = $chat_user->getChatNameSuggestions();
349  $formFactory = new ilChatroomFormFactory();
350  $selectionForm = $formFactory->getUserChatNameSelectionForm($name_options);
351 
352  $this->ilCtrl->saveParameter($this->gui, 'sub');
353 
354  $selectionForm->addCommandButton('view-joinWithCustomName', $this->ilLng->txt('enter'));
355  $selectionForm->setFormAction(
356  $this->ilCtrl->getFormAction($this->gui, 'view-joinWithCustomName')
357  );
358 
359  $this->mainTpl->setVariable('ADM_CONTENT', $selectionForm->getHtml());
360  }
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 71 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().

72  {
73  $this->redirectIfNoPermission('read');
74 
75  $user_id = $chat_user->getUserId($this->ilUser);
76 
77  $this->navigationHistory->addItem($_GET['ref_id'], $this->ilCtrl->getLinkTargetByClass('ilrepositorygui', 'view'), 'chtr');
78 
79  if ($room->isUserBanned($user_id)) {
80  $this->cancelJoin($this->ilLng->txt('banned'));
81  return;
82  }
83 
84  $scope = $room->getRoomId();
85  $connector = $this->gui->getConnector();
86  $response = @$connector->connect($scope, $user_id);
87 
88  if (!$response) {
89  ilUtil::sendFailure($this->ilLng->txt('unable_to_connect'), true);
90  $this->ilCtrl->redirectByClass('ilinfoscreengui', 'info');
91  }
92 
93  if (!$room->isSubscribed($chat_user->getUserId())) {
94  $room->connectUser($chat_user);
95  }
96 
97  $subScope = 0;
98  $response = $connector->sendEnterPrivateRoom($scope, $subScope, $user_id);
99  if (!$response) {
100  ilUtil::sendFailure($this->ilLng->txt('unable_to_connect'), true);
101  $this->ilCtrl->redirectByClass('ilinfoscreengui', 'info');
102  }
103 
104  $connection_info = json_decode($response);
105  $settings = $connector->getSettings();
106  $known_private_room = $room->getActivePrivateRooms($this->ilUser->getId());
107 
108  $initial = new stdClass();
109  $initial->users = $room->getConnectedUsers();
110  $initial->private_rooms = array_values($known_private_room);
111  $initial->redirect_url = $this->ilCtrl->getLinkTarget($this->gui, 'view-lostConnection', '', false, false);
112  $initial->profile_image_url = $this->ilCtrl->getLinkTarget($this->gui, 'view-getUserProfileImages', '', true, false);
113  $initial->no_profile_image_url = ilUtil::getImagePath('no_photo_xxsmall.jpg');
114  $initial->private_rooms_enabled = (boolean) $room->getSetting('private_rooms_enabled');
115  $initial->subdirectory = $settings->getSubDirectory();
116 
117  $initial->userinfo = array(
118  'moderator' => ilChatroom::checkUserPermissions('moderate', (int) $_GET['ref_id'], false),
119  'id' => $chat_user->getUserId(),
120  'login' => $chat_user->getUsername()
121  );
122 
123  $smileys = array();
124 
125  include_once('Modules/Chatroom/classes/class.ilChatroomSmilies.php');
126 
127  if ($settings->getSmiliesEnabled()) {
128  $smileys_array = ilChatroomSmilies::_getSmilies();
129  foreach ($smileys_array as $smiley_array) {
130  $new_keys = array();
131  $new_val = '';
132  foreach ($smiley_array as $key => $value) {
133  if ($key == 'smiley_keywords') {
134  $new_keys = explode("\n", $value);
135  }
136 
137  if ($key == 'smiley_fullpath') {
138  $new_val = $value;
139  }
140  }
141 
142  if (!$new_keys || !$new_val) {
143  continue;
144  }
145 
146  foreach ($new_keys as $new_key) {
147  $smileys[$new_key] = $new_val;
148  }
149  }
150 
151  $initial->smileys = $smileys;
152  } else {
153  $initial->smileys = '{}';
154  }
155 
156  $initial->messages = array();
157 
158  if (isset($_REQUEST['sub'])) {
159  if ($known_private_room[$_REQUEST['sub']]) {
160  if (!$room->isAllowedToEnterPrivateRoom($chat_user->getUserId(), $_REQUEST['sub'])) {
161  $initial->messages[] = array(
162  'type' => 'error',
163  'message' => $this->ilLng->txt('not_allowed_to_enter'),
164  );
165  } else {
166  $scope = $room->getRoomId();
167  $params = array();
168  $params['user'] = $chat_user->getUserId();
169  $params['sub'] = $_REQUEST['sub'];
170 
171  $params['message'] = json_encode(
172  array(
173  'type' => 'private_room_entered',
174  'user' => $user_id
175  )
176  );
177 
178  $connector = $this->gui->getConnector();
179  $response = $connector->sendEnterPrivateRoom($scope, $_REQUEST['sub'], $chat_user->getUserId());
180 
181  if ($this->isSuccessful($response)) {
182  $room->subscribeUserToPrivateRoom($params['sub'], $params['user']);
183  }
184 
185  $initial->enter_room = $_REQUEST['sub'];
186  }
187  } else {
188  $initial->messages[] = array(
189  'type' => 'error',
190  'message' => $this->ilLng->txt('user_invited'),
191  );
192  }
193  }
194 
195  if ((int) $room->getSetting('display_past_msgs')) {
196  $initial->messages = array_merge($initial->messages, array_reverse($room->getLastMessages($room->getSetting('display_past_msgs'), $chat_user)));
197  }
198 
199  $roomTpl = new ilTemplate('tpl.chatroom.html', true, true, 'Modules/Chatroom');
200  $roomTpl->setVariable('SESSION_ID', $connection_info->{'session-id'});
201  $roomTpl->setVariable('BASEURL', $settings->generateClientUrl());
202  $roomTpl->setVariable('INSTANCE', $settings->getInstance());
203  $roomTpl->setVariable('SCOPE', $scope);
204  $roomTpl->setVariable('MY_ID', $user_id);
205  $roomTpl->setVariable('INITIAL_DATA', json_encode($initial));
206  $roomTpl->setVariable('POSTURL', $this->ilCtrl->getLinkTarget($this->gui, 'postMessage', '', true, true));
207 
208  $roomTpl->setVariable('ACTIONS', $this->ilLng->txt('actions'));
209  $roomTpl->setVariable('LBL_CREATE_PRIVATE_ROOM', $this->ilLng->txt('create_private_room_label'));
210  $roomTpl->setVariable('LBL_USER', $this->ilLng->txt('user'));
211  $roomTpl->setVariable('LBL_USER_TEXT', $this->ilLng->txt('invite_username'));
212  $roomTpl->setVariable('LBL_AUTO_SCROLL', $this->ilLng->txt('auto_scroll'));
213 
214  $roomTpl->setVariable('INITIAL_USERS', json_encode($room->getConnectedUsers()));
215 
216  $this->renderFileUploadForm($roomTpl);
217  $this->renderSendMessageBox($roomTpl);
218  $this->renderLanguageVariables($roomTpl);
219 
220  require_once 'Services/UIComponent/Modal/classes/class.ilModalGUI.php';
222 
223  $roomRightTpl = new ilTemplate('tpl.chatroom_right.html', true, true, 'Modules/Chatroom');
224  $this->renderRightUsersBlock($roomRightTpl);
225 
226  require_once 'Services/UIComponent/Panel/classes/class.ilPanelGUI.php';
227  $right_content_panel = ilPanelGUI::getInstance();
228  $right_content_panel->setHeading($this->ilLng->txt('users'));
229  $right_content_panel->setPanelStyle(ilPanelGUI::PANEL_STYLE_SECONDARY);
230  $right_content_panel->setHeadingStyle(ilPanelGUI::HEADING_STYLE_BLOCK);
231  $right_content_panel->setBody($roomRightTpl->get());
232 
233  $this->mainTpl->setContent($roomTpl->get());
234  $this->mainTpl->setRightContent($right_content_panel->getHTML());
235  }
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: