Minor - format code, remove unused session id.

pull/2487/head
jmontoyaa 8 years ago
parent ab5dcae3f0
commit d4d25fb38a
  1. 18
      main/inc/lib/api.lib.php
  2. 41
      main/inc/lib/events.lib.php

@ -4224,7 +4224,7 @@ function api_get_track_item_property_history($tool, $ref)
* @param int $session_id
* @param int $groupId
*
* @return array Array with all fields from c_item_property, empty array if not found or false if course could not be found
* @return array with all fields from c_item_property, empty array if not found or false if course could not be found
*/
function api_get_item_property_info($course_id, $tool, $ref, $session_id = 0, $groupId = 0)
{
@ -4397,9 +4397,6 @@ function api_display_language_form($hide_if_no_choice = false, $showAsButton = f
$html .= '</div>';
}
//$html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
//$html .= '</form>';
return $html;
}
@ -4546,24 +4543,25 @@ function api_get_language_from_type($lang_type)
switch ($lang_type) {
case 'platform_lang':
$temp_lang = api_get_setting('platformLanguage');
if (!empty($temp_lang))
if (!empty($temp_lang)) {
$return = $temp_lang;
}
break;
case 'user_profil_lang':
$_user = api_get_user_info();
if (isset($_user['language']) && !empty($_user['language']))
if (isset($_user['language']) && !empty($_user['language'])) {
$return = $_user['language'];
}
break;
case 'user_selected_lang':
if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice']))
if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice'])) {
$return = $_SESSION['user_language_choice'];
}
break;
case 'course_lang':
global $_course;
$cidReq = null;
if (empty($_course)) {
// Code modified because the local.inc.php file it's declarated after this work
// causing the function api_get_course_info() returns a null value
$cidReq = isset($_GET["cidReq"]) ? Database::escape_string($_GET["cidReq"]) : null;
@ -4589,7 +4587,7 @@ function api_get_language_from_type($lang_type)
break;
default:
$return = false;
break;
break;
}
return $return;

@ -144,7 +144,7 @@ class Event
*
* $tool can take this values :
* Links, Calendar, Document, Announcements,
* Group, Video, Works, Users, Exercices, Course Desc
* Group, Video, Works, Users, Exercises, Course Desc
* ...
* Values can be added if new modules are created (15char max)
* I encourage to use $nameTool as $tool when calling this function
@ -152,22 +152,28 @@ class Event
* Functionality for "what's new" notification is added by Toon Van Hoecke
* @return bool
*/
public static function event_access_tool($tool, $id_session = 0)
public static function event_access_tool($tool)
{
$tool = Database::escape_string($tool);
if (empty($tool)) {
return false;
}
$TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
//for "what's new" notification
$TABLETRACK_LASTACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$_course = api_get_course_info();
$courseId = api_get_course_int_id();
$id_session = api_get_session_id();
$tool = Database::escape_string($tool);
$sessionId = api_get_session_id();
$reallyNow = api_get_utc_datetime();
$user_id = api_get_user_id();
if (empty($_course)) {
return false;
}
$tableAccess = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
//for "what's new" notification
$tableLastAccess = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
// record information
// only if user comes from the course $_cid
//if( eregi($_configuration['root_web'].$_cid,$_SERVER['HTTP_REFERER'] ) )
@ -177,6 +183,7 @@ class Event
$pos = isset($_SERVER['HTTP_REFERER']) ? strpos(strtolower($_SERVER['HTTP_REFERER']), strtolower(api_get_path(WEB_COURSE_PATH).$coursePath)) : false;
// added for "what's new" notification
$pos2 = isset($_SERVER['HTTP_REFERER']) ? strpos(strtolower($_SERVER['HTTP_REFERER']), strtolower(api_get_path(WEB_PATH)."index")) : false;
// end "what's new" notification
if ($pos !== false || $pos2 !== false) {
$params = [
@ -184,25 +191,31 @@ class Event
'c_id' => $courseId,
'access_tool' => $tool,
'access_date' => $reallyNow,
'access_session_id' => $id_session,
'access_session_id' => $sessionId,
'user_ip' => api_get_real_ip()
];
Database::insert($TABLETRACK_ACCESS, $params);
Database::insert($tableAccess, $params);
}
// "what's new" notification
$sql = "UPDATE $TABLETRACK_LASTACCESS
$sql = "UPDATE $tableLastAccess
SET access_date = '$reallyNow'
WHERE
access_user_id = ".$user_id." AND
c_id = '".$courseId."' AND
access_tool = '".$tool."' AND
access_session_id=".$id_session;
access_session_id=".$sessionId;
$result = Database::query($sql);
if (Database::affected_rows($result) == 0) {
$sql = "INSERT INTO $TABLETRACK_LASTACCESS (access_user_id, c_id, access_tool, access_date, access_session_id)
VALUES (".$user_id.", '".$courseId."' , '$tool', '$reallyNow', $id_session)";
Database::query($sql);
$params = [
'access_user_id' => $user_id,
'c_id' => $courseId,
'access_tool' => $tool,
'access_date' => $reallyNow,
'access_session_id' => $sessionId
];
Database::insert($tableLastAccess, $params);
}
return true;
}

Loading…
Cancel
Save