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')
38 $username = $_REQUEST[
'custom_username_text'];
40 elseif(method_exists($chat_user,
'build' . $_REQUEST[
'custom_username_radio']))
42 $username = $chat_user->{
'build' . $_REQUEST[
'custom_username_radio']}();
49 if(!
$failure && trim($username) !=
'')
51 if(!$room->isSubscribed($chat_user->getUserId()))
53 $chat_user->setUsername($chat_user->buildUniqueUsername($username));
56 $this->showRoom($room, $chat_user);
61 $this->showNameSelection($chat_user);
68 private function setupTemplate()
75 $tpl->addJavaScript(
'Modules/Chatroom/js/colorpicker/jquery.colorPicker.js');
76 $tpl->addJavaScript(
'Modules/Chatroom/js/chat.js');
77 $tpl->addJavaScript(
'Modules/Chatroom/js/iliaschat.jquery.js');
78 $tpl->addJavaScript(
'Services/jQuery/js/jquery.outside.events.min.js');
79 $tpl->addJavaScript(
'Modules/Chatroom/js/json2.js');
81 $tpl->addJavaScript(
'./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js');
83 $tpl->addCSS(
'Modules/Chatroom/js/colorpicker/colorPicker.css');
84 $tpl->addCSS(
'Modules/Chatroom/templates/default/style.css');
106 $ilCtrl->setParameterByClass(
'ilrepositorygui',
'ref_id', ROOT_FOLDER_ID);
107 $ilCtrl->redirectByClass(
'ilrepositorygui',
'');
110 $user_id = $chat_user->
getUserId($ilUser);
112 $ilNavigationHistory->addItem(
$_GET[
'ref_id'], $ilCtrl->getLinkTargetByClass(
'ilrepositorygui',
'view'),
'chtr');
121 $connector = $this->gui->getConnector();
122 $response = @$connector->connect($scope, $user_id);
127 $ilCtrl->redirectByClass(
'ilinfoscreengui',
'info');
132 $room->connectUser($chat_user);
136 $response = $connector->sendEnterPrivateRoom($scope, $subScope, $user_id);
140 $ilCtrl->redirectByClass(
'ilinfoscreengui',
'info');
143 $connection_info = json_decode($response);
144 $settings = $connector->getSettings();
147 $initial =
new stdClass();
149 $initial->private_rooms = array_values($known_private_room);
150 $initial->redirect_url = $ilCtrl->getLinkTarget($this->gui,
'view-lostConnection',
'',
false,
false);
151 $initial->private_rooms_enabled = (boolean)$room->
getSetting(
'private_rooms_enabled');
152 $initial->subdirectory = $settings->getSubDirectory();
154 $initial->userinfo =
array(
155 'moderator' => $rbacsystem->checkAccess(
'moderate', (
int)
$_GET[
'ref_id']),
162 include_once(
'Modules/Chatroom/classes/class.ilChatroomSmilies.php');
164 if($settings->getSmiliesEnabled())
166 $smileys_array = ilChatroomSmilies::_getSmilies();
167 foreach($smileys_array as $smiley_array)
171 foreach($smiley_array as $key => $value)
173 if($key ==
'smiley_keywords')
175 $new_keys = explode(
"\n", $value);
178 if($key ==
'smiley_fullpath')
184 if(!$new_keys || !$new_val)
189 foreach($new_keys as $new_key)
191 $smileys[$new_key] = $new_val;
195 $initial->smileys = $smileys;
199 $initial->smileys =
'{}';
202 $initial->messages =
array();
204 if(isset($_REQUEST[
'sub']))
206 if($known_private_room[$_REQUEST[
'sub']])
210 $initial->messages[] =
array(
212 'message' => $lng->txt(
'not_allowed_to_enter'),
220 $params[
'sub'] = $_REQUEST[
'sub'];
222 $params[
'message'] = json_encode(
224 'type' =>
'private_room_entered',
229 $connector = $this->gui->getConnector();
230 $response = $connector->sendEnterPrivateRoom($scope, $_REQUEST[
'sub'], $chat_user->
getUserId());
237 $initial->enter_room = $_REQUEST[
'sub'];
242 $initial->messages[] =
array(
244 'message' => $lng->txt(
'user_invited'),
249 if((
int)$room->
getSetting(
'display_past_msgs'))
251 $initial->messages = array_merge($initial->messages, array_reverse($room->
getLastMessages($room->
getSetting(
'display_past_msgs'), $chat_user)));
254 $roomTpl =
new ilTemplate(
'tpl.chatroom.html',
true,
true,
'Modules/Chatroom');
255 $roomTpl->setVariable(
'SESSION_ID', $connection_info->{
'session-id'});
256 $roomTpl->setVariable(
'BASEURL', $settings->generateClientUrl());
257 $roomTpl->setVariable(
'INSTANCE', $settings->getInstance());
258 $roomTpl->setVariable(
'SCOPE', $scope);
259 $roomTpl->setVariable(
'MY_ID', $user_id);
260 $roomTpl->setVariable(
'INITIAL_DATA', json_encode($initial));
261 $roomTpl->setVariable(
'POSTURL',
$ilCtrl->getLinkTarget($this->gui,
'postMessage',
'',
true,
true));
263 $roomTpl->setVariable(
'ACTIONS',
$lng->txt(
'actions'));
264 $roomTpl->setVariable(
'LBL_CREATE_PRIVATE_ROOM',
$lng->txt(
'create_private_room_label'));
265 $roomTpl->setVariable(
'LBL_USER',
$lng->txt(
'user'));
266 $roomTpl->setVariable(
'LBL_USER_TEXT',
$lng->txt(
'invite_username'));
267 $roomTpl->setVariable(
'LBL_AUTO_SCROLL',
$lng->txt(
'auto_scroll'));
271 $this->renderFontSettings($roomTpl,
array());
273 $this->renderSendMessageBox($roomTpl);
274 $this->renderLanguageVariables($roomTpl);
276 require_once
'Services/UIComponent/Modal/classes/class.ilModalGUI.php';
279 $roomRightTpl =
new ilTemplate(
'tpl.chatroom_right.html',
true,
true,
'Modules/Chatroom');
280 $this->renderRightUsersBlock($roomRightTpl);
282 require_once
'Services/UIComponent/Panel/classes/class.ilPanelGUI.php';
284 $right_content_panel->setHeading(
$lng->txt(
'users'));
287 $right_content_panel->setBody($roomRightTpl->get());
289 $tpl->setContent($roomTpl->get());
290 $tpl->setRightContent($right_content_panel->getHTML());
308 private function renderFontSettings(
ilTemplate $roomTpl,
array $defaultSettings)
316 $font_family =
array(
317 'sans' =>
'Sans Serif',
319 'monospace' =>
'Monospace',
323 'italic' => $lng->txt(
'italic'),
324 'bold' => $lng->txt(
'bold'),
325 'normal' => $lng->txt(
'normal'),
326 'underlined' => $lng->txt(
'underlined'),
330 'small' => $lng->txt(
'small'),
331 'normal' => $lng->txt(
'normal'),
332 'large' => $lng->txt(
'large')
335 $default_font_color =
'#000000';
337 $default_font_family = (
338 isset($defaultSettings[
'font_family']) &&
339 isset($font_family[$defaultSettings[
'font_family']]) ?
340 $defaultSettings[
'font_family'] :
'sans' 343 $default_font_style = (
344 isset($defaultSettings[
'font_style']) &&
345 isset($font_family[$defaultSettings[
'font_style']]) ?
346 $defaultSettings[
'font_style'] :
'normal' 349 $default_font_size = (
350 isset($defaultSettings[
'font_size']) &&
351 isset($font_family[$defaultSettings[
'font_size']]) ?
352 $defaultSettings[
'font_size'] :
'normal' 355 $roomTpl->
setVariable(
'VAL_FONTCOLOR', $default_font_color);
357 foreach($font_family as $font => $label)
363 'SELECTED_FONTFAMILY', $font == $default_font_family ?
364 'selected="selected"' :
'' 369 foreach($font_style as $font => $label)
375 'SELECTED_FONTSTYLE', $font == $default_font_style ?
376 'selected="selected"' :
'' 381 foreach($font_size as $font => $label)
388 $font == $default_font_size ?
'selected="selected"' :
'' 393 $roomTpl->
setVariable(
'LBL_FONTCOLOR', $lng->txt(
'fontcolor'));
394 $roomTpl->
setVariable(
'LBL_FONTFAMILY', $lng->txt(
'fontfamily'));
395 $roomTpl->
setVariable(
'LBL_FONTSTYLE', $lng->txt(
'fontstyle'));
396 $roomTpl->
setVariable(
'LBL_FONTSIZE', $lng->txt(
'fontsize'));
398 $logoutLink = $ilCtrl->getLinkTarget($this->gui,
'view-logout');
411 require_once
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
413 $file_upload = $formFactory->getFileUploadForm();
415 $roomTpl->
setVariable(
'FILE_UPLOAD', $file_upload->getHTML());
421 protected function renderSendMessageBox(
ilTemplate $roomTpl)
428 $roomTpl->
setVariable(
'LBL_MESSAGE', $lng->txt(
'chat_message'));
429 $roomTpl->
setVariable(
'LBL_TOALL', $lng->txt(
'chat_message_to_all'));
430 $roomTpl->
setVariable(
'LBL_OPTIONS', $lng->txt(
'chat_message_options'));
431 $roomTpl->
setVariable(
'LBL_DISPLAY', $lng->txt(
'chat_message_display'));
432 $roomTpl->
setVariable(
'LBL_SEND', $lng->txt(
'send'));
438 protected function renderLanguageVariables(
ilTemplate $roomTpl)
445 $js_translations =
array(
446 'LBL_MAINROOM' =>
'chat_mainroom',
447 'LBL_LEAVE_PRIVATE_ROOM' =>
'leave_private_room',
448 'LBL_LEFT_PRIVATE_ROOM' =>
'left_private_room',
449 'LBL_JOIN' =>
'chat_join',
450 'LBL_DELETE_PRIVATE_ROOM' =>
'delete_private_room',
451 'LBL_DELETE_PRIVATE_ROOM_QUESTION' =>
'delete_private_room_question',
452 'LBL_INVITE_TO_PRIVATE_ROOM' =>
'invite_to_private_room',
453 'LBL_KICK' =>
'chat_kick',
454 'LBL_BAN' =>
'chat_ban',
455 'LBL_KICK_QUESTION' =>
'kick_question',
456 'LBL_BAN_QUESTION' =>
'ban_question',
457 'LBL_ADDRESS' =>
'chat_address',
458 'LBL_WHISPER' =>
'chat_whisper',
459 'LBL_CONNECT' =>
'chat_connection_established',
460 'LBL_DISCONNECT' =>
'chat_connection_disconnected',
461 'LBL_TO_MAINROOM' =>
'chat_to_mainroom',
462 'LBL_CREATE_PRIVATE_ROOM_JS' =>
'chat_create_private_room_button',
463 'LBL_WELCOME_TO_CHAT' =>
'welcome_to_chat',
464 'LBL_USER_INVITED' =>
'user_invited',
465 'LBL_USER_KICKED' =>
'user_kicked',
466 'LBL_USER_INVITED_SELF' =>
'user_invited_self',
467 'LBL_PRIVATE_ROOM_CLOSED' =>
'private_room_closed',
468 'LBL_PRIVATE_ROOM_ENTERED' =>
'private_room_entered',
469 'LBL_PRIVATE_ROOM_LEFT' =>
'private_room_left',
470 'LBL_PRIVATE_ROOM_ENTERED_USER' =>
'private_room_entered_user',
471 'LBL_KICKED_FROM_PRIVATE_ROOM' =>
'kicked_from_private_room',
473 'LBL_INVITE' =>
'chat_invite',
474 'LBL_CANCEL' =>
'cancel',
475 'LBL_WHISPER_TO' =>
'whisper_to',
476 'LBL_SPEAK_TO' =>
'speak_to',
477 'LBL_HISTORY_CLEARED' =>
'history_cleared',
478 'LBL_CLEAR_ROOM_HISTORY' =>
'clear_room_history',
479 'LBL_CLEAR_ROOM_HISTORY_QUESTION' =>
'clear_room_history_question',
480 'LBL_END_WHISPER' =>
'end_whisper',
481 'LBL_SHOW_SETTINGS_JS' =>
'show_settings',
482 'LBL_HIDE_SETTINGS' =>
'hide_settings',
483 'LBL_TIMEFORMAT' =>
'lang_timeformat_no_sec',
484 'LBL_DATEFORMAT' =>
'lang_dateformat' 486 foreach($js_translations as $placeholder => $lng_variable)
488 $roomTpl->
setVariable($placeholder, json_encode($lng->txt($lng_variable)));
491 $roomTpl->
setVariable(
'LBL_CREATE_PRIVATE_ROOM', $lng->txt(
'chat_create_private_room_button'));
492 $roomTpl->
setVariable(
'LBL_CREATE_PRIVATE_ROOM_TEXT', $lng->txt(
'create_private_room_text'));
493 $roomTpl->
setVariable(
'LBL_LAYOUT', $lng->txt(
'layout'));
494 $roomTpl->
setVariable(
'LBL_SHOW_SETTINGS', $lng->txt(
'show_settings'));
495 $roomTpl->
setVariable(
'LBL_USER_IN_ROOM', $lng->txt(
'user_in_room'));
496 $roomTpl->
setVariable(
'LBL_USER_IN_ILIAS', $lng->txt(
'user_in_ilias'));
502 protected function renderRightUsersBlock(
ilTemplate $roomTpl)
509 $roomTpl->
setVariable(
'LBL_NO_FURTHER_USERS', $lng->txt(
'no_further_users'));
527 require_once
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
531 $selectionForm = $formFactory->getUserChatNameSelectionForm($name_options);
533 $ilCtrl->saveParameter($this->gui,
'sub');
535 $selectionForm->addCommandButton(
'view-joinWithCustomName', $lng->txt(
'enter'));
536 $selectionForm->setFormAction(
537 $ilCtrl->getFormAction($this->gui,
'view-joinWithCustomName')
540 $tpl->setVariable(
'ADM_CONTENT', $selectionForm->getHtml());
558 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
562 $this->gui->switchToVisibleMode();
563 $this->setupTemplate();
565 $chatSettings =
new ilSetting(
'chatroom');
566 if(!$chatSettings->get(
'chat_enabled'))
568 $ilCtrl->redirect($this->gui,
'settings-general');
574 if(!$room->
getSetting(
'allow_anonymous') && $ilUser->isAnonymous())
576 $this->
cancelJoin($lng->txt(
'anonymous_not_allowed'));
582 if($room->
getSetting(
'allow_custom_usernames'))
587 $this->showRoom($room, $chat_user);
591 $this->showNameSelection($chat_user);
597 $this->showRoom($room, $chat_user);
604 public function invitePD()
612 $chatSettings =
new ilSetting(
'chatroom');
613 if(!$chatSettings->get(
'chat_enabled'))
615 $ilCtrl->redirect($this->gui,
'settings-general');
620 $user_id = $_REQUEST[
'usr_id'];
621 $connector = $this->gui->getConnector();
625 $room->inviteUserToPrivateRoom($user_id, $subRoomId);
626 $connector->sendCreatePrivateRoom($room->
getRoomId(), $subRoomId, $chat_user->getUserId(),
$title);
627 $connector->sendInviteToPrivateRoom($room->
getRoomId(), $subRoomId, $chat_user->getUserId(), $user_id);
629 $room->sendInvitationNotification($this->gui, $chat_user, $user_id, $subRoomId);
631 $_REQUEST[
'sub'] = $subRoomId;
633 $_SESSION[
'show_invitation_message'] = $user_id;
635 $ilCtrl->setParameter($this->gui,
'sub', $subRoomId);
636 $ilCtrl->redirect($this->gui,
'view');
642 public function logout()
653 $pid = $tree->getParentId($this->gui->getRefId());
654 $ilCtrl->setParameterByClass(
'ilrepositorygui',
'ref_id', $pid);
655 $ilCtrl->redirectByClass(
'ilrepositorygui',
'');
661 public function lostConnection()
669 if(isset(
$_GET[
'msg']))
691 $ilCtrl->redirectByClass(
'ilinfoscreengui',
'info');
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 ilDBInterface $ilDB...
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()
Init javascript.
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)
special template class to simplify handling of ITX/PEAR
getConnectedUsers()
Returns an array of connected users.
subscribeUserToPrivateRoom($room_id, $user_id)
isSuccessful($response)
Checks for success param in an json decoded response.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setCurrentBlock($part="DEFAULT")
Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt.
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.
const HEADING_STYLE_BLOCK
parseCurrentBlock($part="DEFAULT")
Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt public...
isAllowedToEnterPrivateRoom($chat_userid, $proom_id)