4 require_once
'Modules/Chatroom/classes/class.ilChatroom.php';
5 require_once
'Modules/Chatroom/classes/class.ilChatroomUser.php';
56 $ilCtrl->setParameterByClass(
'ilrepositorygui',
'ref_id', ROOT_FOLDER_ID);
57 $ilCtrl->redirectByClass(
'ilrepositorygui',
'');
60 $user_id = $chat_user->
getUserId($ilUser);
62 $ilNavigationHistory->addItem(
$_GET[
'ref_id'], $ilCtrl->getLinkTargetByClass(
'ilrepositorygui',
'view'),
'chtr');
71 $connector = $this->gui->getConnector();
72 $response = @$connector->connect($scope, $user_id);
77 $ilCtrl->redirectByClass(
'ilinfoscreengui',
'info');
82 $messageObject = array(
83 'type' =>
'connected',
90 'timestamp' => time() * 1000
92 $message = json_encode($messageObject);
93 $connector->sendMessage(
101 $connection_info = json_decode($response);
102 $settings = $connector->getSettings();
105 $initial =
new stdClass();
107 $initial->private_rooms = array_values($known_private_room);
108 $initial->redirect_url = $ilCtrl->getLinkTarget($this->gui,
'view-lostConnection',
'',
false,
false);
109 $initial->private_rooms_enabled = (boolean)$room->
getSetting(
'private_rooms_enabled');
111 $initial->userinfo = array(
112 'moderator' => $rbacsystem->checkAccess(
'moderate', (
int)
$_GET[
'ref_id']),
118 include_once(
'Modules/Chatroom/classes/class.ilChatroomSmilies.php');
120 if($settings->getSmiliesEnabled())
123 foreach($smileys_array as $smiley_array)
127 foreach($smiley_array as $key => $value)
129 if($key ==
'smiley_keywords')
131 $new_keys = explode(
"\n", $value);
134 if($key ==
'smiley_fullpath')
140 if(!$new_keys || !$new_val)
145 foreach($new_keys as $new_key)
147 $smileys[$new_key] = $new_val;
151 $initial->smileys = $smileys;
155 $initial->smileys =
'{}';
158 $initial->messages = array();
162 if($known_private_room[
$_REQUEST[
'sub']])
166 $initial->messages[] = array(
168 'message' => $lng->txt(
'not_allowed_to_enter'),
175 $params[
'user'] = $chat_user->
getUserId();
176 $params[
'sub'] = $_REQUEST[
'sub'];
178 $params[
'message'] = json_encode(
180 'type' =>
'private_room_entered',
185 $query = http_build_query($params);
186 $connector = $this->gui->getConnector();
187 $response = $connector->enterPrivateRoom($scope,
$query);
189 $responseObject = json_decode($response);
191 if($responseObject->success ==
true)
196 $message = json_encode(array(
197 'type' =>
'private_room_entered',
198 'user' => $params[
'user'],
199 'sub' => $params[
'sub']
202 $connector->sendMessage($room->
getRoomId(), $message, array(
'public' => 1,
'sub' => $params[
'sub']));
204 $initial->enter_room = $_REQUEST[
'sub'];
205 $initial->messages[] = array(
207 'user' => $params[
'user'],
208 'sub' => $params[
'sub'],
215 $initial->messages[] = array(
217 'message' => $lng->txt(
'user_invited'),
218 'sub' => $_REQUEST[
'sub']
220 unset(
$_SESSION[
'show_invitation_message']);
225 $initial->messages[] = array(
227 'message' => $lng->txt(
'user_invited'),
232 if((
int)$room->
getSetting(
'display_past_msgs'))
234 $initial->messages = array_merge($initial->messages, array_reverse($room->
getLastMessages($room->
getSetting(
'display_past_msgs'), $chat_user)));
237 $roomTpl =
new ilTemplate(
'tpl.chatroom.html',
true,
true,
'Modules/Chatroom');
238 $roomTpl->setVariable(
'SESSION_ID', $connection_info->{
'session-id'});
239 $roomTpl->setVariable(
'BASEURL', $settings->getBaseURL());
240 $roomTpl->setVariable(
'INSTANCE', $settings->getInstance());
241 $roomTpl->setVariable(
'SCOPE', $scope);
242 $roomTpl->setVariable(
'MY_ID', $user_id);
243 $roomTpl->setVariable(
'INITIAL_DATA', json_encode($initial));
244 $roomTpl->setVariable(
'POSTURL',
$ilCtrl->getLinkTarget($this->gui,
'postMessage',
'',
true,
true));
246 $roomTpl->setVariable(
'ACTIONS',
$lng->txt(
'actions'));
247 $roomTpl->setVariable(
'LBL_CREATE_PRIVATE_ROOM',
$lng->txt(
'create_private_room_label'));
248 $roomTpl->setVariable(
'LBL_USER',
$lng->txt(
'user'));
249 $roomTpl->setVariable(
'LBL_USER_TEXT',
$lng->txt(
'invite_username'));
250 $roomTpl->setVariable(
'LBL_AUTO_SCROLL',
$lng->txt(
'auto_scroll'));
254 $this->renderFontSettings($roomTpl, array());
256 $this->renderSendMessageBox($roomTpl);
257 $this->renderLanguageVariables($roomTpl);
259 $roomRightTpl =
new ilTemplate(
'tpl.chatroom_right.html',
true,
true,
'Modules/Chatroom');
260 $this->renderRightUsersBlock($roomRightTpl);
262 require_once
'Services/UIComponent/Panel/classes/class.ilPanelGUI.php';
264 $right_content_panel->setHeading(
$lng->txt(
'users'));
267 $right_content_panel->setBody($roomRightTpl->get());
269 $tpl->setContent($roomTpl->get());
270 $tpl->setRightContent($right_content_panel->getHTML());
276 protected function renderLanguageVariables(
ilTemplate $roomTpl)
283 $js_translations = array(
284 'LBL_MAINROOM' =>
'chat_mainroom',
285 'LBL_LEAVE_PRIVATE_ROOM' =>
'leave_private_room',
286 'LBL_JOIN' =>
'chat_join',
287 'LBL_DELETE_PRIVATE_ROOM' =>
'delete_private_room',
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',
309 'LBL_CANCEL' =>
'cancel',
310 'LBL_WHISPER_TO' =>
'whisper_to',
311 'LBL_SPEAK_TO' =>
'speak_to',
312 'LBL_HISTORY_CLEARED' =>
'history_cleared',
313 'LBL_CLEAR_ROOM_HISTORY' =>
'clear_room_history',
314 'LBL_CLEAR_ROOM_HISTORY_QUESTION' =>
'clear_room_history_question',
315 'LBL_END_WHISPER' =>
'end_whisper',
316 'LBL_SHOW_SETTINGS_JS' =>
'show_settings',
317 'LBL_HIDE_SETTINGS' =>
'hide_settings',
318 'LBL_TIMEFORMAT' =>
'lang_timeformat_no_sec',
319 'LBL_DATEFORMAT' =>
'lang_dateformat' 321 foreach($js_translations as $placeholder => $lng_variable)
323 $roomTpl->
setVariable($placeholder, json_encode($lng->txt($lng_variable)));
326 $roomTpl->
setVariable(
'LBL_CREATE_PRIVATE_ROOM', $lng->txt(
'chat_create_private_room_button'));
327 $roomTpl->
setVariable(
'LBL_CREATE_PRIVATE_ROOM_TEXT', $lng->txt(
'create_private_room_text'));
328 $roomTpl->
setVariable(
'LBL_LAYOUT', $lng->txt(
'layout'));
329 $roomTpl->
setVariable(
'LBL_SHOW_SETTINGS', $lng->txt(
'show_settings'));
330 $roomTpl->
setVariable(
'LBL_USER_IN_ROOM', $lng->txt(
'user_in_room'));
331 $roomTpl->
setVariable(
'LBL_USER_IN_ILIAS', $lng->txt(
'user_in_ilias'));
337 protected function renderRightUsersBlock(
ilTemplate $roomTpl)
344 $roomTpl->
setVariable(
'LBL_NO_FURTHER_USERS', $lng->txt(
'no_further_users'));
350 protected function renderSendMessageBox(
ilTemplate $roomTpl)
357 $roomTpl->
setVariable(
'LBL_MESSAGE', $lng->txt(
'chat_message'));
358 $roomTpl->
setVariable(
'LBL_TOALL', $lng->txt(
'chat_message_to_all'));
359 $roomTpl->
setVariable(
'LBL_OPTIONS', $lng->txt(
'chat_message_options'));
360 $roomTpl->
setVariable(
'LBL_DISPLAY', $lng->txt(
'chat_message_display'));
361 $roomTpl->
setVariable(
'LBL_SEND', $lng->txt(
'send'));
379 require_once
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
383 $selectionForm = $formFactory->getUserChatNameSelectionForm($name_options);
385 $ilCtrl->saveParameter($this->gui,
'sub');
387 $selectionForm->addCommandButton(
'view-joinWithCustomName', $lng->txt(
'enter'));
388 $selectionForm->setFormAction(
389 $ilCtrl->getFormAction($this->gui,
'view-joinWithCustomName')
392 $tpl->setVariable(
'ADM_CONTENT', $selectionForm->getHtml());
398 private function setupTemplate()
405 $tpl->addJavaScript(
'Modules/Chatroom/js/colorpicker/jquery.colorPicker.js');
406 $tpl->addJavaScript(
'Modules/Chatroom/js/chat.js');
407 $tpl->addJavaScript(
'Modules/Chatroom/js/iliaschat.jquery.js');
408 $tpl->addJavaScript(
'Services/jQuery/js/jquery.outside.events.min.js');
409 $tpl->addJavaScript(
'Modules/Chatroom/js/json2.js');
411 $tpl->addJavaScript(
'./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js');
413 $tpl->addCSS(
'Modules/Chatroom/js/colorpicker/colorPicker.css');
414 $tpl->addCSS(
'Modules/Chatroom/templates/default/style.css');
423 public function joinWithCustomName()
431 $this->gui->switchToVisibleMode();
432 $this->setupTemplate();
438 if(
$_REQUEST[
'custom_username_radio'] ==
'custom_username')
440 $username =
$_REQUEST[
'custom_username_text'];
442 elseif(method_exists($chat_user,
'build' .
$_REQUEST[
'custom_username_radio']))
444 $username = $chat_user->{
'build' .
$_REQUEST[
'custom_username_radio']}();
451 if(!
$failure && trim($username) !=
'')
454 $this->showRoom($room, $chat_user);
459 $this->showNameSelection($chat_user);
478 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
482 $this->gui->switchToVisibleMode();
483 $this->setupTemplate();
485 $chatSettings =
new ilSetting(
'chatroom');
486 if(!$chatSettings->get(
'chat_enabled'))
488 $ilCtrl->redirect($this->gui,
'settings-general');
494 if(!$room->getSetting(
'allow_anonymous') && $ilUser->isAnonymous())
496 $this->
cancelJoin($lng->txt(
'anonymous_not_allowed'));
502 if($room->getSetting(
'allow_custom_usernames'))
504 if($room->isSubscribed($chat_user->
getUserId()))
507 $this->showRoom($room, $chat_user);
511 $this->showNameSelection($chat_user);
517 $this->showRoom($room, $chat_user);
524 public function invitePD()
532 $chatSettings =
new ilSetting(
'chatroom');
533 if(!$chatSettings->get(
'chat_enabled'))
535 $ilCtrl->redirect($this->gui,
'settings-general');
541 $connector = $this->gui->getConnector();
542 $title = $room->getUniquePrivateRoomTitle($chat_user->getUsername());
543 $response = $connector->createPrivateRoom($room, $title, $chat_user);
544 $connector->inviteToPrivateRoom($room, $response->id, $ilUser, $user_id);
545 $room->sendInvitationNotification($this->gui, $chat_user, $user_id, $response->id);
549 $_SESSION[
'show_invitation_message'] = $user_id;
551 $ilCtrl->setParameter($this->gui,
'sub', $response->id);
552 $ilCtrl->redirect($this->gui,
'view');
561 private function renderFontSettings(
ilTemplate $roomTpl, array $defaultSettings)
569 $font_family = array(
570 'sans' =>
'Sans Serif',
572 'monospace' =>
'Monospace',
576 'italic' => $lng->txt(
'italic'),
577 'bold' => $lng->txt(
'bold'),
578 'normal' => $lng->txt(
'normal'),
579 'underlined' => $lng->txt(
'underlined'),
583 'small' => $lng->txt(
'small'),
584 'normal' => $lng->txt(
'normal'),
585 'large' => $lng->txt(
'large')
588 $default_font_color =
'#000000';
590 $default_font_family = (
591 isset($defaultSettings[
'font_family']) &&
592 isset($font_family[$defaultSettings[
'font_family']]) ?
593 $defaultSettings[
'font_family'] :
'sans' 596 $default_font_style = (
597 isset($defaultSettings[
'font_style']) &&
598 isset($font_family[$defaultSettings[
'font_style']]) ?
599 $defaultSettings[
'font_style'] :
'normal' 602 $default_font_size = (
603 isset($defaultSettings[
'font_size']) &&
604 isset($font_family[$defaultSettings[
'font_size']]) ?
605 $defaultSettings[
'font_size'] :
'normal' 608 $roomTpl->
setVariable(
'VAL_FONTCOLOR', $default_font_color);
610 foreach($font_family as $font => $label)
616 'SELECTED_FONTFAMILY', $font == $default_font_family ?
617 'selected="selected"' :
'' 622 foreach($font_style as $font => $label)
628 'SELECTED_FONTSTYLE', $font == $default_font_style ?
629 'selected="selected"' :
'' 634 foreach($font_size as $font => $label)
641 $font == $default_font_size ?
'selected="selected"' :
'' 646 $roomTpl->
setVariable(
'LBL_FONTCOLOR', $lng->txt(
'fontcolor'));
647 $roomTpl->
setVariable(
'LBL_FONTFAMILY', $lng->txt(
'fontfamily'));
648 $roomTpl->
setVariable(
'LBL_FONTSTYLE', $lng->txt(
'fontstyle'));
649 $roomTpl->
setVariable(
'LBL_FONTSIZE', $lng->txt(
'fontsize'));
651 $logoutLink = $ilCtrl->getLinkTarget($this->gui,
'view-logout');
664 require_once
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
666 $file_upload = $formFactory->getFileUploadForm();
668 $roomTpl->
setVariable(
'FILE_UPLOAD', $file_upload->getHTML());
674 public function logout()
685 $pid = $tree->getParentId($this->gui->getRefId());
686 $ilCtrl->setParameterByClass(
'ilrepositorygui',
'ref_id', $pid);
687 $ilCtrl->redirectByClass(
'ilrepositorygui',
'');
693 public function lostConnection()
702 $ilCtrl->redirectByClass(
'ilinfoscreengui',
'info');
renderFileUploadForm(ilTemplate $roomTpl)
Prepares Fileupload form and displays it.
getUserId()
Returns Ilias User ID.
getActivePrivateRooms($userid)
setUsername($username)
Sets and stores given username in SESSION.
getRoomId()
Returns roomID from $this->roomId.
static _getSmilies()
Fetches smilies from database.
Class ilChatroomViewTask.
isUserBanned($user_id)
Returns true if there's an entry in banTable matching roomId and given $user_id.
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.
executeDefault($requestedMethod)
setVariable($variable, $value='')
Sets a variable value.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
addHistoryEntry($message, $recipient=null, $publicMessage=true)
Inserts entry into historyTable.
special template class to simplify handling of ITX/PEAR
getConnectedUsers()
Returns an array of connected users.
subscribeUserToPrivateRoom($room_id, $user_id)
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.
cancelJoin($message)
Calls ilUtil::sendFailure method using given $message as parameter.
getChatNameSuggestions()
Returns an array of chat-name suggestions.
static getInstance()
Get instance.
const PANEL_STYLE_SECONDARY
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
getUsername()
Returns username from Object or SESSION.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
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)
__construct(ilChatroomObjectGUI $gui)