Merge 1.11.x

ofaj
jmontoyaa 10 years ago
commit a4ee4d2f4f
  1. 36
      app/Migrations/Schema/V111/Version20160623143200.php
  2. 204
      app/Resources/public/css/chat.css
  3. 1
      index.php
  4. 15
      main/auth/courses.php
  5. 25
      main/auth/courses_controller.php
  6. 8
      main/auth/inscription.php
  7. 36
      main/auth/profile.php
  8. 5
      main/auth/shibboleth/app/model/scaffold/user.class.php
  9. 112
      main/chat/chat.php
  10. 217
      main/chat/chat_chat.php
  11. 242
      main/chat/chat_functions.lib.php
  12. 130
      main/chat/chat_hidden.php
  13. 128
      main/chat/chat_message.php
  14. 162
      main/chat/chat_whoisonline.php
  15. 17
      main/chat/footer_frame.inc.php
  16. 272
      main/chat/header_frame.inc.php
  17. 12
      main/inc/ajax/chat.ajax.php
  18. 76
      main/inc/ajax/course_chat.ajax.php
  19. 1843
      main/inc/lib/CourseChatUtils.php
  20. 14
      main/inc/lib/course_category.lib.php
  21. 9
      main/inc/lib/course_home.lib.php
  22. 2
      main/inc/lib/document.lib.php
  23. 125
      main/inc/lib/extra_field.lib.php
  24. 1968
      main/inc/lib/javascript/jquery-textcomplete/jquery.textcomplete.js
  25. 7
      main/inc/lib/javascript/jquery-textcomplete/jquery.textcomplete.min.js
  26. 2
      main/inc/lib/javascript/jquery-textcomplete/jquery.textcomplete.min.map
  27. 54
      main/inc/lib/online.inc.php
  28. 5
      main/inc/lib/social.lib.php
  29. 2
      main/inc/lib/userportal.lib.php
  30. 4
      main/install/data.sql
  31. 36
      main/lp/learnpath.class.php
  32. 91
      main/template/default/auth/courses_categories.php
  33. 342
      main/template/default/chat/chat.tpl
  34. 27
      main/wiki/wiki.inc.php
  35. 1
      robots.txt
  36. 4
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRecycler.php
  37. 91
      src/Chamilo/PageBundle/Entity/User.php
  38. 91
      src/Chamilo/UserBundle/Entity/User.php
  39. 44
      tests/main/chat/chat_functions.lib.test.php
  40. 30
      webchatdeny.php
  41. 15
      whoisonline.php

@ -0,0 +1,36 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160623143200
* Remove chatcall_date, chatcall_text, chatcall_user_id from User table
* @package Application\Migrations\Schema\V111
*/
class Version20160623143200 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$schema
->getTable('user')
->dropColumn('chatcall_user_id')
->dropColumn('chatcall_date')
->dropColumn('chatcall_text');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

@ -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;
}

@ -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).

