Fixing counter field update due the global chat see #4191

skala
Julio Montoya 13 years ago
parent 1f932c8b84
commit f89a25ff44
  1. 2
      main/inc/ajax/chat.ajax.php
  2. 1
      main/inc/lib/chat.lib.php
  3. 16
      main/inc/local.inc.php

@ -4,6 +4,8 @@
* Responses to AJAX calls * Responses to AJAX calls
*/ */
$_dont_save_user_course_access = true;
require_once '../global.inc.php'; require_once '../global.inc.php';
require_once api_get_path(LIBRARY_PATH).'chat.lib.php'; require_once api_get_path(LIBRARY_PATH).'chat.lib.php';

@ -192,7 +192,6 @@ class Chat extends Model {
function close() { function close() {
unset($_SESSION['openChatBoxes'][$_POST['chatbox']]); unset($_SESSION['openChatBoxes'][$_POST['chatbox']]);
unset($_SESSION['chatHistory'][$_POST['chatbox']]); unset($_SESSION['chatHistory'][$_POST['chatbox']]);
echo "1"; echo "1";
exit; exit;
} }

@ -792,7 +792,15 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
} }
if (!isset($_SESSION['login_as'])) { if (!isset($_SESSION['login_as'])) {
$save_course_access = true;
//The value $_dont_save_user_course_access should be added before the call of global.inc.php see the main/inc/chat.ajax.php file
//Disables the updates in the TRACK_E_COURSE_ACCESS table
if (isset($_dont_save_user_course_access) && $_dont_save_user_course_access == true) {
$save_course_access = false;
}
if ($save_course_access) {
$course_tracking_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); $course_tracking_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
/* /*
@ -814,8 +822,7 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
$time = api_get_datetime(); $time = api_get_datetime();
//We select the last record for the current course in the course tracking table //We select the last record for the current course in the course tracking table
// But only if the login date is < than now + max_life_time //But only if the login date is < than now + max_life_time
$sql = "SELECT course_access_id FROM $course_tracking_table $sql = "SELECT course_access_id FROM $course_tracking_table
WHERE user_id = ".intval($_user ['user_id'])." AND WHERE user_id = ".intval($_user ['user_id'])." AND
course_code = '$course_code' AND course_code = '$course_code' AND
@ -823,9 +830,8 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
login_course_date > now() - INTERVAL $session_lifetime SECOND login_course_date > now() - INTERVAL $session_lifetime SECOND
ORDER BY login_course_date DESC LIMIT 0,1"; ORDER BY login_course_date DESC LIMIT 0,1";
$result = Database::query($sql); $result = Database::query($sql);
//error_log($sql);
if (Database::num_rows($result)>0) {
if (Database::num_rows($result) > 0) {
$i_course_access_id = Database::result($result,0,0); $i_course_access_id = Database::result($result,0,0);
//We update the course tracking table //We update the course tracking table
$sql="UPDATE $course_tracking_table SET logout_course_date = '$time', counter = counter+1 ". $sql="UPDATE $course_tracking_table SET logout_course_date = '$time', counter = counter+1 ".
@ -839,6 +845,8 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
Database::query($sql); Database::query($sql);
} }
} }
}
} }
} }

Loading…
Cancel
Save