4require_once 
'Modules/Chatroom/classes/class.ilChatroom.php';
 
    5require_once 
'Modules/Chatroom/classes/class.ilChatroomUser.php';
 
   23        $this->gui->switchToVisibleMode();
 
   30        if ($_REQUEST[
'custom_username_radio'] == 
'custom_username') {
 
   31            $username = $_REQUEST[
'custom_username_text'];
 
   32        } elseif (method_exists($chat_user, 
'build' . $_REQUEST[
'custom_username_radio'])) {
 
   33            $username = $chat_user->{
'build' . $_REQUEST[
'custom_username_radio']}();
 
   38        if (!
$failure && trim($username) != 
'') {
 
   39            if (!$room->isSubscribed($chat_user->getUserId())) {
 
   40                $chat_user->setUsername($chat_user->buildUniqueUsername($username));
 
   55        $this->mainTpl->addJavaScript(
'Modules/Chatroom/js/chat.js');
 
   56        $this->mainTpl->addJavaScript(
'Modules/Chatroom/js/iliaschat.jquery.js');
 
   57        $this->mainTpl->addJavaScript(
'libs/bower/bower_components/jquery-outside-events/jquery.ba-outside-events.min.js');
 
   59        $this->mainTpl->addJavaScript(
'./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js');
 
   61        $this->mainTpl->addCSS(
'Modules/Chatroom/templates/default/style.css');
 
   71        $this->redirectIfNoPermission(
'read');
 
   73        $user_id = $chat_user->
getUserId($this->ilUser);
 
   78            $this->cancelJoin($this->ilLng->txt(
'banned'));
 
   83        $connector = $this->gui->getConnector();
 
   84        $response = @$connector->connect($scope, $user_id);
 
   96        $response = $connector->sendEnterPrivateRoom($scope, $subScope, $user_id);
 
  102        $connection_info = json_decode(
$response);
 
  103        $settings = $connector->getSettings();
 
  106        $initial = 
new stdClass();
 
  108        $initial->private_rooms = array_values($known_private_room);
 
  109        $initial->redirect_url = $this->
ilCtrl->
getLinkTarget($this->gui, 
'view-lostConnection', 
'', 
false, 
false);
 
  110        $initial->profile_image_url = $this->
ilCtrl->
getLinkTarget($this->gui, 
'view-getUserProfileImages', 
'', 
true, 
false);
 
  112        $initial->private_rooms_enabled = (boolean) $room->
getSetting(
'private_rooms_enabled');
 
  113        $initial->subdirectory = $settings->getSubDirectory();
 
  115        $initial->userinfo = array(
 
  123        include_once(
'Modules/Chatroom/classes/class.ilChatroomSmilies.php');
 
  125        if ($settings->getSmiliesEnabled()) {
 
  126            $smileys_array = ilChatroomSmilies::_getSmilies();
 
  127            foreach ($smileys_array as $smiley_array) {
 
  130                foreach ($smiley_array as 
$key => $value) {
 
  131                    if (
$key == 
'smiley_keywords') {
 
  132                        $new_keys = explode(
"\n", $value);
 
  135                    if (
$key == 
'smiley_fullpath') {
 
  140                if (!$new_keys || !$new_val) {
 
  144                foreach ($new_keys as $new_key) {
 
  145                    $smileys[$new_key] = $new_val;
 
  149            $initial->smileys = $smileys;
 
  151            $initial->smileys = 
'{}';
 
  154        $initial->messages = array();
 
  156        if (isset($_REQUEST[
'sub'])) {
 
  157            if ($known_private_room[$_REQUEST[
'sub']]) {
 
  159                    $initial->messages[] = array(
 
  161                        'message' => $this->ilLng->txt(
'not_allowed_to_enter'),
 
  167                    $params[
'sub'] = $_REQUEST[
'sub'];
 
  169                    $params[
'message'] = json_encode(
 
  171                            'type' => 
'private_room_entered',
 
  176                    $connector = $this->gui->getConnector();
 
  177                    $response = $connector->sendEnterPrivateRoom($scope, $_REQUEST[
'sub'], $chat_user->
getUserId());
 
  183                    $initial->enter_room = $_REQUEST[
'sub'];
 
  186                $initial->messages[] = array(
 
  188                    'message' => $this->ilLng->txt(
'user_invited'),
 
  193        if ((
int) $room->
getSetting(
'display_past_msgs')) {
 
  194            $initial->messages = array_merge($initial->messages, array_reverse($room->
getLastMessages($room->
getSetting(
'display_past_msgs'), $chat_user)));
 
  197        $roomTpl = 
new ilTemplate(
'tpl.chatroom.html', 
true, 
true, 
'Modules/Chatroom');
 
  198        $roomTpl->setVariable(
'SESSION_ID', $connection_info->{
'session-id'});
 
  199        $roomTpl->setVariable(
'BASEURL', $settings->generateClientUrl());
 
  200        $roomTpl->setVariable(
'INSTANCE', $settings->getInstance());
 
  201        $roomTpl->setVariable(
'SCOPE', $scope);
 
  202        $roomTpl->setVariable(
'MY_ID', $user_id);
 
  203        $roomTpl->setVariable(
'INITIAL_DATA', json_encode($initial));
 
  204        $roomTpl->setVariable(
'POSTURL', $this->
ilCtrl->
getLinkTarget($this->gui, 
'postMessage', 
'', 
true, 
true));
 
  206        $roomTpl->setVariable(
'ACTIONS', $this->ilLng->txt(
'actions'));
 
  207        $roomTpl->setVariable(
'LBL_CREATE_PRIVATE_ROOM', $this->ilLng->txt(
'create_private_room_label'));
 
  208        $roomTpl->setVariable(
'LBL_USER', $this->ilLng->txt(
'user'));
 
  209        $roomTpl->setVariable(
'LBL_USER_TEXT', $this->ilLng->txt(
'invite_username'));
 
  210        $roomTpl->setVariable(
'LBL_AUTO_SCROLL', $this->ilLng->txt(
'auto_scroll'));
 
  212        $roomTpl->setVariable(
'INITIAL_USERS', json_encode($room->getConnectedUsers()));
 
  214        $this->renderFileUploadForm($roomTpl);
 
  215        $this->renderSendMessageBox($roomTpl);
 
  216        $this->renderLanguageVariables($roomTpl);
 
  218        require_once 
'Services/UIComponent/Modal/classes/class.ilModalGUI.php';
 
  221        $roomRightTpl = 
new ilTemplate(
'tpl.chatroom_right.html', 
true, 
true, 
'Modules/Chatroom');
 
  222        $this->renderRightUsersBlock($roomRightTpl);
 
  224        require_once 
'Services/UIComponent/Panel/classes/class.ilPanelGUI.php';
 
  226        $right_content_panel->setHeading($this->ilLng->txt(
'users'));
 
  229        $right_content_panel->setBody($roomRightTpl->get());
 
  231        $this->mainTpl->setContent($roomTpl->get());
 
  232        $this->mainTpl->setRightContent($right_content_panel->getHTML());
 
  253        require_once 
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
 
  255        $file_upload = $formFactory->getFileUploadForm();
 
  257        $roomTpl->
setVariable(
'FILE_UPLOAD', $file_upload->getHTML());
 
  265        $roomTpl->
setVariable(
'LBL_MESSAGE', $this->ilLng->txt(
'chat_message'));
 
  266        $roomTpl->
setVariable(
'LBL_TOALL', $this->ilLng->txt(
'chat_message_to_all'));
 
  267        $roomTpl->
setVariable(
'LBL_OPTIONS', $this->ilLng->txt(
'chat_message_options'));
 
  268        $roomTpl->
setVariable(
'LBL_DISPLAY', $this->ilLng->txt(
'chat_message_display'));
 
  269        $roomTpl->
setVariable(
'LBL_SEND', $this->ilLng->txt(
'send'));
 
  277        $js_translations = array(
 
  278            'LBL_MAINROOM' => 
'chat_mainroom',
 
  279            'LBL_LEAVE_PRIVATE_ROOM' => 
'leave_private_room',
 
  280            'LBL_LEFT_PRIVATE_ROOM' => 
'left_private_room',
 
  281            'LBL_JOIN' => 
'chat_join',
 
  282            'LBL_DELETE_PRIVATE_ROOM' => 
'delete_private_room',
 
  283            'LBL_DELETE_PRIVATE_ROOM_QUESTION' => 
'delete_private_room_question',
 
  284            'LBL_INVITE_TO_PRIVATE_ROOM' => 
'invite_to_private_room',
 
  285            'LBL_KICK' => 
'chat_kick',
 
  286            'LBL_BAN' => 
'chat_ban',
 
  287            'LBL_KICK_QUESTION' => 
'kick_question',
 
  288            'LBL_BAN_QUESTION' => 
'ban_question',
 
  289            'LBL_ADDRESS' => 
'chat_address',
 
  290            'LBL_WHISPER' => 
'chat_whisper',
 
  291            'LBL_CONNECT' => 
'chat_connection_established',
 
  292            'LBL_DISCONNECT' => 
'chat_connection_disconnected',
 
  293            'LBL_TO_MAINROOM' => 
'chat_to_mainroom',
 
  294            'LBL_CREATE_PRIVATE_ROOM_JS' => 
'chat_create_private_room_button',
 
  295            'LBL_WELCOME_TO_CHAT' => 
'welcome_to_chat',
 
  296            'LBL_USER_INVITED' => 
'user_invited',
 
  297            'LBL_USER_KICKED' => 
'user_kicked',
 
  298            'LBL_USER_INVITED_SELF' => 
'user_invited_self',
 
  299            'LBL_PRIVATE_ROOM_CLOSED' => 
'private_room_closed',
 
  300            'LBL_PRIVATE_ROOM_ENTERED' => 
'private_room_entered',
 
  301            'LBL_PRIVATE_ROOM_LEFT' => 
'private_room_left',
 
  302            'LBL_PRIVATE_ROOM_ENTERED_USER' => 
'private_room_entered_user',
 
  303            'LBL_KICKED_FROM_PRIVATE_ROOM' => 
'kicked_from_private_room',
 
  305            'LBL_INVITE' => 
'chat_invite',
 
  306            'LBL_CANCEL' => 
'cancel',
 
  307            'LBL_WHISPER_TO' => 
'whisper_to',
 
  308            'LBL_SPEAK_TO' => 
'speak_to',
 
  309            'LBL_HISTORY_CLEARED' => 
'history_cleared',
 
  310            'LBL_CLEAR_ROOM_HISTORY' => 
'clear_room_history',
 
  311            'LBL_CLEAR_ROOM_HISTORY_QUESTION' => 
'clear_room_history_question',
 
  312            'LBL_END_WHISPER' => 
'end_whisper',
 
  313            'LBL_TIMEFORMAT' => 
'lang_timeformat_no_sec',
 
  314            'LBL_DATEFORMAT' => 
'lang_dateformat' 
  316        foreach ($js_translations as $placeholder => $lng_variable) {
 
  317            $roomTpl->
setVariable($placeholder, json_encode($this->ilLng->txt($lng_variable)));
 
  320        $roomTpl->
setVariable(
'LBL_CREATE_PRIVATE_ROOM', $this->ilLng->txt(
'chat_create_private_room_button'));
 
  321        $roomTpl->
setVariable(
'LBL_CREATE_PRIVATE_ROOM_TEXT', $this->ilLng->txt(
'create_private_room_text'));
 
  322        $roomTpl->
setVariable(
'LBL_LAYOUT', $this->ilLng->txt(
'layout'));
 
  323        $roomTpl->
setVariable(
'LBL_SHOW_SETTINGS', $this->ilLng->txt(
'show_settings'));
 
  324        $roomTpl->
setVariable(
'LBL_USER_IN_ROOM', $this->ilLng->txt(
'user_in_room'));
 
  325        $roomTpl->
setVariable(
'LBL_USER_IN_ILIAS', $this->ilLng->txt(
'user_in_ilias'));
 
  333        $roomTpl->
setVariable(
'LBL_NO_FURTHER_USERS', $this->ilLng->txt(
'no_further_users'));
 
  344        require_once 
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
 
  348        $selectionForm = $formFactory->getUserChatNameSelectionForm($name_options);
 
  352        $selectionForm->addCommandButton(
'view-joinWithCustomName', $this->ilLng->txt(
'enter'));
 
  353        $selectionForm->setFormAction(
 
  357        $this->mainTpl->setVariable(
'ADM_CONTENT', $selectionForm->getHtml());
 
  368        include_once 
'Modules/Chatroom/classes/class.ilChatroom.php';
 
  370        $this->redirectIfNoPermission(
'read');
 
  372        $this->gui->switchToVisibleMode();
 
  373        $this->setupTemplate();
 
  375        $chatSettings = 
new ilSetting(
'chatroom');
 
  376        if (!$chatSettings->get(
'chat_enabled')) {
 
  383        if (!$room->getSetting(
'allow_anonymous') && $this->ilUser->isAnonymous()) {
 
  384            $this->cancelJoin($this->ilLng->txt(
'chat_anonymous_not_allowed'));
 
  390        if ($room->getSetting(
'allow_custom_usernames')) {
 
  391            if ($room->isSubscribed($chat_user->getUserId())) {
 
  392                $chat_user->setUsername($chat_user->getUsername());
 
  393                $this->showRoom($room, $chat_user);
 
  395                $this->showNameSelection($chat_user);
 
  398            $chat_user->setUsername($this->ilUser->getLogin());
 
  399            $this->showRoom($room, $chat_user);
 
  408        $chatSettings = 
new ilSetting(
'chatroom');
 
  409        if (!$chatSettings->get(
'chat_enabled')) {
 
  415        $user_id = $_REQUEST[
'usr_id'];
 
  416        $connector = $this->gui->getConnector();
 
  417        $title = $room->getUniquePrivateRoomTitle($chat_user->buildLogin());
 
  418        $subRoomId = $room->addPrivateRoom(
$title, $chat_user, array(
'public' => 
false));
 
  420        $room->inviteUserToPrivateRoom($user_id, $subRoomId);
 
  421        $connector->sendCreatePrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), 
$title);
 
  422        $connector->sendInviteToPrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), $user_id);
 
  424        $room->sendInvitationNotification($this->gui, $chat_user, $user_id, $subRoomId);
 
  426        $_REQUEST[
'sub'] = $subRoomId;
 
  428        $_SESSION[
'show_invitation_message'] = $user_id;
 
  442        $pid = $this->tree->getParentId($this->gui->getRefId());
 
  452        if (isset(
$_GET[
'msg'])) {
 
  453            switch (
$_GET[
'msg']) {
 
  473    public function getUserProfileImages()
 
  479        if (!$this->ilUser) {
 
  484        if (!isset(
$_GET[
'usr_ids']) || strlen(
$_GET[
'usr_ids']) == 0) {
 
  489        $this->ilLng->loadLanguageModule(
'user');
 
  493        $user_ids = array_filter(array_map(
'intval', array_map(
'trim', explode(
',', 
$_GET[
'usr_ids']))));
 
  497        $chatRoomUserDetailsByUsrId = array_combine(
 
  499                function (stdClass $userData) {
 
  500                    return $userData->id;
 
  510        foreach ($user_ids as $usr_id) {
 
  511            if (!array_key_exists($usr_id, $chatRoomUserDetailsByUsrId)) {
 
  515            if ($room->getSetting(
'allow_custom_usernames')) {
 
  517                $avatar = 
$DIC[
"user.avatar.factory"]->avatar(
'xsmall');
 
  518                $avatar->setUsrId(ANONYMOUS_USER_ID);
 
  519                $avatar->setName(
ilStr::subStr($chatRoomUserDetailsByUsrId[$usr_id]->login, 0, 2));
 
  521                $public_name = $chatRoomUserDetailsByUsrId[$usr_id]->login;
 
  522                $public_image = $avatar->getUrl();
 
  524                $public_image = isset($public_data[$usr_id]) && isset($public_data[$usr_id][
'img']) ? $public_data[$usr_id][
'img'] : 
'';
 
  526                if (isset($public_names[$usr_id])) {
 
  527                    $public_name = $public_names[$usr_id];
 
  528                    if (
'unknown' == $public_name && isset($public_data[$usr_id]) && isset($public_data[$usr_id][
'login'])) {
 
  529                        $public_name = $public_data[$usr_id][
'login'];
 
  535                'public_name' => $public_name,
 
  536                'profile_image' => $public_image,
 
An exception for terminatinating execution or to throw for unit testing.
setVariable($variable, $value='')
Sets a variable value.
Class ilChatroomGUIHandler.
static getUserInformation(array $usrIds, int $roomId=null)
getChatNameSuggestions()
Returns an array of chat-name suggestions.
getUserId()
Returns Ilias User ID.
getUsername()
Returns username from Object or SESSION.
joinWithCustomName()
Joins user to chatroom with custom username, fetched from $_REQUEST['custom_username_text'] or by cal...
renderLanguageVariables(ilTemplate $roomTpl)
renderFileUploadForm(ilTemplate $roomTpl)
Prepares Fileupload form and displays it.
renderRightUsersBlock(ilTemplate $roomTpl)
executeDefault($method)
Chatroom and Chatuser get prepared before $this->showRoom method is called.
setupTemplate()
Adds CSS and JavaScript files that should be included in the header.
showNameSelection(ilChatroomUser $chat_user)
Prepares and displays name selection.
cancelJoin($message)
Calls ilUtil::sendFailure method using given $message as parameter.
showRoom(ilChatroom $room, ilChatroomUser $chat_user)
Prepares and displays chatroom and connects user to it.
renderSendMessageBox(ilTemplate $roomTpl)
isSubscribed($chat_userid)
Returns true if entry exists in userTable matching given $chat_userid and $this->roomId.
isUserBanned($user_id)
Returns true if there's an entry in banTable matching roomId and given $user_id.
connectUser(ilChatroomUser $user)
Connects user by inserting userdata into userTable.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
getConnectedUsers($only_data=true)
Returns an array of connected users.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
getActivePrivateRooms($userid)
subscribeUserToPrivateRoom($room_id, $user_id)
getLastMessages($number, $chatuser=null)
getRoomId()
Returns roomID from $this->roomId.
getSetting($name)
Returns setting from $this->settings array by given name.
isAllowedToEnterPrivateRoom($chat_userid, $proom_id)
This class provides processing control methods.
getLinkTargetByClass( $a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui class name.
getFormAction( $a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
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.
setParameterByClass($a_class, $a_parameter, $a_value)
Same as setParameterByClass, except that a class name is passed.
redirectByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to other gui class using class name.
redirect($a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to another command.
getLinkTarget( $a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui object.
setParameter($a_obj, $a_parameter, $a_value)
Set parameters that should be passed a form and link of a gui class.
static initJS(ilTemplate $a_main_tpl=null)
Init javascript.
const PANEL_STYLE_SECONDARY
const HEADING_STYLE_BLOCK
static getInstance()
Get instance.
static subStr($a_str, $a_start, $a_length=null)
special template class to simplify handling of ITX/PEAR
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
catch(Exception $e) $message