4 require_once
'Modules/Chatroom/classes/class.ilChatroom.php';
5 require_once
'Modules/Chatroom/classes/class.ilChatroomUser.php';
21 public function joinWithCustomName()
29 $this->gui->switchToVisibleMode();
30 $this->setupTemplate();
36 if ($_REQUEST[
'custom_username_radio'] ==
'custom_username') {
37 $username = $_REQUEST[
'custom_username_text'];
38 } elseif (method_exists($chat_user,
'build' . $_REQUEST[
'custom_username_radio'])) {
39 $username = $chat_user->{
'build' . $_REQUEST[
'custom_username_radio']}();
44 if (!
$failure && trim($username) !=
'') {
45 if (!$room->isSubscribed($chat_user->getUserId())) {
46 $chat_user->setUsername($chat_user->buildUniqueUsername($username));
49 $this->showRoom($room, $chat_user);
52 $this->showNameSelection($chat_user);
59 private function setupTemplate()
66 $tpl->addJavaScript(
'Modules/Chatroom/js/chat.js');
67 $tpl->addJavaScript(
'Modules/Chatroom/js/iliaschat.jquery.js');
68 $tpl->addJavaScript(
'libs/bower/bower_components/jquery-outside-events/jquery.ba-outside-events.min.js');
69 $tpl->addJavaScript(
'Modules/Chatroom/js/json2.js');
71 $tpl->addJavaScript(
'./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js');
73 $tpl->addCSS(
'Modules/Chatroom/templates/default/style.css');
95 $user_id = $chat_user->
getUserId($ilUser);
97 $ilNavigationHistory->addItem(
$_GET[
'ref_id'], $ilCtrl->getLinkTargetByClass(
'ilrepositorygui',
'view'),
'chtr');
105 $connector = $this->gui->getConnector();
106 $response = @$connector->connect($scope, $user_id);
110 $ilCtrl->redirectByClass(
'ilinfoscreengui',
'info');
118 $response = $connector->sendEnterPrivateRoom($scope, $subScope, $user_id);
121 $ilCtrl->redirectByClass(
'ilinfoscreengui',
'info');
124 $connection_info = json_decode(
$response);
125 $settings = $connector->getSettings();
128 $initial =
new stdClass();
130 $initial->private_rooms = array_values($known_private_room);
131 $initial->redirect_url = $ilCtrl->getLinkTarget($this->gui,
'view-lostConnection',
'',
false,
false);
132 $initial->profile_image_url = $ilCtrl->getLinkTarget($this->gui,
'view-getUserProfileImages',
'',
true,
false);
134 $initial->private_rooms_enabled = (boolean) $room->
getSetting(
'private_rooms_enabled');
135 $initial->subdirectory = $settings->getSubDirectory();
137 $initial->userinfo =
array(
145 include_once(
'Modules/Chatroom/classes/class.ilChatroomSmilies.php');
147 if ($settings->getSmiliesEnabled()) {
148 $smileys_array = ilChatroomSmilies::_getSmilies();
149 foreach ($smileys_array as $smiley_array) {
152 foreach ($smiley_array as
$key => $value) {
153 if (
$key ==
'smiley_keywords') {
154 $new_keys = explode(
"\n", $value);
157 if (
$key ==
'smiley_fullpath') {
162 if (!$new_keys || !$new_val) {
166 foreach ($new_keys as $new_key) {
167 $smileys[$new_key] = $new_val;
171 $initial->smileys = $smileys;
173 $initial->smileys =
'{}';
176 $initial->messages =
array();
178 if (isset($_REQUEST[
'sub'])) {
179 if ($known_private_room[$_REQUEST[
'sub']]) {
181 $initial->messages[] =
array(
183 'message' => $lng->txt(
'not_allowed_to_enter'),
189 $params[
'sub'] = $_REQUEST[
'sub'];
191 $params[
'message'] = json_encode(
193 'type' =>
'private_room_entered',
198 $connector = $this->gui->getConnector();
199 $response = $connector->sendEnterPrivateRoom($scope, $_REQUEST[
'sub'], $chat_user->
getUserId());
205 $initial->enter_room = $_REQUEST[
'sub'];
208 $initial->messages[] =
array(
210 'message' => $lng->txt(
'user_invited'),
215 if ((
int) $room->
getSetting(
'display_past_msgs')) {
216 $initial->messages = array_merge($initial->messages, array_reverse($room->
getLastMessages($room->
getSetting(
'display_past_msgs'), $chat_user)));
219 $roomTpl =
new ilTemplate(
'tpl.chatroom.html',
true,
true,
'Modules/Chatroom');
220 $roomTpl->setVariable(
'SESSION_ID', $connection_info->{
'session-id'});
221 $roomTpl->setVariable(
'BASEURL', $settings->generateClientUrl());
222 $roomTpl->setVariable(
'INSTANCE', $settings->getInstance());
223 $roomTpl->setVariable(
'SCOPE', $scope);
224 $roomTpl->setVariable(
'MY_ID', $user_id);
225 $roomTpl->setVariable(
'INITIAL_DATA', json_encode($initial));
226 $roomTpl->setVariable(
'POSTURL',
$ilCtrl->getLinkTarget($this->gui,
'postMessage',
'',
true,
true));
228 $roomTpl->setVariable(
'ACTIONS',
$lng->txt(
'actions'));
229 $roomTpl->setVariable(
'LBL_CREATE_PRIVATE_ROOM',
$lng->txt(
'create_private_room_label'));
230 $roomTpl->setVariable(
'LBL_USER',
$lng->txt(
'user'));
231 $roomTpl->setVariable(
'LBL_USER_TEXT',
$lng->txt(
'invite_username'));
232 $roomTpl->setVariable(
'LBL_AUTO_SCROLL',
$lng->txt(
'auto_scroll'));
237 $this->renderSendMessageBox($roomTpl);
238 $this->renderLanguageVariables($roomTpl);
240 require_once
'Services/UIComponent/Modal/classes/class.ilModalGUI.php';
243 $roomRightTpl =
new ilTemplate(
'tpl.chatroom_right.html',
true,
true,
'Modules/Chatroom');
244 $this->renderRightUsersBlock($roomRightTpl);
246 require_once
'Services/UIComponent/Panel/classes/class.ilPanelGUI.php';
248 $right_content_panel->setHeading(
$lng->txt(
'users'));
251 $right_content_panel->setBody($roomRightTpl->get());
253 $tpl->setContent($roomTpl->get());
254 $tpl->setRightContent($right_content_panel->getHTML());
275 require_once
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
277 $file_upload = $formFactory->getFileUploadForm();
279 $roomTpl->
setVariable(
'FILE_UPLOAD', $file_upload->getHTML());
285 protected function renderSendMessageBox(
ilTemplate $roomTpl)
292 $roomTpl->
setVariable(
'LBL_MESSAGE', $lng->txt(
'chat_message'));
293 $roomTpl->
setVariable(
'LBL_TOALL', $lng->txt(
'chat_message_to_all'));
294 $roomTpl->
setVariable(
'LBL_OPTIONS', $lng->txt(
'chat_message_options'));
295 $roomTpl->
setVariable(
'LBL_DISPLAY', $lng->txt(
'chat_message_display'));
296 $roomTpl->
setVariable(
'LBL_SEND', $lng->txt(
'send'));
302 protected function renderLanguageVariables(
ilTemplate $roomTpl)
309 $js_translations =
array(
310 'LBL_MAINROOM' =>
'chat_mainroom',
311 'LBL_LEAVE_PRIVATE_ROOM' =>
'leave_private_room',
312 'LBL_LEFT_PRIVATE_ROOM' =>
'left_private_room',
313 'LBL_JOIN' =>
'chat_join',
314 'LBL_DELETE_PRIVATE_ROOM' =>
'delete_private_room',
315 'LBL_DELETE_PRIVATE_ROOM_QUESTION' =>
'delete_private_room_question',
316 'LBL_INVITE_TO_PRIVATE_ROOM' =>
'invite_to_private_room',
317 'LBL_KICK' =>
'chat_kick',
318 'LBL_BAN' =>
'chat_ban',
319 'LBL_KICK_QUESTION' =>
'kick_question',
320 'LBL_BAN_QUESTION' =>
'ban_question',
321 'LBL_ADDRESS' =>
'chat_address',
322 'LBL_WHISPER' =>
'chat_whisper',
323 'LBL_CONNECT' =>
'chat_connection_established',
324 'LBL_DISCONNECT' =>
'chat_connection_disconnected',
325 'LBL_TO_MAINROOM' =>
'chat_to_mainroom',
326 'LBL_CREATE_PRIVATE_ROOM_JS' =>
'chat_create_private_room_button',
327 'LBL_WELCOME_TO_CHAT' =>
'welcome_to_chat',
328 'LBL_USER_INVITED' =>
'user_invited',
329 'LBL_USER_KICKED' =>
'user_kicked',
330 'LBL_USER_INVITED_SELF' =>
'user_invited_self',
331 'LBL_PRIVATE_ROOM_CLOSED' =>
'private_room_closed',
332 'LBL_PRIVATE_ROOM_ENTERED' =>
'private_room_entered',
333 'LBL_PRIVATE_ROOM_LEFT' =>
'private_room_left',
334 'LBL_PRIVATE_ROOM_ENTERED_USER' =>
'private_room_entered_user',
335 'LBL_KICKED_FROM_PRIVATE_ROOM' =>
'kicked_from_private_room',
337 'LBL_INVITE' =>
'chat_invite',
338 'LBL_CANCEL' =>
'cancel',
339 'LBL_WHISPER_TO' =>
'whisper_to',
340 'LBL_SPEAK_TO' =>
'speak_to',
341 'LBL_HISTORY_CLEARED' =>
'history_cleared',
342 'LBL_CLEAR_ROOM_HISTORY' =>
'clear_room_history',
343 'LBL_CLEAR_ROOM_HISTORY_QUESTION' =>
'clear_room_history_question',
344 'LBL_END_WHISPER' =>
'end_whisper',
345 'LBL_TIMEFORMAT' =>
'lang_timeformat_no_sec',
346 'LBL_DATEFORMAT' =>
'lang_dateformat' 348 foreach ($js_translations as $placeholder => $lng_variable) {
349 $roomTpl->
setVariable($placeholder, json_encode($lng->txt($lng_variable)));
352 $roomTpl->
setVariable(
'LBL_CREATE_PRIVATE_ROOM', $lng->txt(
'chat_create_private_room_button'));
353 $roomTpl->
setVariable(
'LBL_CREATE_PRIVATE_ROOM_TEXT', $lng->txt(
'create_private_room_text'));
354 $roomTpl->
setVariable(
'LBL_LAYOUT', $lng->txt(
'layout'));
355 $roomTpl->
setVariable(
'LBL_SHOW_SETTINGS', $lng->txt(
'show_settings'));
356 $roomTpl->
setVariable(
'LBL_USER_IN_ROOM', $lng->txt(
'user_in_room'));
357 $roomTpl->
setVariable(
'LBL_USER_IN_ILIAS', $lng->txt(
'user_in_ilias'));
363 protected function renderRightUsersBlock(
ilTemplate $roomTpl)
370 $roomTpl->
setVariable(
'LBL_NO_FURTHER_USERS', $lng->txt(
'no_further_users'));
388 require_once
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
392 $selectionForm = $formFactory->getUserChatNameSelectionForm($name_options);
394 $ilCtrl->saveParameter($this->gui,
'sub');
396 $selectionForm->addCommandButton(
'view-joinWithCustomName', $lng->txt(
'enter'));
397 $selectionForm->setFormAction(
398 $ilCtrl->getFormAction($this->gui,
'view-joinWithCustomName')
401 $tpl->setVariable(
'ADM_CONTENT', $selectionForm->getHtml());
419 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
423 $this->gui->switchToVisibleMode();
424 $this->setupTemplate();
426 $chatSettings =
new ilSetting(
'chatroom');
427 if (!$chatSettings->get(
'chat_enabled')) {
428 $ilCtrl->redirect($this->gui,
'settings-general');
434 if (!$room->
getSetting(
'allow_anonymous') && $ilUser->isAnonymous()) {
435 $this->
cancelJoin($lng->txt(
'chat_anonymous_not_allowed'));
441 if ($room->
getSetting(
'allow_custom_usernames')) {
444 $this->showRoom($room, $chat_user);
446 $this->showNameSelection($chat_user);
450 $this->showRoom($room, $chat_user);
457 public function invitePD()
465 $chatSettings =
new ilSetting(
'chatroom');
466 if (!$chatSettings->get(
'chat_enabled')) {
467 $ilCtrl->redirect($this->gui,
'settings-general');
472 $user_id = $_REQUEST[
'usr_id'];
473 $connector = $this->gui->getConnector();
478 $connector->sendCreatePrivateRoom($room->
getRoomId(), $subRoomId, $chat_user->getUserId(),
$title);
479 $connector->sendInviteToPrivateRoom($room->
getRoomId(), $subRoomId, $chat_user->getUserId(), $user_id);
481 $room->sendInvitationNotification($this->gui, $chat_user, $user_id, $subRoomId);
483 $_REQUEST[
'sub'] = $subRoomId;
485 $_SESSION[
'show_invitation_message'] = $user_id;
487 $ilCtrl->setParameter($this->gui,
'sub', $subRoomId);
488 $ilCtrl->redirect($this->gui,
'view');
494 public function logout()
505 $pid = $tree->getParentId($this->gui->getRefId());
506 $ilCtrl->setParameterByClass(
'ilrepositorygui',
'ref_id', $pid);
507 $ilCtrl->redirectByClass(
'ilrepositorygui',
'');
513 public function lostConnection()
521 if (isset(
$_GET[
'msg'])) {
522 switch (
$_GET[
'msg']) {
539 $ilCtrl->redirectByClass(
'ilinfoscreengui',
'info');
553 if (!isset(
$_GET[
'usr_ids']) || strlen(
$_GET[
'usr_ids']) == 0) {
558 $DIC[
'lng']->loadLanguageModule(
'user');
560 require_once
'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
563 $user_ids = array_filter(array_map(
'intval', array_map(
'trim', explode(
',',
$_GET[
'usr_ids']))));
564 require_once
'Services/User/classes/class.ilUserUtil.php';
568 foreach ($user_ids as $usr_id) {
569 $public_image = isset($public_data[$usr_id]) && isset($public_data[$usr_id][
'img']) ? $public_data[$usr_id][
'img'] :
'';
572 if (isset($public_names[$usr_id])) {
573 $public_name = $public_names[$usr_id];
574 if (
'unknown' == $public_name && isset($public_data[$usr_id]) && isset($public_data[$usr_id][
'login'])) {
575 $public_name = $public_data[$usr_id][
'login'];
580 'public_name' => $public_name,
581 'profile_image' => $public_image
getUserId()
Returns Ilias User ID.
getActivePrivateRooms($userid)
getUniquePrivateRoomTitle($title)
setUsername($username)
Sets and stores given username in SESSION.
getRoomId()
Returns roomID from $this->roomId.
isUserBanned($user_id)
Returns true if there's an entry in banTable matching roomId and given $user_id.
inviteUserToPrivateRoom($user_id, $proom_id)
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
executeDefault($requestedMethod)
getLastMessages($number, $chatuser=null)
getSetting($name)
Returns setting from $this->settings array by given name.
isSubscribed($chat_userid)
Returns true if entry exists in userTable matching given $chat_userid and $this->roomId.
static initJS(ilTemplate $a_main_tpl=null)
Init javascript.
catch(Exception $e) $message
setVariable($variable, $value='')
Sets a variable value.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
Class ilChatroomGUIHandler.
addPrivateRoom($title, ilChatroomUser $owner, $settings)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
subscribeUserToPrivateRoom($room_id, $user_id)
isSuccessful($response)
Checks for success param in an json decoded response.
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:
connectUser(ilChatroomUser $user)
Connects user by inserting userdata into userTable.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
renderFileUploadForm(ilTemplate $roomTpl)
Prepares Fileupload form and displays it.
getChatNameSuggestions()
Returns an array of chat-name suggestions.
static getInstance()
Get instance.
cancelJoin($message)
Calls ilUtil::sendFailure method using given $message as parameter.
const PANEL_STYLE_SECONDARY
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
getUsername()
Returns username from Object or SESSION.
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
const HEADING_STYLE_BLOCK
getConnectedUsers($only_data=true)
Returns an array of connected users.
isAllowedToEnterPrivateRoom($chat_userid, $proom_id)