@ -12,7 +12,6 @@ use \Chamilo\CoreBundle\Entity\SequenceResource;
// Delete the globals['_cid'], we don't need it here.
$cidReset = true; // Flag forcing the 'current course' reset
// including files
require_once '../inc/global.inc.php';
$ctok = Security::get_existing_token();
@ -31,7 +30,7 @@ if (api_get_setting('course_catalog_published') !== 'true') {
$user_can_view_page = false;
//For students
if (api_get_setting('allow_students_to_browse_courses') == 'false') {
if (api_get_setting('allow_students_to_browse_courses') === 'false') {
$user_can_view_page = false;
} else {
$user_can_view_page = true;
@ -62,7 +61,8 @@ if (isset($_GET['action']) && in_array($_GET['action'], $actions)) {
$action = Security::remove_XSS($_GET['action']);
}
$categoryCode = isset($_GET['category_code']) ? $_GET['category_code'] : 'ALL';
$categoryCode = isset($_GET['category_code']) && !empty($_GET['category_code']) ? $_GET['category_code'] : 'ALL';
$nameTools = CourseCategory::getCourseCatalogNameTools($action);
if (empty($nameTools)) {
$nameTools = get_lang('CourseManagement');
@ -73,7 +73,8 @@ if (empty($nameTools)) {
'name' => get_lang('CourseManagement'),
);
}
if ($action == 'createcoursecategory') {
if ($action === 'createcoursecategory') {
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses',
'name' => get_lang('SortMyCourses'),
@ -153,19 +154,19 @@ if (isset($_REQUEST['subscribe_course'])) {
$courses_controller->subscribe_user($_GET['subscribe_course'], $_GET['search_term'], $categoryCode);
}
}
// We are unsubscribing from a course (=Unsubscribe from course).
if (isset($_GET['unsubscribe'])) {
$search_term = isset($_GET['search_term']) ? $_GET['search_term'] : null;
if ($ctok == $_GET['sec_token']) {
$courses_controller->unsubscribe_user_from_course($_GET['unsubscribe'], $search_term, $categoryCode);
//$message = remove_user_from_course($_user['user_id'], $_POST['unsubscribe']);
}
}
// We are unsubscribing from a course (=Unsubscribe from course).
if (isset($_POST['unsubscribe'])) {
if ($ctok == $_POST['sec_token']) {
$courses_controller->unsubscribe_user_from_course($_POST['unsubscribe']);
//$message = remove_user_from_course($_user['user_id'], $_POST['unsubscribe']);
}
}
@ -215,7 +216,7 @@ switch ($action) {
if (!$user_can_view_page) {
api_not_allowed(true);
}
$courses_controller->courses_categories(
$action,
$categoryCode,

@ -90,14 +90,20 @@ class CoursesController
* @internal param \action $string
* @internal param \Category $string code (optional)
*/
public function courses_categories($action, $category_code = null, $message = '', $error = '', $content = null, $limit = array())
{
public function courses_categories(
$action,
$category_code = null,
$message = '',
$error = '',
$content = null,
$limit = array()
) {
$data = array();
$browse_course_categories = $this->model->browse_course_categories();
$data['countCoursesInCategory'] = $this->model->count_courses_in_category($category_code);
if ($action == 'display_random_courses') {
if ($action === 'display_random_courses') {
// Random value is used instead limit filter
$data['browse_courses_in_category'] = $this->model->browse_courses_in_category(null, 10);
$data['browse_courses_in_category'] = $this->model->browse_courses_in_category(null, 12);
$data['countCoursesInCategory'] = count($data['browse_courses_in_category']);
} else {
if (!isset($category_code)) {
@ -110,6 +116,7 @@ class CoursesController
$data['browse_course_categories'] = $browse_course_categories;
$data['code'] = Security::remove_XSS($category_code);
// getting all the courses to which the user is subscribed to
$curr_user_id = api_get_user_id();
$user_courses = $this->model->get_courses_of_user($curr_user_id);
@ -117,7 +124,7 @@ class CoursesController
// we need only the course codes as these will be used to match against the courses of the category
if ($user_courses != '') {
foreach($user_courses as $key => $value) {
foreach ($user_courses as $key => $value) {
$user_coursecodes[] = $value['code'];
}
}
@ -143,7 +150,7 @@ class CoursesController
}
// render to the view
$this->view->set_data($data);
$this->view->set_layout('catalog_layout');
$this->view->set_template('courses_categories');
@ -750,7 +757,7 @@ class CoursesController
'coach_access_start_date' => $session->getCoachAccessStartDate(),
'coach_access_end_date' => $session->getCoachAccessEndDate(),
]);
$imageField = $extraFieldValue->get_values_by_handler_and_field_variable($session->getId(), 'image');
$sessionCourseTags = [];
@ -799,7 +806,7 @@ class CoursesController
} else {
$catName = $cat->getName();
}
$coachId = $session->getGeneralCoach()->getId();
$coachName = $session->getGeneralCoach()->getCompleteName();
$actions = null;
@ -834,7 +841,7 @@ class CoursesController
'tags' => $sessionCourseTags,
'edit_actions' => $actions
);
$sessionsBlock = array_merge($sessionsBlock, $sequences);
$sessionsBlocks[] = $sessionsBlock;
}

@ -123,8 +123,12 @@ if ($userGeolocalization) {
return false;
});
$("#address").keypress(function (event) {
if (event.which == 13) {
$("#geolocalization").click();
return false;
}
});
});
function myLocation() {

@ -35,9 +35,7 @@ $userGeolocalization = api_get_setting('enable_profile_user_address_geolocalizat
$htmlHeadXtra[] = api_get_password_checker_js('#username', '#password1');
$htmlHeadXtra[] = '<link href="'. api_get_path(WEB_PATH) .'web/assets/cropper/dist/cropper.min.css" rel="stylesheet">';
$htmlHeadXtra[] = '<script src="'. api_get_path(WEB_PATH) .'web/assets/cropper/dist/cropper.min.js"></script>';
if ($userGeolocalization) {
$htmlHeadXtra[] = '<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=true" ></script>';
}
$htmlHeadXtra[] = '<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=true" ></script>';
$htmlHeadXtra[] = '<script>
$(document).ready(function() {
var $image = $("#previewImage");
@ -153,6 +151,7 @@ $user_data['api_key_generate'] = $value_array;
if ($userGeolocalization) {
$htmlHeadXtra[] = '<script>
$(document).ready(function() {
var address = "' . $user_data['address'] . '";
initializeGeo(address, false);
@ -166,6 +165,13 @@ if ($userGeolocalization) {
myLocation();
return false;
});
$("#address").keypress(function (event) {
if (event.which == 13) {
$("#geolocalization").click();
return false;
}
});
});
function myLocation() {
@ -805,7 +811,7 @@ if ($form->validate()) {
unset($user_data['api_key_generate']);
foreach ($user_data as $key => $value) {
if (substr($key, 0, 6) == 'extra_') { //an extra field
if (substr($key, 0, 6) === 'extra_') { //an extra field
continue;
} elseif (strpos($key, 'remove_extra_') !== false) {
} else {
@ -853,7 +859,7 @@ if ($form->validate()) {
UserManager::updatePassword(api_get_user_id(), $password);
}
if (api_get_setting('profile', 'officialcode') == 'true' &&
if (api_get_setting('profile', 'officialcode') === 'true' &&
isset($user_data['official_code'])
) {
$sql .= ", official_code = '".Database::escape_string($user_data['official_code'])."'";
@ -962,34 +968,34 @@ if ($form->validate()) {
// the header
$actions = null;
if (api_get_setting('allow_social_tool') != 'true') {
if (api_get_setting('extended_profile') == 'true') {
if (api_get_setting('allow_social_tool') !== 'true') {
if (api_get_setting('extended_profile') === 'true') {
$actions .= '<div class="actions">';
if (api_get_setting('allow_social_tool') == 'true' &&
api_get_setting('allow_message_tool') == 'true'
if (api_get_setting('allow_social_tool') === 'true' &&
api_get_setting('allow_message_tool') === 'true'
) {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
}
if (api_get_setting('allow_message_tool') == 'true') {
if (api_get_setting('allow_message_tool') === 'true') {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Messages')).'</a>';
}
$show = isset($_GET['show']) ? '&amp;show='.Security::remove_XSS($_GET['show']) : '';
if (isset($_GET['type']) && $_GET['type'] == 'extended') {
if (isset($_GET['type']) && $_GET['type'] === 'extended') {
$actions .= '<a href="profile.php?type=reduced'.$show.'">'.
Display::return_icon('edit.png', get_lang('EditNormalProfile'),'',16).'</a>';
Display::return_icon('edit.png', get_lang('EditNormalProfile'), '', 16).'</a>';
} else {
$actions .= '<a href="profile.php?type=extended'.$show.'">'.
Display::return_icon('edit.png', get_lang('EditExtendProfile'),'',16).'</a>';
Display::return_icon('edit.png', get_lang('EditExtendProfile'), '', 16).'</a>';
}
$actions .= '</div>';
}
}
$show_delete_account_button = api_get_setting('platform_unsubscribe_allowed') == 'true' ? true : false;
$show_delete_account_button = api_get_setting('platform_unsubscribe_allowed') === 'true' ? true : false;
if (api_get_setting('show_terms_if_profile_completed') === 'true') {
if (empty($user_data['profile_completed'])) {
@ -1019,7 +1025,7 @@ $tpl->assign('actions', $actions);
SocialManager::setSocialUserBlock($tpl, $user_id, 'messages');
if (api_get_setting('allow_social_tool') == 'true') {
if (api_get_setting('allow_social_tool') === 'true') {
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
$menu = SocialManager::show_social_menu(
'home',

@ -57,10 +57,7 @@ class _User
public $diplomas = null;
public $openarea = null;
public $teach = null;
public $productions = null;
public $chatcall_user_id = null;
public $chatcall_date = null;
public $chatcall_text = null;
public $productions = null;
public $language = null;
public $registration_date = null;
public $expiration_date = null;

@ -1,92 +1,58 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Chat tool
* @package chamilo.chat
*/
define('CHAMILO_LOAD_WYSIWYG', false);
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_CHAT;
$this_section = SECTION_COURSES;
$nameTools = get_lang('ToolChat');
$origin = isset($_GET["origin"]) ? Security::remove_XSS($_GET["origin"]) : null;
$target = isset($_GET["target"]) ? Security::remove_XSS($_GET["target"]) : null;
if ($origin != 'whoisonline') {
api_protect_course_script(true);
} else {
$origin = Session::read('origin');
$target = Session::read('target');
}
api_protect_course_group(GroupManager::GROUP_TOOL_CHAT, false);
api_protect_course_script(true);
/* TRACKING */
Event::event_access_tool(TOOL_CHAT);
header('Content-Type: text/html; charset=UTF-8');
/*
* Choose CSS style (platform's, user's, or course's)
*/
$my_style = api_get_visual_theme();
$mycourseid = api_get_course_id();
if (!empty($mycourseid) && $mycourseid != -1) {
$open_chat_window = api_get_course_setting('allow_open_chat_window');
// View
$externalCSS = [
'jquery-emojiarea/jquery.emojiarea.css',
'jquery-textcomplete/jquery.textcomplete.css',
'emojione/css/emojione.min.css',
'emojione/css/autocomplete.css',
'highlight/styles/github.css'
];
foreach ($externalCSS as $css) {
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_JS_PATH) . $css);
}
$courseCode = Security::remove_XSS($_GET['cidReq']);
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH) . 'chat.css');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH) . 'markdown.css');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH); ?>chat.css">
<?php
echo'<title>'.get_lang('Chat').' - '.$mycourseid.' - '.api_get_setting('siteName').'</title>';
$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 '<div class="page-chat">';
echo '<iframe src="'.$url.'chat_whoisonline.php?'.$params.'" name="chat_whoisonline" scrolling="no" style="height:550px; width:35%; border: 0px none; float:left"></iframe>';
echo '<iframe src="'.$url.'chat_chat.php?origin='.$origin.'&target='.$target.'&'.$params.'" name="chat_chat" id="chat_chat" scrolling="auto" height="380" style="width:65%; border: 0px none; float:right"></iframe>';
echo '<iframe src="'.$url.'chat_message.php?'.$params.'" name="chat_message" scrolling="no" height="182px" style="width:65%; border: 0px none; float:right"></iframe>';
echo '<iframe src="'.$url.'chat_hidden.php?'.$params.'" name="chat_hidden" height="0px" style="height:0px; border: 0px none"></iframe>';
echo '</div>';
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 '</html>';
$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();

@ -1,217 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Chat frame that shows the message list
*
* @author Olivier Brouckaert
* @package chamilo.chat
*/
define('FRAME', 'chat');
require_once '../inc/global.inc.php';
$course = $_GET['cidReq'];
$session_id = api_get_session_id();
$group_id = api_get_group_id();
$userId = api_get_user_id();
$_course = api_get_course_info();
$time = api_get_utc_datetime();
// if we have the session set up
if (!empty($course)) {
$reset = isset($_GET['reset']) ? (bool)$_GET['reset'] : null;
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$query = "SELECT username FROM $tbl_user WHERE user_id='".$userId."'";
$result = Database::query($query);
list($pseudo_user) = Database::fetch_row($result);
$isAllowed = !(empty($pseudo_user) || !$_cid);
$isMaster = (bool)api_is_course_admin();
$date_now = date('Y-m-d');
$basepath_chat = '';
$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.'/';
$TABLEITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = api_get_course_int_id();
if (!is_dir($chat_path)) {
if (is_file($chat_path)) {
@unlink($chat_path);
}
if (!api_is_anonymous()) {
@mkdir($chat_path, api_get_permissions_for_new_directories());
// Save chat files document for group into item property
if (!empty($group_id)) {
$doc_id = add_document($_course, $basepath_chat, 'folder', 0, 'chat_files');
api_item_property_update(
$_course,
TOOL_DOCUMENT,
$doc_id,
'FolderCreated',
null,
$group_id,
null,
null,
null
);
}
}
}
$filename_chat = '';
if (!empty($group_id)) {
$filename_chat = 'messages-'.$date_now.'_gid-'.$group_id.'.log.html';
} else if (!empty($session_id)) {
$filename_chat = 'messages-'.$date_now.'_sid-'.$session_id.'.log.html';
} else {
$filename_chat = 'messages-'.$date_now.'.log.html';
}
if (!file_exists($chat_path.$filename_chat)) {
@fclose(fopen($chat_path.$filename_chat, 'w'));
if (!api_is_anonymous()) {
$doc_id = add_document($_course, $basepath_chat.'/'.$filename_chat, 'file', 0, $filename_chat);
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);
}
}
$basename_chat = '';
if (!empty($group_id)) {
$basename_chat = 'messages-'.$date_now.'_gid-'.$group_id;
} else if (!empty($session_id)) {
$basename_chat = 'messages-'.$date_now.'_sid-'.$session_id;
} else {
$basename_chat = 'messages-'.$date_now;
}
if ($reset && $isMaster) {
$i = 1;
while (file_exists($chat_path.$basename_chat.'-'.$i.'.log.html')) {
$i++;
}
@rename($chat_path.$basename_chat.'.log.html', $chat_path.$basename_chat.'-'.$i.'.log.html');
@fclose(fopen($chat_path.$basename_chat.'.log.html', 'w'));
$doc_id = add_document($_course, $basepath_chat.'/'.$basename_chat.'-'.$i.'.log.html', 'file', filesize($chat_path.$basename_chat.'-'.$i.'.log.html'), $basename_chat.'-'.$i.'.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);
$doc_id = DocumentManager::get_document_id(
$_course,
$basepath_chat.'/'.$basename_chat.'.log.html'
);
update_existing_document($_course, $doc_id, 0);
}
$remove = 0;
$content = array();
if (file_exists($chat_path.$basename_chat.'.log.html')) {
$content = file($chat_path.$basename_chat.'.log.html');
$nbr_lines = sizeof($content);
$remove = $nbr_lines - 100;
}
if ($remove < 0) {
$remove = 0;
}
array_splice($content, 0, $remove);
require 'header_frame.inc.php';
if (isset($_GET['origin']) && $_GET['origin'] == 'whoisonline') {
//the caller
$content[0] = get_lang('CallSent').'<br />'.$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 '<div id="content-chat"';
foreach ($content as & $this_line) {
echo $this_line;
}
echo '</div>';
echo '<a name="bottom" style="text-decoration:none;">&nbsp;</a>';
if ($isMaster || $is_courseCoach) {
$rand = mt_rand(1, 1000);
echo '<div id="clear-chat">';
echo '<a class="btn btn-danger btn-small " href="'.api_get_self().'?rand='.$rand.'&reset=1&'.api_get_cidreq().'#bottom" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmReset'), ENT_QUOTES)).'\')) return false;">'.
get_lang('ClearList').
'</a>';
echo '</div>';
}
} else {
echo '</div>';
require 'header_frame.inc.php';
$message = get_lang('CloseOtherSession');
Display :: display_error_message($message);
}
require 'footer_frame.inc.php';

@ -1,242 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.chat
*/
use Michelf\MarkdownExtra;
/**
* @author isaac flores paz
* @param integer $user_id
*
* @return boolean
* @todo this function need more parameters seems not to be use anymore
* @deprecated fix this function or create another
*/
function user_connected_in_chat($user_id)
{
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
$user_id = intval($user_id);
$session_id = api_get_session_id();
$group_id = api_get_group_id();
$course_id = api_get_course_int_id();
if (!empty($group_id)) {
$extra_condition = " AND to_group_id = '$group_id'";
} else {
$extra_condition = api_get_session_condition($session_id);
}
$sql = 'SELECT COUNT(*) AS count
FROM '.$tbl_chat_connected .' c
WHERE
c_id = '.$course_id.' AND
user_id='.$user_id.$extra_condition;
$result = Database::query($sql);
$count = Database::fetch_array($result,'ASSOC');
return $count['count'] == 1;
}
/**
* @param integer
* @return void
*/
function exit_of_chat($user_id)
{
$user_id = intval($user_id);
$list_course = CourseManager::get_courses_list_by_user_id($user_id);
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
foreach ($list_course as $course) {
$response = user_connected_in_chat($user_id);
$sql = 'DELETE FROM '.$tbl_chat_connected.'
WHERE c_id = '.$course['real_id'].' AND user_id = '.$user_id;
Database::query($sql);
}
}
/**
* @return void
*/
function disconnect_user_of_chat()
{
$list_info_user_in_chat = users_list_in_chat();
$course_id = api_get_course_int_id();
$groupId = api_get_group_id();
$now = time();
$cd_date = date('Y-m-d', $now);
$cdate_h = date('H', $now);
$cdate_m = date('i', $now);
$cdate_s = date('s', $now);
$cd_count_time_seconds = $cdate_h*3600 + $cdate_m*60 + $cdate_s;
if (is_array($list_info_user_in_chat) && count($list_info_user_in_chat) > 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 = '<img class="chat-image" src="'.$userPhoto.'"/>';
if ($isMaster) {
fputs($fp, '<div class="message-teacher"><div class="content-message"><div class="chat-message-block-name">'.$fullName.'</div><div class="chat-message-block-content">'.$message.'</div><div class="message-date">'.$timeNow.'</div></div><div class="icon-message"></div>'.$filePhoto.'</div>'."\n");
} else {
fputs($fp, '<div class="message-student">'.$filePhoto.'<div class="icon-message"></div><div class="content-message"><div class="chat-message-block-name">'.$fullName.'</div><div class="chat-message-block-content">'.$message.'</div><div class="message-date">'.$timeNow.'</div></div></div>'."\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);
}
}
}

@ -1,130 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Hidden frame that refreshes the visible frames when a modification occurs
*
* @author Olivier Brouckaert
* @package chamilo.chat
*/
define('FRAME', 'hidden');
require_once '../inc/global.inc.php';
require_once 'chat_functions.lib.php';
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
$userId = api_get_user_id();
$course_id = api_get_course_int_id();
$query = "SELECT username FROM $tbl_user WHERE user_id='".$userId."'";
$result = Database::query($query);
list($pseudo_user) = Database::fetch_row($result);
$isAllowed = !(empty($pseudo_user) || !$_cid);
$isMaster = (bool)api_is_course_admin();
$date_now = date('Y-m-d');
$group_id = api_get_group_id();
$session_id = api_get_session_id();
$session_condition = api_get_session_condition($session_id);
$group_condition = " AND to_group_id = '$group_id'";
$extra_condition = '';
if (!empty($group_id)) {
$extra_condition = $group_condition;
} else {
$extra_condition = $session_condition;
}
$extra_condition.= " AND c_id = $course_id";
// get chat path
$chat_path = '';
$document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
if (!empty($group_id)) {
$group_info = GroupManager :: get_group_properties($group_id);
$chat_path = $document_path.$group_info['directory'].'/chat_files/';
} else {
$chat_path = $document_path.'/chat_files/';
}
// get chat file
$basename_chat = '';
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;
}
$chat_size_old = isset($_POST['chat_size_old']) ? intval($_POST['chat_size_old']) : null;
$file = $chat_path.$basename_chat.'.log.html';
$chat_size_new = 0;
if (file_exists($file)) {
$chat_size_new = filesize($file);
}
$sql = "SELECT user_id FROM $tbl_chat_connected
WHERE user_id='".$userId."' $extra_condition";
$result = Database::query($sql);
// The user_id exists so we must do an UPDATE and not a INSERT
$current_time = api_get_utc_datetime();
if (Database::num_rows($result) == 0) {
$query = "INSERT INTO $tbl_chat_connected(c_id, user_id, last_connection,session_id,to_group_id)
VALUES($course_id, '".$userId."','$current_time','$session_id','$group_id')";
Database::query($query);
$id = Database::insert_id();
if ($id) {
$sql = "UPDATE $tbl_chat_connected SET id = iid WHERE iid = $id";
Database::query($sql);
}
} else {
$query = "UPDATE $tbl_chat_connected SET
last_connection='".$current_time."'
WHERE c_id = $course_id AND user_id='".$userId."' AND session_id='$session_id' AND to_group_id='$group_id'";
Database::query($query);
}
$query = "SELECT COUNT(user_id) FROM $tbl_chat_connected
WHERE last_connection>'".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';
?>
<form name="formHidden" method="post" action="<?php echo api_get_self().'?'.api_get_cidreq(); ?>">
<input type="hidden" name="chat_size_old" value="<?php echo $chat_size_new; ?>">
<input type="hidden" name="connected_old" value="<?php echo $connected_new; ?>">
</form>
<?php
$origin = Session::read('origin');
$target = Session::read('target');
if ($origin == 'whoisonline') {
//check if our target has denied our request or not
$talk_to = (int) $target;
$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "select chatcall_text from $track_user_table where ( user_id = $talk_to )";
$result = Database::query($sql);
$row = Database::fetch_array($result);
if ($row['chatcall_text'] == 'DENIED') {
echo "<script language=\"javascript\" type=\"text/javascript\"> alert('".get_lang('ChatDenied')."'); </script>";
$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';

@ -1,128 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Allows to type the messages that will be displayed on chat_chat.php
*
* @author Olivier Brouckaert
* Modified by Alex Aragón (BeezNest)
* @package chamilo.chat
*/
define('FRAME', 'message');
require_once '../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'chat/chat_functions.lib.php';
$userId = api_get_user_id();
$userInfo = api_get_user_info();
$course = api_get_course_id();
$session_id = api_get_session_id();
$group_id = api_get_group_id();
$_course = api_get_course_info();
// Juan Carlos Raña inserted smileys and self-closing window.
?>
<script>
function close_chat_window() {
var chat_window = top.window.self;
chat_window.opener = top.window.self;
chat_window.top.close();
}
</script>
<?php
// Mode open in a new window: close the window when there isn't an user login
if (empty($userId)) {
echo '<script languaje="javascript" type="text/javascript"> close_chat_window(); </script>';
} 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
);
}
?>
<form
id="formMessage"
name="formMessage"
method="post"
action="<?php echo api_get_self().'?'.api_get_cidreq(); ?>" onsubmit="javascript: if(document.formMessage.message.value == '') { alert('<?php echo addslashes(api_htmlentities(get_lang('TypeMessage'), ENT_QUOTES)); ?>'); document.formMessage.message.focus(); return false; }"
autocomplete="off"
>
<input type="hidden" name="sent" value="1">
<div class="message-form-chat">
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active">
<a href="#tab1" data-toggle="tab">
<?php echo get_lang('Write'); ?>
</a>
</li>
<li>
<a href="#tab2" id="preview" data-toggle="tab">
<?php echo get_lang('Preview'); ?>
</a>
</li>
<li>
<a href="#tab3" id="emojis" data-toggle="tab">
<?php echo Emojione\Emojione::toImage(':smile:'); ?>
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td width="320" valign="middle">
<?php
$talkboxsize = (api_get_course_setting('allow_open_chat_window')) ? 'width: 350px; height: 80px' : 'width: 450px; height: 35px';
?>
<textarea id="message" class="message-text" name="message" style=" <?php echo $talkboxsize; ?>"></textarea>
</td>
</tr>
<tr>
<td>
<div class="btn-group">
<button id="send" type="submit" value="<?php echo get_lang('Send'); ?>" class="btn btn-primary">
<?php echo get_lang('Send'); ?>
</button>
</div>
</td>
</tr>
</table>
</div>
<div class="tab-pane" id="tab2">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td width="320" valign="middle">
<div id="html-preview" class="emoji-wysiwyg-editor-preview">
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</form>
<?php
require 'footer_frame.inc.php';

@ -1,162 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Shows the list of connected users
*
* @author Olivier Brouckaert
* @package chamilo.chat
*/
define('FRAME', 'online');
require_once '../inc/global.inc.php';
$course = api_get_course_id();
$courseInfo = api_get_course_info();
$group_id = api_get_group_id();
$session_id = api_get_session_id();
$user_id = api_get_user_id();
$group_condition = " AND to_group_id = '$group_id'";
$extra_condition = '';
if (!empty($group_id)) {
$extra_condition = $group_condition;
}
if (!empty($course)) {
$showPic = isset($_GET['showPic']) ? intval($_GET['showPic']) : null;
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
$query = "SELECT username FROM $tbl_user WHERE user_id='".$user_id."'";
$result = Database::query($query);
list($pseudo_user) = Database::fetch_array($result);
$isAllowed = !(empty($pseudo_user) || !$_cid);
$isMaster = api_is_course_admin();
$date_inter = api_get_utc_datetime(time() - 120);
$users = array();
$course_id = api_get_course_int_id();
if (empty($session_id)) {
$sql = "SELECT DISTINCT
t1.user_id,
username,
firstname,
lastname,
picture_uri,
email,
t3.status
FROM $tbl_user t1, $tbl_chat_connected t2, $tbl_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.relation_type<>".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';
?>
<div class="user-connected">
<div id="user-online-scroll" class="user-online">
<div class="title"><?php echo get_lang('Users'); ?> <?php echo get_lang('Connected'); ?></div>
<div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div></div></div></div>
<div class="scrollbar-inner viewport"><div id="hidden" class="overview">
<ul class="profile list-group">
<?php
foreach ($users as & $user) {
if (empty($session_id)) {
$status = $user['status'];
} else {
$status = CourseManager::is_course_teacher($user['user_id'], api_get_course_id()) ? 1 : 5;
}
$fileUrl = UserManager::getUserPicture($user['user_id'], USER_IMAGE_SIZE_MEDIUM);
$url_user_profile=api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user['user_id'].'&';
?>
<li class="list-group-item">
<img src="<?php echo $fileUrl;?>" border="0" width="50" alt="" class="user-image-chat" />
<div class="user-name">
<a href="<?php echo $url_user_profile; ?>" target="_blank">
<?php echo api_get_person_name($user['firstname'], $user['lastname']); ?>
</a>
<?php
if ($status == 1) {
echo Display::return_icon('teachers.gif', get_lang('Teacher'), array('height' => '18'));
} else {
echo Display::return_icon('students.gif', get_lang('Student'), array('height' => '18'));
}
?>
</div>
<div class="user-email"><?php echo $user['username']; ?></div>
</li>
<?php
}
unset($users);
?>
</ul>
</div></div></div></div>
<?php
}
require 'footer_frame.inc.php';

@ -1,17 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Footer of each frame of the Chat tool
*
* @author Olivier Brouckaert
* @package chamilo.chat
*/
?>
<audio id="audio">
<source src="<?php echo api_get_path(WEB_PATH);?>main/chat/sound/notification.wav" type="audio/wav"></source>
<source src="<?php echo api_get_path(WEB_PATH);?>main/chat/sound/notification.ogg" type="audio/ogg"></source>
<source src="<?php echo api_get_path(WEB_PATH);?>main/chat/sound/notification.mp3" type="audio/mpeg"></source>
</audio>
</body>
</html>

File diff suppressed because one or more lines are too long

@ -17,16 +17,8 @@ if (api_is_anonymous()) {
// Course Chat
if ($action == 'preview') {
require_once api_get_path(SYS_CODE_PATH).'chat/chat_functions.lib.php';
echo saveMessage(
$_REQUEST['message'],
api_get_user_id(),
api_get_course_info(),
api_get_session_id(),
api_get_group_id(),
true
);
echo CourseChatUtils::prepareMessage($_REQUEST['message']);
exit;
}
if (api_get_setting('allow_global_chat') == 'false') {

@ -0,0 +1,76 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls for course chat
*/
require_once '../global.inc.php';
if (!api_protect_course_script(false)) {
exit;
}
$courseId = api_get_course_int_id();
$userId = api_get_user_id();
$sessionId = api_get_session_id();
$groupId = api_get_group_id();
$json = ['status' => false];
$courseChatUtils = new CourseChatUtils($courseId, $userId, $sessionId, $groupId);
switch ($_REQUEST['action']) {
case 'track':
$courseChatUtils->keepUserAsConnected();
$courseChatUtils->disconnectInactiveUsers();
$friend = isset($_REQUEST['friend']) ? intval($_REQUEST['friend']) : 0;
$filePath = $courseChatUtils->getFileName(true, $friend);
$newFileSize = file_exists($filePath) ? filesize($filePath) : 0;
$oldFileSize = isset($_GET['size']) ? intval($_GET['size']) : -1;
$newUsersOnline = $courseChatUtils->countUsersOnline();
$oldUsersOnline = isset($_GET['users_online']) ? intval($_GET['users_online']) : 0;
$json = [
'status' => true,
'data' => [
'chatIsDenied' => $courseChatUtils->isChatDenied(),
'oldFileSize' => file_exists($filePath) ? filesize($filePath) : 0,
'history' => $newFileSize !== $oldFileSize ? $courseChatUtils->readMessages(false, $friend) : null,
'usersOnline' => $newUsersOnline,
'userList' => $newUsersOnline != $oldUsersOnline ? $courseChatUtils->listUsersOnline() : null,
'currentFriend' => $friend
]
];
break;
case 'preview':
$json = [
'status' => true,
'data' => [
'message' => CourseChatUtils::prepareMessage($_REQUEST['message'])
]
];
break;
case 'reset':
$friend = isset($_REQUEST['friend']) ? intval($_REQUEST['friend']) : 0;
$json = [
'status' => true,
'data' => $courseChatUtils->readMessages(true, $friend)
];
break;
case 'write':
$friend = isset($_REQUEST['friend']) ? intval($_REQUEST['friend']) : 0;
$writed = $courseChatUtils->saveMessage($_POST['message'], $friend);
$json = [
'status' => $writed,
'data' => [
'writed' => $writed
]
];
break;
}
header('Content-Type: application/json');
echo json_encode($json);

File diff suppressed because it is too large Load Diff

@ -577,7 +577,7 @@ class CourseCategory
* @param string $searchTerm
* @return int
*/
public static function countCoursesInCategory($category_code = "", $searchTerm = '')
public static function countCoursesInCategory($category_code = '', $searchTerm = '')
{
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$categoryCode = Database::escape_string($category_code);
@ -924,17 +924,13 @@ class CourseCategory
*/
public static function getLimitArray()
{
$pageCurrent = isset($_REQUEST['pageCurrent']) ?
intval($_GET['pageCurrent']) :
1;
$pageLength = isset($_REQUEST['pageLength']) ?
intval($_GET['pageLength']) :
10;
$pageCurrent = isset($_REQUEST['pageCurrent']) ? intval($_GET['pageCurrent']) : 1;
$pageLength = isset($_REQUEST['pageLength']) ? intval($_GET['pageLength']) : 12;
return array(
'start' => ($pageCurrent - 1) * $pageLength,
'current' => $pageCurrent,
'length' => $pageLength,
'length' => $pageLength
);
}
@ -948,7 +944,7 @@ class CourseCategory
$limitFilter = '';
if (!empty($limit) && is_array($limit)) {
$limitStart = isset($limit['start']) ? $limit['start'] : 0;
$limitLength = isset($limit['length']) ? $limit['length'] : 10;
$limitLength = isset($limit['length']) ? $limit['length'] : 12;
$limitFilter = 'LIMIT '.$limitStart.', '.$limitLength;
}

@ -1094,6 +1094,7 @@ class CourseHome
$navigation_items = array();
$course_id = api_get_course_int_id();
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
if (!empty($course_id)) {
@ -1126,7 +1127,7 @@ class CourseHome
$sql_result = Database::query($sql);
$course_setting_info = Database::fetch_array($sql_result);
$course_setting_visual_name = CourseHome::translate_tool_name($course_setting_info);
if (api_get_session_id() == 0) {
if ($sessionId == 0) {
// course settings item
$navigation_items['course_settings']['image'] = $course_setting_info['image'];
$navigation_items['course_settings']['link'] = api_get_path(WEB_CODE_PATH).'course_info/infocours.php';
@ -1144,7 +1145,7 @@ class CourseHome
$parameter_separator = '?';
}
//$navigation_items[$key]['link'] .= $parameter_separator.api_get_cidreq();
$navigation_items[$key]['link'] .= $parameter_separator.'cidReq='.api_get_course_id().'&gidReq=0&id_session='.api_get_session_id();
$navigation_items[$key]['link'] .= $parameter_separator.'cidReq='.api_get_course_id().'&gidReq=0&id_session='.$sessionId;
}
return $navigation_items;
@ -1211,9 +1212,9 @@ class CourseHome
$navigation_items = self::get_navigation_items(false);
$html = '';
if (!empty($navigation_items)) {
if ($orientation == SHORTCUTS_HORIZONTAL)
if ($orientation == SHORTCUTS_HORIZONTAL) {
$style_id = "toolshortcuts_horizontal";
else {
} else {
$style_id = "toolshortcuts_vertical";
}
$html .= '<div id="'.$style_id.'">';

@ -517,7 +517,7 @@ class DocumentManager
if (!empty($sessionId)) {
// Chat folder filter
if ($path == '/chat_files') {
$condition .= " AND (id_session = '$sessionId') ";
$condition .= " AND (docs.session_id = '$sessionId') ";
}
// share_folder filter
$condition .= " AND docs.path != '/shared_folder' ";

@ -1638,11 +1638,14 @@ EOF;
}
break;
case ExtraField::FIELD_TYPE_GEOLOCALIZATION:
$dataValue = isset($extraData['extra_'.$field_details['variable']])
? $extraData['extra_'.$field_details['variable']]
: '';
$form->addElement(
'text',
'extra_'.$field_details['variable'],
$field_details['display_text'],
array()
['id' => 'extra_'.$field_details['variable']]
);
$form->applyFilter('extra_'.$field_details['variable'], 'stripslashes');
$form->applyFilter('extra_'.$field_details['variable'], 'trim');
@ -1653,6 +1656,126 @@ EOF;
);
}
}
$form->addHtml(
'<script>
$(document).ready(function() {
var address = "' . $dataValue . '";
initializeGeo'.$field_details['variable'].'(address, false);
$("#geolocalization_extra_'.$field_details['variable'].'").on("click", function() {
var address = $("#extra_'.$field_details['variable'].'").val();
initializeGeo'.$field_details['variable'].'(address, false);
return false;
});
$("#myLocation_extra_'.$field_details['variable'].'").on("click", function() {
myLocation'.$field_details['variable'].'();
return false;
});
$("#extra_'.$field_details['variable'].'").keypress(function (event) {
if (event.which == 13) {
$("#geolocalization_extra_'.$field_details['variable'].'").click();
return false;
}
});
});
function myLocation'.$field_details['variable'].'() {
if (navigator.geolocation) {
var geoPosition = function(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
var latLng = new google.maps.LatLng(lat, lng);
initializeGeo'.$field_details['variable'].'(false, latLng)
};
var geoError = function(error) {
alert("Geocode ' . get_lang('Error') . ': " + error);
};
var geoOptions = {
enableHighAccuracy: true
};
navigator.geolocation.getCurrentPosition(geoPosition, geoError, geoOptions);
}
}
function initializeGeo'.$field_details['variable'].'(address, latLng) {
var geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 15,
center: latlng,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
},
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map_'.$field_details['variable'].' = new google.maps.Map(document.getElementById("map_extra_'.$field_details['variable'].'"), myOptions);
var parameter = address ? { "address": address } : latLng ? { "latLng": latLng } : false;
if (geocoder && parameter) {
geocoder.geocode(parameter, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
map_'.$field_details['variable'].'.setCenter(results[0].geometry.location);
if (!address) {
$("#extra_'.$field_details['variable'].'").val(results[0].formatted_address);
}
var infowindow = new google.maps.InfoWindow({
content: "<b>" + $("#extra_'.$field_details['variable'].'").val() + "</b>",
size: new google.maps.Size(150, 50)
});
var marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map_'.$field_details['variable'].',
title: $("#extra_'.$field_details['variable'].'").val()
});
google.maps.event.addListener(marker, "click", function() {
infowindow.open(map_'.$field_details['variable'].', marker);
});
} else {
alert("' . get_lang("NotFound") . '");
}
} else {
alert("Geocode ' . get_lang('Error') . ': " + status);
}
});
}
}
</script>
');
$form->addHtml('
<div class="form-group">
<label for="geolocalization_extra_'.$field_details['variable'].'" class="col-sm-2 control-label"></label>
<div class="col-sm-8">
<button class="null btn btn-default " id="geolocalization_extra_'.$field_details['variable'].'" name="geolocalization_extra_'.$field_details['variable'].'" type="submit"><em class="fa fa-map-marker"></em> '.get_lang('Geolocalization').'</button>
<button class="null btn btn-default " id="myLocation_extra_'.$field_details['variable'].'" name="myLocation_extra_'.$field_details['variable'].'" type="submit"><em class="fa fa-crosshairs"></em> '.get_lang('MyLocation').'</button>
</div>
</div>
');
$form->addHtml('
<div class="form-group">
<label for="map_extra_'.$field_details['variable'].'" class="col-sm-2 control-label">
'.$field_details['display_text'].' - '.get_lang('Map').'
</label>
<div class="col-sm-8">
<div name="map_extra_'.$field_details['variable'].'" id="map_extra_'.$field_details['variable'].'" style="width:100%; height:300px;">
</div>
</div>
</div>
');
break;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -149,8 +149,7 @@ function online_logout($user_id = null, $logout_redirect = false)
}
}
require_once api_get_path(SYS_PATH) . 'main/chat/chat_functions.lib.php';
exit_of_chat($user_id);
CourseChatUtils::exitChat($user_id);
session_regenerate_id();
Session::destroy();
if ($logout_redirect) {
@ -472,54 +471,3 @@ function GetFullUserName($uid) {
}
}
}
/**
* Gets a list of chat calls made by others to the current user (info kept in main.user table)
* @param none - taken from global space
* @return string An HTML-formatted message
*/
function chatcall() {
$_cid = api_get_course_id();
$_user = api_get_user_info();
if (!$_user['user_id']) {
return (false);
}
$userId = intval($_user['user_id']);
$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql="SELECT chatcall_user_id, chatcall_date FROM $track_user_table
WHERE ( id = $userId )";
$result=Database::query($sql);
$row=Database::fetch_array($result);
$login_date=$row['chatcall_date'];
$hour = substr($login_date,11,2);
$minute = substr($login_date,14,2);
$second = substr($login_date,17,2);
$month = substr($login_date,5,2);
$day = substr($login_date,8,2);
$year = substr($login_date,0,4);
$calltime = mktime($hour,$minute,$second,$month,$day,$year);
$time = api_get_utc_datetime();
$minute_passed=5; //within this limit, the chat call request is valid
$limittime = mktime(date("H"),date("i")-$minute_passed,date("s"),date("m"),date("d"),date("Y"));
if (($row['chatcall_user_id']) and ($calltime>$limittime)) {
$webpath=api_get_path(WEB_CODE_PATH);
$message=get_lang('YouWereCalled').' : '.GetFullUserName($row['chatcall_user_id'],'').'<br>'.get_lang('DoYouAccept')
."<p>"
."<a href=\"".$webpath."chat/chat.php?cidReq=".$_cid."&origin=whoisonlinejoin\">"
. get_lang("Yes")
."</a>"
."&nbsp;&nbsp;|&nbsp;&nbsp;"
."<a href=\"".api_get_path(WEB_PATH)."webchatdeny.php\">"
. get_lang("No")
."</a>"
."</p>";
return($message);
} else {
return false;
}
}

@ -1072,6 +1072,10 @@ class SocialManager extends UserManager
}
$userPicture = $user_info['avatar'];
$officialCode = '';
if (api_get_setting('show_official_code_whoisonline') == 'true') {
$officialCode .= '<div class="items-user-official-code"><p style="min-height: 30px;" title="'.get_lang('OfficialCode').'">'.$user_info['official_code'].'</p></div>';
}
$img = '<img class="img-responsive img-circle" title="'.$completeName.'" alt="'.$completeName.'" src="'.$userPicture.'">';
$url = null;
@ -1093,6 +1097,7 @@ class SocialManager extends UserManager
<div class="items-user-name">
'.$name.'
</div>
'.$officialCode.'
<div class="items-user-status">'.$status_icon_chat.' '.$user_rol.'</div>
</div>
</div>';

@ -1539,7 +1539,7 @@ class IndexManager
$listCoursesInfo = array();
if (!isset($_GET['history'])) {
// Display special courses
$specialCoursesResult = CourseManager::display_special_courses(
$specialCoursesResult = CourseManager::returnSpecialCourses(
$user_id,
$loadDirs
);

@ -1875,6 +1875,10 @@ INSERT INTO settings_current (variable, type, category, selected_value, title, c
INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_profile_user_address_geolocalization', 'true', 'Yes');
INSERT INTO settings_options (variable, value, display_text) VALUES ('enable_profile_user_address_geolocalization', 'false', 'No');
INSERT INTO settings_current (variable, type, category, selected_value, title, comment) VALUES ('show_official_code_whoisonline', 'radio', 'User', 'false', 'ShowOfficialCodeInWhoIsOnlinePage', 'ShowOfficialCodeInWhoIsOnlinePageComment');
INSERT INTO settings_options (variable, value, display_text) VALUES ('show_official_code_whoisonline', 'true', 'Yes');
INSERT INTO settings_options (variable, value, display_text) VALUES ('show_official_code_whoisonline', 'false', 'No');
INSERT INTO access_url_rel_course_category (access_url_id, course_category_id) VALUES (1, 1);
INSERT INTO access_url_rel_course_category (access_url_id, course_category_id) VALUES (1, 2);
INSERT INTO access_url_rel_course_category (access_url_id, course_category_id) VALUES (1, 3);

@ -5543,7 +5543,7 @@ class learnpath
}
// We need to close the form when we are updating the mp3 files.
if ($update_audio == 'true' && count($this->arrMenu) != 0) {
if ($update_audio == 'true' && isset($this->arrMenu) && count($this->arrMenu) != 0) {
$return .= '</form>';
}
@ -9233,7 +9233,12 @@ class learnpath
$dest_path_to_lp = substr($this->path, -1) == '.' ? substr($this->path, 0, -1) : $this->path;
$dest_path_to_scorm_folder = str_replace('//','/',$temp_zip_dir.'/scorm/'.$dest_path_to_lp);
mkdir($dest_path_to_scorm_folder, api_get_permissions_for_new_directories(), true);
$zip_files_dist = copyr($current_course_path.'/scorm/'.$this->path, $dest_path_to_scorm_folder, array('imsmanifest'), $zip_files);
copyr(
$current_course_path.'/scorm/'.$this->path,
$dest_path_to_scorm_folder,
array('imsmanifest'),
$zip_files
);
}
// Build a dummy imsmanifest structure.
@ -9296,7 +9301,7 @@ class learnpath
foreach ($this->items as $index => $item) {
if (!in_array($item->type, array(TOOL_QUIZ, TOOL_FORUM, TOOL_THREAD, TOOL_LINK, TOOL_STUDENTPUBLICATION))) {
// Get included documents from this item.
if ($item->type == 'sco') {
if ($item->type === 'sco') {
$inc_docs = $item->get_resources_from_source(
null,
api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/' . 'scorm/' . $this->path . '/' . $item->get_path()
@ -9366,7 +9371,7 @@ class learnpath
$my_resource->setAttribute('type', 'webcontent');
$my_resource->setAttribute('href', $my_xml_file_path);
// adlcp:scormtype can be either 'sco' or 'asset'.
if ($item->type == 'sco') {
if ($item->type === 'sco') {
$my_resource->setAttribute('adlcp:scormtype', 'sco');
} else {
$my_resource->setAttribute('adlcp:scormtype', 'asset');
@ -9382,7 +9387,9 @@ class learnpath
$i = 1;
if ($inc_docs)
foreach ($inc_docs as $doc_info) {
if (count($doc_info) < 1 || empty($doc_info[0])) { continue; }
if (count($doc_info) < 1 || empty($doc_info[0])) {
continue;
}
$my_dep = $xmldoc->createElement('resource');
$res_id = 'RESOURCE_'.$item->get_id().'_'.$i;
$my_dep->setAttribute('identifier', $res_id);
@ -9395,7 +9402,7 @@ class learnpath
// Remote file. Save url as is.
$my_dep_file->setAttribute('href', $doc_info[0]);
$my_dep->setAttribute('xml:base', '');
} elseif ($doc_info[1] == 'local') {
} elseif ($doc_info[1] === 'local') {
switch ($doc_info[2]) {
case 'url': // Local URL - save path as url for now, don't zip file.
$abs_path = api_get_path(SYS_PATH).str_replace(api_get_path(WEB_PATH), '', $doc_info[0]);
@ -9443,7 +9450,10 @@ class learnpath
if ($pos === 0) {
$abs_img_path_without_subdir = '/'.substr($abs_img_path_without_subdir, strlen($relp));
}
$file_path = realpath(api_get_path(SYS_PATH).$abs_img_path_without_subdir);
//$file_path = realpath(api_get_path(SYS_PATH).$abs_img_path_without_subdir);
$file_path = realpath(api_get_path(SYS_APP_PATH).$abs_img_path_without_subdir);
$file_path = str_replace('\\', '/', $file_path);
$file_path = str_replace('//', '/', $file_path);
@ -10005,10 +10015,10 @@ EOD;
$main_code_path = api_get_path(SYS_CODE_PATH) . 'lp/packaging/';
$extra_files = scandir($main_code_path);
foreach ($extra_files as $extra_file) {
if (strpos($extra_file, '.') === 0)
if (strpos($extra_file, '.') === 0) {
continue;
else {
$dest_file = $archive_path . $temp_dir_short . '/' . $extra_file;
} else {
$dest_file = $archive_path.$temp_dir_short.'/'.$extra_file;
$this->create_path($dest_file);
copy($main_code_path.$extra_file, $dest_file);
}
@ -10019,7 +10029,11 @@ EOD;
$manifest = @$xmldoc->saveXML();
$manifest = api_utf8_decode_xml($manifest); // The manifest gets the system encoding now.
file_put_contents($archive_path.'/'.$temp_dir_short.'/imsmanifest.xml', $manifest);
$zip_folder->add($archive_path.'/'.$temp_dir_short, PCLZIP_OPT_REMOVE_PATH, $archive_path.'/'.$temp_dir_short.'/');
$zip_folder->add(
$archive_path.'/'.$temp_dir_short,
PCLZIP_OPT_REMOVE_PATH,
$archive_path.'/'.$temp_dir_short.'/'
);
// Clean possible temporary files.
foreach ($files_cleanup as $file) {

@ -15,17 +15,11 @@ if (isset($_REQUEST['action']) && Security::remove_XSS($_REQUEST['action']) !==
$showCourses = CoursesAndSessionsCatalog::showCourses();
$showSessions = CoursesAndSessionsCatalog::showSessions();
$pageCurrent = isset($pageCurrent) ? $pageCurrent :
isset($_GET['pageCurrent']) ? intval($_GET['pageCurrent']) :
1;
$pageLength = isset($pageLength) ? $pageLength :
isset($_GET['pageLength']) ? intval($_GET['pageLength']) :
10;
$pageCurrent = isset($pageCurrent) ? $pageCurrent : isset($_GET['pageCurrent']) ? intval($_GET['pageCurrent']) : 1;
$pageLength = isset($pageLength) ? $pageLength : isset($_GET['pageLength']) ? intval($_GET['pageLength']) : 12;
$pageTotal = intval(ceil(intval($countCoursesInCategory) / $pageLength));
$cataloguePagination = $pageTotal > 1 ?
CourseCategory::getCatalogPagination($pageCurrent, $pageLength, $pageTotal) :
'';
$search_term = isset($search_term) ? $search_term :null;
$cataloguePagination = $pageTotal > 1 ? CourseCategory::getCatalogPagination($pageCurrent, $pageLength, $pageTotal) : '';
$search_term = isset($search_term) ? $search_term : null;
if ($showSessions && isset($_POST['date'])) {
$date = $_POST['date'];
@ -123,51 +117,50 @@ $code = isset($code) ? $code : null;
</div>
</div>
</form>
<?php } ?>
<?php } ?>
</div>
<div class="col-md-4">
<h5><?php echo get_lang('CourseCategories'); ?></h5>
<?php
$webAction = api_get_path(WEB_CODE_PATH).'auth/courses.php';
$action = (!empty($_REQUEST['action']) ? Security::remove_XSS($_REQUEST['action']):'display_courses');
$pageLength = (!empty($_REQUEST['pageLength'])?intval($_REQUEST['pageLength']):10);
$pageCurrent = (!empty($_REQUEST['pageCurrent'])?intval($_REQUEST['pageCurrent']):1);
$form = '<form action="'.$webAction.'" method="GET" class="form-horizontal">';
$form .= '<input type="hidden" name="action" value="' . $action . '">';
$form .= '<input type="hidden" name="pageCurrent" value="' . $pageCurrent . '">';
$form .= '<input type="hidden" name="pageLength" value="' . $pageLength . '">';
$form .= '<div class="form-group">';
$form .= '<div class="col-sm-12">';
$form .= '<select name="category_code" onchange="submit();" class="selectpicker show-tick form-control">';
$codeType = isset($_REQUEST['category_code']) ? Security::remove_XSS($_REQUEST['category_code']) : '';
foreach ($browse_course_categories[0] as $category) {
$categoryCode = $category['code'];
$countCourse = $category['count_courses'];
$form .= '<option '. ($categoryCode == $codeType? 'selected="selected" ':'') .' value="' . $category['code'] . '">' . $category['name'] . ' ( '. $countCourse .' ) </option>';
if (!empty($browse_course_categories[$categoryCode])) {
foreach ($browse_course_categories[$categoryCode] as $subCategory){
$subCategoryCode = $subCategory['code'];
$form .= '<option '. ($subCategoryCode == $codeType ? 'selected="selected" ':'') .' value="' . $subCategory['code'] . '"> ---' . $subCategory['name'] . ' ( '. $subCategory['count_courses'] .' ) </option>';
}
$webAction = api_get_path(WEB_CODE_PATH).'auth/courses.php';
$action = (!empty($_REQUEST['action']) ? Security::remove_XSS($_REQUEST['action']) : 'display_courses');
$pageLength = (!empty($_REQUEST['pageLength']) ? intval($_REQUEST['pageLength']) : 10);
$pageCurrent = (!empty($_REQUEST['pageCurrent']) ? intval($_REQUEST['pageCurrent']) : 1);
$form = '<form action="'.$webAction.'" method="GET" class="form-horizontal">';
$form .= '<input type="hidden" name="action" value="' . $action . '">';
$form .= '<input type="hidden" name="pageCurrent" value="' . $pageCurrent . '">';
$form .= '<input type="hidden" name="pageLength" value="' . $pageLength . '">';
$form .= '<div class="form-group">';
$form .= '<div class="col-sm-12">';
$form .= '<select name="category_code" onchange="submit();" class="selectpicker show-tick form-control">';
$codeType = isset($_REQUEST['category_code']) ? Security::remove_XSS($_REQUEST['category_code']) : '';
foreach ($browse_course_categories[0] as $category) {
$categoryCode = $category['code'];
$countCourse = $category['count_courses'];
$form .= '<option '. ($categoryCode == $codeType? 'selected="selected" ':'') .' value="' . $category['code'] . '">' . $category['name'] . ' ( '. $countCourse .' ) </option>';
if (!empty($browse_course_categories[$categoryCode])) {
foreach ($browse_course_categories[$categoryCode] as $subCategory){
$subCategoryCode = $subCategory['code'];
$form .= '<option '. ($subCategoryCode == $codeType ? 'selected="selected" ':'') .' value="' . $subCategory['code'] . '"> ---' . $subCategory['name'] . ' ( '. $subCategory['count_courses'] .' ) </option>';
}
}
$form .= '</select>';
$form .= '</div>';
$form .= '</form>';
echo $form;
?>
}
$form .= '</select>';
$form .= '</div>';
$form .= '</form>';
echo $form;
?>
</div>
</div>
<?php
if ($showSessions) { ?>
<div class="col-md-4">
<h5><?php echo get_lang('Sessions'); ?></h5>
<a class="btn btn-default btn-block" href="<?php echo CourseCategory::getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions'); ?>">
<?php echo get_lang('SessionList'); ?>
</a>
</div>
<div class="col-md-4">
<h5><?php echo get_lang('Sessions'); ?></h5>
<a class="btn btn-default btn-block" href="<?php echo CourseCategory::getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions'); ?>">
<?php echo get_lang('SessionList'); ?>
</a>
</div>
<?php } ?>
</div>
<?php } ?>
@ -190,13 +183,13 @@ if ($showCourses && $action != 'display_sessions') {
if (!empty($search_term)) {
echo "<p><strong>".get_lang('SearchResultsFor')." ".Security::remove_XSS($_POST['search_term'])."</strong><br />";
}
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
$user_id = api_get_user_id();
if (!empty($browse_courses_in_category)) {
foreach ($browse_courses_in_category as $course) {
$course_hidden = ($course['visibility'] == COURSE_VISIBILITY_HIDDEN);
$course_hidden = $course['visibility'] == COURSE_VISIBILITY_HIDDEN;
if ($course_hidden) {
continue;
@ -213,7 +206,7 @@ if ($showCourses && $action != 'display_sessions') {
$course_subscribe_allowed = ($course['subscribe'] == 1);
$course_unsubscribe_allowed = ($course['unsubscribe'] == 1);
$count_connections = $course['count_connections'];
$creation_date = substr($course['creation_date'],0,10);
$creation_date = substr($course['creation_date'], 0, 10);
$html = null;
// display the course bloc
@ -320,7 +313,7 @@ function returnThumbnail($course)
// without picture
$course_medium_image = Display::return_icon('session_default.png', null, null, null, null, true);
}
$html .= '<div class="image">';
$html .= '<img class="img-responsive" src="'.$course_medium_image.'" alt="'.api_htmlentities($title).'"/>';
$categoryTitle = $course['category'];

@ -0,0 +1,342 @@
<div class="page-chat">
<div class="row">
<div class="col-sm-4 col-md-5 col-lg-4">
<ul class="row list-unstyled" id="chat-users"></ul>
</div>
<div class="col-sm-8 col-md-7 col-lg-8">
<div id="chat-tabs">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#all" aria-controls="all" role="tab" data-toggle="tab">{{ 'All'|get_lang }}</a>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="all">
<div class="course-chat chat-history" id="chat-history"></div>
</div>
</div>
</div>
<div class="profile row">
<div class="col-xs-12">
<div class="message-form-chat">
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active">
<a href="#tab1" data-toggle="tab">{{ 'Write'|get_lang }}</a>
</li>
<li>
<a href="#tab2" id="preview" data-toggle="tab">{{ 'Preview'|get_lang }}</a>
</li>
<li>
<button id="emojis" class="btn btn-link" type="button">
<span class="sr-only">{{ 'Emoji'|get_lang }}</span>{{ emoji_smile }}
</button>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<div class="row">
<div class="col-sm-9">
<span class="sr-only">{{ 'Message'|get_lang }}</span>
<textarea id="chat-writer" name="message"></textarea>
</div>
<div class="col-sm-3">
<button id="chat-send-message" type="button" class="btn btn-primary">{{ 'Send'|get_lang }}</button>
</div>
</div>
</div>
<div class="tab-pane" id="tab2">
<div id="html-preview" class="emoji-wysiwyg-editor-preview"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<audio id="chat-alert">
<source src="{{ _p.web_main }}/chat/sound/notification.wav" type="audio/wav"></source>
<source src="{{ _p.web_main }}chat/sound/notification.ogg" type="audio/ogg"></source>
<source src="{{ _p.web_main }}chat/sound/notification.mp3" type="audio/mpeg"></source>
</audio>
<script>
$(document).on('ready', function () {
var ChChat = {
_ajaxUrl: '{{ _p.web_ajax }}course_chat.ajax.php?{{ _p.web_cid_query }}',
_historySize: -1,
usersOnline: 0,
currentFriend: 0,
call: false,
track: function () {
return $
.get(ChChat._ajaxUrl, {
action: 'track',
size: ChChat._historySize,
users_online: ChChat.usersOnline,
friend: ChChat.currentFriend
})
.done(function (response) {
if (response.data.chatIsDenied) {
alert("{{ 'ChatDenied'|get_lang }}");
return;
}
if (response.data.history) {
ChChat._historySize = response.data.oldFileSize;
ChChat.setHistory(response.data.history);
}
if (response.data.userList) {
ChChat.usersOnline = response.data.usersOnline;
ChChat.setConnectedUsers(response.data.userList);
}
});
},
setHistory: function (messageList) {
var chatHistoryContainer = ChChat.currentFriend ? ('#chat-history-' + ChChat.currentFriend) : '#chat-history';
$(chatHistoryContainer)
.html(messageList)
.prop('scrollTop', function () {
return this.scrollHeight;
});
$('#chat-alert').get(0).play();
},
setConnectedUsers: function (userList) {
var html = '';
userList.forEach(function (user) {
var buttonStatus = user.isConnected ? 'success' : 'muted',
buttonTitle = user.isConnected ? '{{ 'StartAChat'|get_lang }}' : '{{ 'LeaveAMessage'|get_lang }}';
html += '<li class="col-xs-12 chat-user">' +
' <div>' +
' <img src="'+ user.image_url + '" alt="' + user.complete_name + '" class="img-circle user-image-chat"/>' +
' <ul class="list-unstyled">' +
' <li>' + user.complete_name;
if (user.id != {{ _u.user_id }}) {
html += ' <button type="button" class="btn btn-link btn-xs" title="' + buttonTitle + '" data-name="' + user.complete_name + '" data-user="' + user.id + '">' +
' <i class="fa fa-comments text-' + buttonStatus + '"></i><span class="sr-only">' + buttonTitle + '</span>' +
' </button>';
}
html += ' </li>' +
' <li><small>' + user.username + '</small></li>' +
' </ul>' +
' </div>' +
'</li>';
});
$('#chat-users').html(html);
},
onPreviewListener: function () {
$
.post(ChChat._ajaxUrl, {
action: 'preview',
'message': $('textarea#chat-writer').val()
})
.done(function (response) {
if (!response.status) {
return;
}
$('#html-preview').html(response.data.message);
});
},
onSendMessageListener: function (e) {
e.preventDefault();
if (!$('textarea#chat-writer').val().trim().length) {
return;
}
var self = this;
self.disabled = true;
$
.post(ChChat._ajaxUrl, {
action: 'write',
message: $('textarea#chat-writer').val(),
friend: ChChat.currentFriend
})
.done(function (response) {
self.disabled = false;
if (!response.status) {
return;
}
$('textarea#chat-writer').val('');
$(".emoji-wysiwyg-editor").html('');
});
},
onResetListener: function (e) {
if (!confirm("{{ 'ConfirmReset'|get_lang }}")) {
e.preventDefault();
return;
}
$
.get(ChChat._ajaxUrl, {
action: 'reset',
friend: ChChat.currentFriend
})
.done(function (response) {
if (!response.status) {
return;
}
ChChat.setHistory(response.data);
});
},
init: function () {
ChChat.track().done(function () {
ChChat.init();
});
}
};
hljs.initHighlightingOnLoad();
emojione.ascii = true;
emojione.imagePathPNG = '{{ _p.web_lib }}javascript/emojione/png/';
emojione.imagePathSVG = '{{ _p.web_lib }}javascript/emojione/svg/';
emojione.imagePathSVGSprites = '{{ _p.web_lib }}javascript/emojione/sprites/';
var emojiStrategy = {{ emoji_strategy|json_encode }};
$.emojiarea.path = '{{ _p.web_lib }}javascript/emojione/png/';
$.emojiarea.icons = {{ icons|json_encode }};
$('body').on('click', '#chat-reset', ChChat.onResetListener);
$('#preview').on('click', ChChat.onPreviewListener);
$('#emojis').on('click', function () {
$('[data-toggle="tab"][href="#tab1"]')
.show()
.tab('show');
});
$('textarea#chat-writer').emojiarea({
button: '#emojis'
});
$('body').delay(1500).find('.emoji-wysiwyg-editor').textcomplete([
{
match: /\B:([\-+\w]*)$/,
search: function (term, callback) {
var results = [];
var results2 = [];
var results3 = [];
$.each(emojiStrategy, function (shortname, data) {
if (shortname.indexOf(term) > -1) {
results.push(shortname);
} else {
if ((data.aliases !== null) && (data.aliases.indexOf(term) > -1)) {
results2.push(shortname);
} else if ((data.keywords !== null) && (data.keywords.indexOf(term) > -1)) {
results3.push(shortname);
}
}
});
if (term.length >= 3) {
results.sort(function (a, b) {
return (a.length > b.length);
});
results2.sort(function (a, b) {
return (a.length > b.length);
});
results3.sort();
}
var newResults = results.concat(results2).concat(results3);
callback(newResults);
},
template: function (shortname) {
return '<img class="emojione" src="{{ _p.web_lib }}javascript/emojione/png/'
+ emojiStrategy[shortname].unicode
+ '.png"> :' + shortname + ':';
},
replace: function (shortname) {
return ':' + shortname + ': ';
},
index: 1,
maxCount: 10
}
], {});
$('button#chat-send-message').on('click', ChChat.onSendMessageListener);
$('#chat-users').on('click', 'button.btn', function (e) {
e.preventDefault();
var jSelf = $(this),
userId = parseInt(jSelf.data('user')) || 0;
if (!userId) {
return;
}
var exists = false;
$('#chat-tabs ul.nav li').each(function (i, el) {
if ($(el).data('user') == userId) {
exists = true;
}
});
if (exists) {
$('#chat-tab-' + userId).tab('show');
return;
}
$('#chat-tabs ul.nav-tabs').append('\
<li role="presentation" data-user="' + userId + '">\
<a id="chat-tab-' + userId + '" href="#chat-' + userId + '" aria-controls="chat-' + userId + '" role="tab" data-toggle="tab">' + jSelf.data('name') + '</a>\
</li>\
');
$('#chat-tabs .tab-content').append('\
<div role="tabpanel" class="tab-pane" id="chat-' + userId + '">\
<div class="course-chat chat-history" id="chat-history-' + userId + '"></div>\
</div>\
');
$('#chat-tab-' + userId).tab('show');
});
$('#chat-tabs ul.nav-tabs').on('shown.bs.tab', 'li a', function (e) {
var jSelf = $(this);
var userId = parseInt(jSelf.parent().data('user')) || 0;
if (!userId) {
ChChat.currentFriend = 0;
return;
}
ChChat.currentFriend = userId;
$(this).tab('show');
});
$('.emoji-wysiwyg-editor').on('keyup', function (e) {
if (e.ctrlKey && e.keyCode === 13) {
$('button#chat-send-message').trigger('click');
}
});
ChChat.init();
});
</script>

@ -926,7 +926,8 @@ class Wiki
if ($row['content']=='' && $row['title']=='' && $page=='index') {
if (api_is_allowed_to_edit(false, true) ||
api_is_platform_admin() ||
GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())
GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id()) ||
api_is_allowed_in_course()
) {
//Table structure for better export to pdf
$default_table_for_content_Start='<table align="center" border="0"><tr><td align="center">';
@ -961,7 +962,8 @@ class Wiki
if ($KeyVisibility == "1" ||
api_is_allowed_to_edit(false, true) ||
api_is_platform_admin() ||
($row['assignment'] == 2 && $KeyVisibility=="0" && (api_get_user_id() == $row['user_id']))
($row['assignment'] == 2 && $KeyVisibility=="0" && (api_get_user_id() == $row['user_id'])) ||
api_is_allowed_in_course()
) {
$actionsLeft = '';
@ -973,7 +975,7 @@ class Wiki
$actionsLeft .= $editLink;
} else {
if ((api_is_allowed_in_course() ||
GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())) && $page != 'index'
GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id()))
) {
$actionsLeft .= $editLink;
} else {
@ -1277,7 +1279,7 @@ class Wiki
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_editlock = $row['editlock'];
$id = $row['id'];
$id = $row['page_id'];
///change status
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
@ -1289,7 +1291,7 @@ class Wiki
}
$sql = 'UPDATE '.$tbl_wiki.' SET editlock="'.Database::escape_string($status_editlock).'"
WHERE c_id = '.$course_id.' AND id="'.$id.'"';
WHERE c_id = '.$course_id.' AND page_id="'.$id.'"';
Database::query($sql);
$sql='SELECT * FROM '.$tbl_wiki.'
@ -4230,7 +4232,8 @@ class Wiki
//Only teacher, platform admin and group members can edit a wiki group
if (api_is_allowed_to_edit(false,true) ||
api_is_platform_admin() ||
GroupManager :: is_user_in_group($userId, $this->group_id)
GroupManager :: is_user_in_group($userId, $this->group_id) ||
api_is_allowed_in_course()
) {
$PassEdit = true;
} else {
@ -4846,8 +4849,9 @@ class Wiki
// Only teachers and platform admin can edit the index page.
// Only teachers and platform admin can edit an assignment teacher.
// And users in groups
if (($row['reflink'] == 'index' || $row['reflink'] == '' || $row['assignment'] == 1) &&
(!api_is_allowed_to_edit(false, true) && $groupId == 0)
(!api_is_allowed_to_edit(false, true) && $groupId == 0) && !api_is_allowed_in_course()
) {
Display::addFlash(
Display::return_message(get_lang('OnlyEditPagesCourseManager')),
@ -4903,7 +4907,7 @@ class Wiki
}
if ($PassEdit) {
//show editor if edit is allowed
//show editor if edit is allowed <<<<<
if ($row['editlock'] == 1 &&
(api_is_allowed_to_edit(false, true) == false || api_is_platform_admin()==false)
) {
@ -5064,7 +5068,9 @@ class Wiki
Display::addFlash(
Display::return_message(
$is_being_edited
$is_being_edited,
'normal',
false
)
);
@ -5477,7 +5483,8 @@ class Wiki
if (self::checktitle('index')) {
if (api_is_allowed_to_edit(false,true) ||
api_is_platform_admin() ||
GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())
GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id()) ||
api_is_allowed_in_course()
) {
self::setMessage(Display::display_normal_message(get_lang('GoAndEditMainPage'), false, true));
} else {

@ -29,6 +29,5 @@ Disallow: /tests/
# Files
Disallow: /license.txt
Disallow: /README.txt
Disallow: /webchatdeny.php
Disallow: /whoisonline.php
Disallow: /whoisonlinesession.php

@ -431,11 +431,13 @@ class CourseRecycler
// Identifying again and deletion of the orphan questions, if it was desired.
if ($delete_orphan_questions) {
// If this query was ever too slow, there is an alternative here:
// https://github.com/beeznest/chamilo-lms-icpna/commit/a38eab725402188dffff50245ee068d79bcef779
$sql = " (
SELECT q.id, ex.c_id FROM $table_qui_que q
INNER JOIN $table_rel r
ON (q.c_id = r.c_id AND q.id = r.question_id)
INNER JOIN $table_qui ex
ON (ex.id = r.exercice_id AND ex.c_id = r.c_id)
WHERE ex.c_id = ".$this->course_id." AND (ex.active = '-1' OR ex.id = '-1')

@ -212,27 +212,6 @@ class User extends BaseUser
*/
private $productions;
/**
* @var integer
*
* @ORM\Column(name="chatcall_user_id", type="integer", nullable=true, unique=false)
*/
private $chatcallUserId;
/**
* @var \DateTime
*
* @ORM\Column(name="chatcall_date", type="datetime", nullable=true, unique=false)
*/
private $chatcallDate;
/**
* @var string
*
* @ORM\Column(name="chatcall_text", type="string", length=50, nullable=true, unique=false)
*/
private $chatcallText;
/**
* @var string
*
@ -407,7 +386,6 @@ class User extends BaseUser
$this->portals = new ArrayCollection();
$this->dropBoxSentFiles = new ArrayCollection();
$this->dropBoxReceivedFiles = new ArrayCollection();
$this->chatcallUserId = 0;
//$this->extraFields = new ArrayCollection();
//$this->userId = 0;
//$this->createdAt = new \DateTime();
@ -1064,75 +1042,6 @@ class User extends BaseUser
return $this->productions;
}
/**
* Set chatcallUserId
*
* @param integer $chatcallUserId
* @return User
*/
public function setChatcallUserId($chatcallUserId)
{
$this->chatcallUserId = $chatcallUserId;
return $this;
}
/**
* Get chatcallUserId
*
* @return integer
*/
public function getChatcallUserId()
{
return $this->chatcallUserId;
}
/**
* Set chatcallDate
*
* @param \DateTime $chatcallDate
* @return User
*/
public function setChatcallDate($chatcallDate)
{
$this->chatcallDate = $chatcallDate;
return $this;
}
/**
* Get chatcallDate
*
* @return \DateTime
*/
public function getChatcallDate()
{
return $this->chatcallDate;
}
/**
* Set chatcallText
*
* @param string $chatcallText
* @return User
*/
public function setChatcallText($chatcallText)
{
$this->chatcallText = $chatcallText;
return $this;
}
/**
* Get chatcallText
*
* @return string
*/
public function getChatcallText()
{
return $this->chatcallText;
}
/**
* Set language
*

@ -251,27 +251,6 @@ class User implements UserInterface //implements ParticipantInterface, ThemeUser
*/
private $productions;
/**
* @var integer
*
* @ORM\Column(name="chatcall_user_id", type="integer", nullable=true, unique=false)
*/
private $chatcallUserId;
/**
* @var \DateTime
*
* @ORM\Column(name="chatcall_date", type="datetime", nullable=true, unique=false)
*/
private $chatcallDate;
/**
* @var string
*
* @ORM\Column(name="chatcall_text", type="string", length=50, nullable=true, unique=false)
*/
private $chatcallText;
/**
* @var string
*
@ -474,7 +453,6 @@ class User implements UserInterface //implements ParticipantInterface, ThemeUser
$this->portals = new ArrayCollection();
$this->dropBoxSentFiles = new ArrayCollection();
$this->dropBoxReceivedFiles = new ArrayCollection();
$this->chatcallUserId = 0;
//$this->extraFields = new ArrayCollection();
//$this->userId = 0;
//$this->createdAt = new \DateTime();
@ -1169,75 +1147,6 @@ class User implements UserInterface //implements ParticipantInterface, ThemeUser
return $this->productions;
}
/**
* Set chatcallUserId
*
* @param integer $chatcallUserId
* @return User
*/
public function setChatcallUserId($chatcallUserId)
{
$this->chatcallUserId = $chatcallUserId;
return $this;
}
/**
* Get chatcallUserId
*
* @return integer
*/
public function getChatcallUserId()
{
return $this->chatcallUserId;
}
/**
* Set chatcallDate
*
* @param \DateTime $chatcallDate
* @return User
*/
public function setChatcallDate($chatcallDate)
{
$this->chatcallDate = $chatcallDate;
return $this;
}
/**
* Get chatcallDate
*
* @return \DateTime
*/
public function getChatcallDate()
{
return $this->chatcallDate;
}
/**
* Set chatcallText
*
* @param string $chatcallText
* @return User
*/
public function setChatcallText($chatcallText)
{
$this->chatcallText = $chatcallText;
return $this;
}
/**
* Get chatcallText
*
* @return string
*/
public function getChatcallText()
{
return $this->chatcallText;
}
/**
* Set language
*

@ -1,5 +1,4 @@
<?php
require_once(api_get_path(SYS_CODE_PATH).'chat/chat_functions.lib.php');
require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
class TestChatFunctions extends UnitTestCase {
@ -16,25 +15,6 @@ class TestChatFunctions extends UnitTestCase {
$this->tcourse = null;
}
function testuser_connected_in_chat () {
$course_code = 'COURSETEST';
$user_id = 1;
$res = user_connected_in_chat($user_id);
$this->assertTrue(is_bool($res));
}
function testUsersListInChat () {
$course_code = 'COURSETEST';
$course_info = api_get_course_info($course_code);
$database_name = $course_info['dbName'];
$res = users_list_in_chat($database_name);
$this->assertTrue(is_array($res));
//var_dump($res);
}
function CreateChatConnection($database_name) {
$session_id = 1;
$tbl_chat_connected = Database::get_main_table(TABLE_MAIN_CHAT);
@ -51,29 +31,5 @@ class TestChatFunctions extends UnitTestCase {
}
Database::query($query);
}
function testExitOfChat () {
$course_code = 'COURSETEST';
$course_info = api_get_course_info($course_code);
$database_name = $course_info['dbName'];
$this->CreateChatConnection($database_name);
$user_id = 1;
$res = exit_of_chat($user_id);
//$resu = $this->tcourse->delete_course($course_code);
$this->assertTrue(is_null($res));
//var_dump($res);
}
function testDisconnectUserOfChat() {
$_SESSION['is_courseAdmin'] = 1;
$course_code = 'COURSETEST';
$course_info = api_get_course_info($course_code);
$database_name = $course_info['dbName'];
$this->CreateChatConnection($database_name);
$res = disconnect_user_of_chat($database_name);
$this->assertTrue(is_null($res));
}
}
?>

@ -1,30 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @todo can't this be moved to a different file so that we can delete this file?
* Is this still in use? If not, then it should be removed or maybe offered as an extension
*/
/**
* Deletes the web-chat request form the user table
*/
// including necessary files
include_once './main/inc/global.inc.php';
// table definitions
$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
if (isset($_user['user_id']) && $_user['user_id'] != '') {
$_user['user_id'] = intval($_user['user_id']);
$sql = "update $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='DENIED' where (user_id = ".$_user['user_id'].")";
$result = Database::query($sql);
}
Display::display_header();
$message = get_lang('RequestDenied').'<br /><br /><a href="javascript: history.back();">'.get_lang('Back').'</a>';
Display::display_normal_message($message);
/* FOOTER */
Display::display_footer();

@ -18,26 +18,11 @@ if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
$_SESSION['who_is_online_counter'] = 2;
$this_section = SECTION_SOCIAL;
// table definitions
$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
$social_right_content = null;
$whoisonline_list = null;
$social_search = '';
/* if (isset($_GET['chatid'])) {
//send out call request
$time = time();
$time = date("Y-m-d H:i:s", $time);
$chatid = intval($_GET['chatid']);
if ($_GET['chatid'] == strval(intval($_GET['chatid']))) {
$sql = "update $track_user_table set chatcall_user_id = ".intval($_user['user_id']).", chatcall_date = '".Database::escape_string($time)."', chatcall_text = '' where (user_id = ".(int)Database::escape_string($chatid).")";
$result = Database::query($sql);
//redirect caller to chat
header("Location: ".api_get_path(WEB_CODE_PATH)."chat/chat.php?".api_get_cidreq()."&origin=whoisonline&target=".Security::remove_XSS($chatid));
exit;
}
}
*/
// This if statement prevents users accessing the who's online feature when it has been disabled.
if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
((api_get_setting('showonline', 'users') == 'true' || api_get_setting('showonline', 'course') == 'true') && $_user['user_id'])

Loading…
Cancel
Save