diff --git a/app/Resources/public/css/chat.css b/app/Resources/public/css/chat.css
index 6f9d2a9e1d..8578b287e3 100644
--- a/app/Resources/public/css/chat.css
+++ b/app/Resources/public/css/chat.css
@@ -1,13 +1,5 @@
-body{
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
- font-size: 13px;
- line-height: 18px;
- color: #333333;
- margin: 0;
- padding: 0;
-}
.page-chat{
- padding: 10px;
+ padding: 10px 0;
background:#ffffff;
}
.message-form-chat .nav{
@@ -16,48 +8,7 @@ body{
.message-form-chat .nav-tabs .active a{
background-color: #f6f6f6;
}
-#clear-chat{
- width:140px;
- padding: 13px;
- font-size: 14px;
- float:right;
-}
-#clear-chat img{
- width: 20px;
- float: left;
- margin-right: 5px;
-}
-#clear-chat a{
- text-decoration: none;
-}
-#clear-chat a:hover{
- opacity: 0.7;
-}
-#content-chat{
- background:#ffffff;
- padding: 30px;
- -webkit-border-radius: 10px;
- -moz-border-radius: 10px;
- border-radius: 10px;
-}
-
-textarea {
- width: 52%;
- padding: 3%;
- height: 100px;
- float: left;
- border: 0;
- background-color: #ffffff;
-
- font-family: Helvetica, arial, sans-serif;
- -webkit-border-radius: 10px;
- -moz-border-radius: 10px;
- border-radius: 10px;
- border: 1px solid #EEEEEE;
- color: #666;
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35) inset;
-}
.message-student .chat-image, .message-teacher .chat-image{
width: 80px;
height: auto;
@@ -85,7 +36,7 @@ textarea {
font-size: 13px;
padding: 15px;
vertical-align: top;
- width: 310px;
+ width: calc(100% - 100px);
}
.message-teacher .icon-message{
display: inline-block;
@@ -121,7 +72,7 @@ textarea {
font-size: 13px;
padding: 15px;
vertical-align: top;
- width: 360px;
+ width: calc(100% - 100px);
}
.message-teacher .message-date{
color: #666;
@@ -138,121 +89,30 @@ textarea {
text-align: right;
margin-top: 10px;
}
-.user-online .profile{
- list-style: none;
- padding: 0;
- margin:0;
-}
-.chat-message-block-name {
- font-style: italic;
- color: #666;
-}
-.user-online .profile li{
- margin-bottom: 5px;
-}
-.user-online .profile li a{
- color: #0088AA;
- text-decoration: none;
-}
-.user-online .title{
- background: url(chat.png) no-repeat 0 center;
- color: #0088AA;
- padding-top: 5px;
- padding-left: 30px;
- font-weight: bold;
- font-size: 16px;
- margin-bottom: 15px;
- width: 90%;
-}
-.delete-chat{
- background: #F8F8F8;
- padding-bottom: 15px;
-}
-.list-group {
- margin-bottom: 20px;
- padding-left: 0;
-}
-.list-group-item {
- position: relative;
- display: block;
- padding-top: 5px;
- padding-bottom: 10px;
- padding-left: 10px;
- padding-right: 10px;
- margin-bottom: -1px;
- background-color: #EEEEEE;
- border: 1px solid #E2E2E2;
- -webkit-border-radius: 10px;
+
+.chat-user {
+ background-color: #EEEEEE;
+ border: 1px solid #E2E2E2;
+ -webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
color: #666;
+ margin-bottom: -1px;
+ padding: 10px;
}
-.user-connected{
- border-right: 1px dashed #cccccc;
- margin-right: 5px;
-}
-li.list-group-item:hover, li.list-group-item:focus {
- text-decoration: none;
- background-color: #E2E2E2;
- cursor: pointer;
- border: 1px solid #EEEEEE;
-}
-li.list-group-item:hover a{
- color: #000;
-}
-.user-image-chat{
- width: 40px;
- height: auto;
- max-height: 40px;
- display: inline-block;
- vertical-align: top;
- -webkit-border-radius: 10px;
+.chat-user .user-image-chat {
+ -webkit-border-radius: 10px;
-moz-border-radius: 10px;
+ border: 2px solid #FFF;
border-radius: 10px;
- border:2px solid #ffffff;
+ display: inline-block;
+ height: auto;
+ margin-right: 10px;
+ max-height: 40px;
float: left;
- margin-right: 5px;
-}
-.noSelect {
- user-select: none;
- -o-user-select: none;
- -moz-user-select: none;
- -khtml-user-select: none;
- -webkit-user-select: none;
-}
-.btn-send {
- background: #87e0fd; /* Old browsers */
- background: -moz-linear-gradient(top, #87e0fd 0%, #53cbf1 40%, #05abe0 100%); /* FF3.6+ */
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#87e0fd), color-stop(40%,#53cbf1), color-stop(100%,#05abe0)); /* Chrome,Safari4+ */
- background: -webkit-linear-gradient(top, #87e0fd 0%,#53cbf1 40%,#05abe0 100%); /* Chrome10+,Safari5.1+ */
- background: -o-linear-gradient(top, #87e0fd 0%,#53cbf1 40%,#05abe0 100%); /* Opera 11.10+ */
- background: -ms-linear-gradient(top, #87e0fd 0%,#53cbf1 40%,#05abe0 100%); /* IE10+ */
- background: linear-gradient(to bottom, #87e0fd 0%,#53cbf1 40%,#05abe0 100%); /* W3C */
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#87e0fd', endColorstr='#05abe0',GradientType=0 ); /* IE6-9 */
- -webkit-border-radius: 15px;
- -moz-border-radius: 15px;
- border-radius: 15px;
- border:1px solid #53cbf1;
- display:inline-block;
- color:#ffffff;
- font-family:Arial;
- font-size:22px;
- font-weight:bold;
- font-style:normal;
- height:80px;
- line-height:80px;
- width:131px;
- text-decoration:none;
- text-align:center;
- cursor: pointer;
-}
-.btn-send:hover {
- opacity: 0.8;
-}
-.btn-send:active {
- position:relative;
- top:1px;
+ width: 40px;
}
+
.emoticons-chat img{
width: 24px;
border: none;
@@ -267,21 +127,17 @@ li.list-group-item:hover a{
}
.emoji-menu {
- margin-left: 0px;
- width:468px;
- left: 11px !important;
+ margin-left: -234px;
+ margin-top: -224px;
+ width: 468px;
}
.emoji-wysiwyg-editor-preview,
.emoji-wysiwyg-editor {
- width: 454px;
padding: 3%;
height: 50px;
- float: left;
border: 0;
background-color: #ffffff;
-
- font-family: Helvetica, arial, sans-serif;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
@@ -289,3 +145,19 @@ li.list-group-item:hover a{
color: #666;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35) inset;
}
+
+#chat-tabs .tab-content{
+ margin-top: 15px;
+}
+
+.chat-history {
+ height: 400px;
+ overflow: auto;
+}
+
+#chat-users {
+ margin-left: 0;
+}
+#chat-users div.chat-user > div {
+ padding: 5px;
+}
diff --git a/index.php b/index.php
index e1424d20cd..bb3235d0c9 100755
--- a/index.php
+++ b/index.php
@@ -14,7 +14,6 @@ define('CHAMILO_LOAD_WYSIWYG', false);
$cidReset = true;
require_once 'main/inc/global.inc.php';
-require_once 'main/chat/chat_functions.lib.php';
//require_once 'main/auth/external_login/facebook.inc.php';
// The section (for the tabs).
diff --git a/main/chat/chat.php b/main/chat/chat.php
index eeed6df290..d8257d9c09 100755
--- a/main/chat/chat.php
+++ b/main/chat/chat.php
@@ -1,92 +1,58 @@
-
-
-
-
-
-'.get_lang('Chat').' - '.$mycourseid.' - '.api_get_setting('siteName').'';
+$externalJS = [
+ 'highlight/highlight.pack.js',
+ 'jquery-textcomplete/jquery.textcomplete.js',
+ 'emojione/js/emojione.min.js',
+ 'jquery-emojiarea/jquery.emojiarea.js'
+];
-$groupId = api_get_group_id();
-
-// If it is a group chat then the breadcrumbs.
-if (!empty($groupId)) {
- $group_properties = GroupManager :: get_group_properties($groupId);
- $interbreadcrumb[] = array(
- 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
- 'name' => get_lang('Groups')
- );
- $interbreadcrumb[] = array(
- 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
- 'name' => get_lang('GroupSpace').' '.$group_properties['name']
- );
- $noPHP_SELF = true;
- $shortBanner = false;
- $add_group_to_title = ' ('.$group_properties['name'].')';
- $groupfilter = 'group_id="'.$groupId.'"';
-} else {
- $groupfilter = 'group_id=0';
-}
-
-if (empty($open_chat_window)) {
- Display::display_header($tool_name, 'Chat');
+foreach ($externalJS as $js) {
+ $htmlHeadXtra[] = api_get_js($js);
}
-$url = api_get_path(WEB_CODE_PATH).'chat/';
-$params = api_get_cidreq();
+$iconList = [];
-echo '';
-echo '';
-echo '';
-echo '';
-echo '';
-echo '
';
+foreach (Emojione\Emojione::$shortcode_replace as $key => $icon) {
+ if (!in_array($key, CourseChatUtils::getEmojisToInclude())) {
+ continue;
+ }
-if (empty($open_chat_window)) {
- Display::display_footer();
+ $iconList[$key] = strtoupper($icon) . '.png';
}
-echo '';
+$view = new Template(get_lang('Chat'), false, false, false, true, false);
+$view->assign('icons', $iconList);
+$view->assign('emoji_strategy', CourseChatUtils::getEmojiStrategry());
+$view->assign('emoji_smile', \Emojione\Emojione::toImage(':smile:'));
+
+$template = $view->get_template('chat/chat.tpl');
+$content = $view->fetch($template);
+
+$view->assign('content', $content);
+$view->display_one_col_template();
diff --git a/main/chat/chat_chat.php b/main/chat/chat_chat.php
deleted file mode 100755
index d0bef29526..0000000000
--- a/main/chat/chat_chat.php
+++ /dev/null
@@ -1,217 +0,0 @@
-'.$content[0];
- }
- if (isset($_GET['origin']) && $_GET['origin'] == 'whoisonlinejoin') {
- //the joiner (we have to delete the chat request to him when he joins the chat)
- $track_user_table = Database::get_main_table(TABLE_MAIN_USER);
- $sql = "UPDATE $track_user_table SET
- chatcall_user_id = '',
- chatcall_date = '',
- chatcall_text=''
- WHERE (user_id = ".$userId.")";
- $result = Database::query($sql);
- }
-
- echo '';
- echo '
';
- if ($isMaster || $is_courseCoach) {
- $rand = mt_rand(1, 1000);
- echo '
';
- }
-} else {
- echo '
';
- require 'header_frame.inc.php';
- $message = get_lang('CloseOtherSession');
- Display :: display_error_message($message);
-}
-require 'footer_frame.inc.php';
diff --git a/main/chat/chat_functions.lib.php b/main/chat/chat_functions.lib.php
deleted file mode 100755
index 2a4054830a..0000000000
--- a/main/chat/chat_functions.lib.php
+++ /dev/null
@@ -1,242 +0,0 @@
- 0) {
- foreach ($list_info_user_in_chat as $list_info_user) {
- $date_db_date = date('Y-m-d', api_strtotime($list_info_user['last_connection'], 'UTC'));
- $date_db_h = date('H', api_strtotime($list_info_user['last_connection'], 'UTC'));
- $date_db_m = date('i', api_strtotime($list_info_user['last_connection'], 'UTC'));
- $date_db_s = date('s', api_strtotime($list_info_user['last_connection'], 'UTC'));
- $date_count_time_seconds = $date_db_h * 3600 + $date_db_m * 60 + $date_db_s;
- if ($cd_date == $date_db_date) {
- if (($cd_count_time_seconds - $date_count_time_seconds) > 5) {
- $tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
- $sql = 'DELETE FROM '.$tbl_chat_connected.'
- WHERE
- c_id = '.$course_id.' AND
- user_id = '.$list_info_user['user_id'].' AND
- to_group_id = '.$groupId.'
- ';
- Database::query($sql);
- }
- }
- }
- }
-}
-
-/**
- * @return array user list in chat
- */
-function users_list_in_chat()
-{
- $list_users_in_chat = array();
- $tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
- $course_id = api_get_course_int_id();
-
- $session_id = api_get_session_id();
- $group_id = api_get_group_id();
-
- if (!empty($group_id)) {
- $extra_condition = " WHERE to_group_id = '$group_id'";
- } else{
- $extra_condition = api_get_session_condition($session_id, false);
- }
- $extra_condition.= " AND c_id = $course_id ";
- $sql = 'SELECT user_id, last_connection FROM '.$tbl_chat_connected.$extra_condition;
- $result = Database::query($sql);
- while ($row = Database::fetch_array($result, 'ASSOC')) {
- $list_users_in_chat[] = $row;
- }
-
- return $list_users_in_chat;
-}
-
-/**
- * @param string $message
- * @param array $_course
- * @param int $group_id
- * @param int $session_id
- * @param bool $preview
- */
-function saveMessage($message, $userId, $_course, $session_id, $group_id, $preview = true)
-{
- $userInfo = api_get_user_info($userId);
- $fullName = $userInfo['complete_name'];
- $isMaster = (bool)api_is_course_admin();
-
- $document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
- if (!empty($group_id)) {
- $group_info = GroupManager :: get_group_properties($group_id);
- $basepath_chat = $group_info['directory'].'/chat_files';
- } else {
- $basepath_chat = '/chat_files';
- }
- $chat_path = $document_path.$basepath_chat.'/';
-
- if (!is_dir($chat_path)) {
- if (is_file($chat_path)) {
- @unlink($chat_path);
- }
- }
-
- $date_now = date('Y-m-d');
- $message = trim($message);
- $timeNow = date('d/m/y H:i:s');
-
- if (!empty($group_id)) {
- $basename_chat = 'messages-'.$date_now.'_gid-'.$group_id;
- } elseif (!empty($session_id)) {
- $basename_chat = 'messages-'.$date_now.'_sid-'.$session_id;
- } else {
- $basename_chat = 'messages-'.$date_now;
- }
-
- if (!api_is_anonymous()) {
- if (!empty($message)) {
- Emojione\Emojione::$imagePathPNG = api_get_path(WEB_LIBRARY_PATH).'javascript/emojione/png/';
- Emojione\Emojione::$ascii = true;
-
- // Parsing emojis
- $message = Emojione\Emojione::toImage($message);
- // Parsing text to understand markdown (code highlight)
- $message = MarkdownExtra::defaultTransform($message);
- // Security XSS
- $message = Security::remove_XSS($message);
-
- if ($preview == true) {
- return $message;
- }
-
- if (!file_exists($chat_path.$basename_chat.'.log.html')) {
- $doc_id = add_document(
- $_course,
- $basepath_chat . '/' . $basename_chat . '.log.html',
- 'file',
- 0,
- $basename_chat . '.log.html'
- );
- api_item_property_update(
- $_course,
- TOOL_DOCUMENT,
- $doc_id,
- 'DocumentAdded',
- $userId,
- $group_id,
- null,
- null,
- null,
- $session_id
- );
- api_item_property_update(
- $_course,
- TOOL_DOCUMENT,
- $doc_id,
- 'invisible',
- $userId,
- $group_id,
- null,
- null,
- null,
- $session_id
- );
- item_property_update_on_folder(
- $_course,
- $basepath_chat,
- $userId
- );
- } else {
- $doc_id = DocumentManager::get_document_id(
- $_course,
- $basepath_chat.'/'.$basename_chat.'.log.html'
- );
- }
-
- $fp = fopen($chat_path.$basename_chat.'.log.html', 'a');
- $userPhoto = UserManager::getUserPicture($userId, USER_IMAGE_SIZE_MEDIUM);
- $filePhoto = '
';
- if ($isMaster) {
- fputs($fp, ''.$fullName.'
'.$message.'
'.$timeNow.'
'.$filePhoto.'
'."\n");
- } else {
- fputs($fp, ''.$filePhoto.'
'.$fullName.'
'.$message.'
'.$timeNow.'
'."\n");
- }
- fclose($fp);
-
- $chat_size = filesize($chat_path.$basename_chat.'.log.html');
-
- update_existing_document($_course, $doc_id, $chat_size);
- item_property_update_on_folder($_course, $basepath_chat, $userId);
- }
- }
-}
diff --git a/main/chat/chat_hidden.php b/main/chat/chat_hidden.php
deleted file mode 100755
index 98c8397936..0000000000
--- a/main/chat/chat_hidden.php
+++ /dev/null
@@ -1,130 +0,0 @@
-'".date('Y-m-d H:i:s',time()-60*5)."' $extra_condition";
-$result = Database::query($query);
-
-$connected_old = isset($_POST['connected_old']) ? intval($_POST['connected_old']) : null;
-list($connected_new) = Database::fetch_row($result);
-
-/*disconnected user of chat*/
-disconnect_user_of_chat();
-require 'header_frame.inc.php';
-?>
-
- alert('".get_lang('ChatDenied')."'); ";
- $sql = "update $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='' WHERE (user_id = $talk_to)";
- $result = Database::query($sql);
- }
-}
-require 'footer_frame.inc.php';
diff --git a/main/chat/chat_message.php b/main/chat/chat_message.php
deleted file mode 100755
index c78356aefc..0000000000
--- a/main/chat/chat_message.php
+++ /dev/null
@@ -1,128 +0,0 @@
-
-
- close_chat_window(); ';
-} else {
- api_protect_course_script();
-}
-
-if (empty($course) || empty($userId)) {
- exit;
-}
-
-/* Constants and variables */
-$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
-$sent = isset($_REQUEST['sent']) ? $_REQUEST['sent'] : null;
-
-require 'header_frame.inc.php';
-$chat_size = 0;
-
-if ($sent) {
- saveMessage(
- $_POST['message'],
- $userId,
- $_course,
- $session_id,
- $group_id,
- false
- );
-}
-?>
-
-".COURSE_RELATION_TYPE_RRHH." AND
- t3.c_id = '".$courseInfo['real_id']."' AND
- t2.last_connection>'".$date_inter."' $extra_condition
- ORDER BY username";
-
- $result = Database::query($sql);
- $users = Database::store_result($result);
- } else {
- $session_condition = api_get_session_condition($session_id, true, false, 't3.session_id');
- // select learners
- $query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri,email
- FROM $tbl_user t1, $tbl_chat_connected t2, $tbl_session_course_user t3
- WHERE
- t2.c_id = $course_id AND
- t1.user_id=t2.user_id AND t3.user_id=t2.user_id AND
- t3.session_id = '".$session_id."' AND
- t3.c_id = '".$courseInfo['real_id']."' AND
- t2.last_connection>'".$date_inter."' $session_condition
- ORDER BY username";
- $result = Database::query($query);
- while ($learner = Database::fetch_array($result)) {
- $users[$learner['user_id']] = $learner;
- }
-
- // select session coach
- $query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri,email
- FROM $tbl_user t1,$tbl_chat_connected t2,$tbl_session t3
- WHERE
- t2.c_id = $course_id AND
- t1.user_id=t2.user_id AND
- t3.id_coach=t2.user_id AND
- t3.id = '".$session_id."' AND
- t2.last_connection > '".$date_inter."'
- $extra_condition
- ORDER BY username";
- $result = Database::query($query);
- if ($coach = Database::fetch_array($result)) {
- $users[$coach['user_id']] = $coach;
- }
-
- // select session course coach
- $query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri,email
- FROM $tbl_user t1,$tbl_chat_connected t2,$tbl_session_course_user t3
- WHERE
- t2.c_id = $course_id AND
- t1.user_id=t2.user_id
- AND t3.user_id =t2.user_id AND t3.status=2
- AND t3.session_id = '".$session_id."'
- AND t3.c_id = '".$course_id."'
- AND t2.last_connection>'".$date_inter."' $extra_condition
- ORDER BY username";
-
- $result = Database::query($query);
- $course_coaches = array();
- while ($coaches = Database::fetch_array($result)) {
- $users[$coaches['user_id']] = $coaches;
- }
- }
- require 'header_frame.inc.php';
-
- ?>
-
-
-
-
-