Adding session id to the \"event_access_course\" function in events.lib

skala
Julio Montoya 15 years ago
parent 7c1439e8ea
commit 0e17f68bdf
  1. 50
      main/inc/lib/events.lib.inc.php

@ -143,9 +143,9 @@ function event_access_course()
$res = Database::query($sql);
if (Database::affected_rows() == 0) {
$sql = " INSERT INTO $TABLETRACK_LASTACCESS
(access_user_id,access_cours_code,access_date, access_session_id)
VALUES
(".$user_id.", '".$_cid."', FROM_UNIXTIME($reallyNow), ".$id_session.")";
(access_user_id,access_cours_code,access_date, access_session_id)
VALUES
(".$user_id.", '".$_cid."', FROM_UNIXTIME($reallyNow), ".$id_session.")";
$res = Database::query($sql);
}
// end "what's new" notification
@ -177,16 +177,8 @@ function event_access_tool($tool, $id_session=0)
global $_configuration;
global $_course;
global $TABLETRACK_LASTACCESS; //for "what's new" notification
if(api_get_setting('use_session_mode')=='true' && isset($_SESSION['id_session']))
{
$id_session = intval($_SESSION['id_session']);
}
else
{
$id_session = 0;
}
$id_session = api_get_session_id();
$reallyNow = time();
$user_id = $_user['user_id'] ? "'".$_user['user_id']."'" : "0"; // no one
// record information
@ -198,29 +190,33 @@ function event_access_tool($tool, $id_session=0)
$pos2 = strpos(strtolower($_SERVER['HTTP_REFERER']), strtolower($_configuration['root_web']."index"));
// end "what's new" notification
if ($_configuration['tracking_enabled'] && ($pos !== false || $pos2 !== false)) {
$sql = "INSERT INTO ".$TABLETRACK_ACCESS."
(access_user_id,
access_cours_code,
access_tool,
access_date)
VALUES
(".$user_id.",".// Don't add ' ' around value, it's already done.
$sql = "INSERT INTO ".$TABLETRACK_ACCESS."
(access_user_id,
access_cours_code,
access_tool,
access_date,
access_session_id
)
VALUES
(".$user_id.",".// Don't add ' ' around value, it's already done.
"'".$_cid."' ,
'".htmlspecialchars($tool, ENT_QUOTES)."',
FROM_UNIXTIME(".$reallyNow."))";
FROM_UNIXTIME(".$reallyNow."),
'".$id_session."')";
$res = Database::query($sql);
}
// "what's new" notification
$sql = " UPDATE $TABLETRACK_LASTACCESS
SET access_date = FROM_UNIXTIME($reallyNow)
WHERE access_user_id = ".$user_id." AND access_cours_code = '".$_cid."' AND access_tool = '".htmlspecialchars($tool, ENT_QUOTES)."' AND access_session_id=".$id_session;
$sql = "UPDATE $TABLETRACK_LASTACCESS
SET access_date = FROM_UNIXTIME($reallyNow)
WHERE access_user_id = ".$user_id." AND access_cours_code = '".$_cid."' AND access_tool = '".htmlspecialchars($tool, ENT_QUOTES)."' AND access_session_id=".$id_session;
$res = Database::query($sql);
if (Database::affected_rows() == 0)
{
$sql = "INSERT INTO $TABLETRACK_LASTACCESS
(access_user_id,access_cours_code,access_tool, access_date, access_session_id)
VALUES
(".$user_id.", '".$_cid."' , '".htmlspecialchars($tool, ENT_QUOTES)."', FROM_UNIXTIME($reallyNow), $id_session)";
(access_user_id,access_cours_code,access_tool, access_date, access_session_id)
VALUES
(".$user_id.", '".$_cid."' , '".htmlspecialchars($tool, ENT_QUOTES)."', FROM_UNIXTIME($reallyNow), $id_session)";
$res = Database::query($sql);
}
return 1;

Loading…
Cancel
Save