Replace NOW() by api_get_utc_datetime()

1.10.x
Yannick Warnier 10 years ago
parent 5f7d105aa7
commit df958828f8
  1. 3
      main/chat/chat_chat.php
  2. 19
      whoisonlinesession.php

@ -54,8 +54,9 @@ if (!empty($course)) {
// Save chat files document for group into item property
if (!empty($group_id)) {
$doc_id = add_document($_course, $basepath_chat, 'folder', 0, 'chat_files');
$now = api_get_utc_datetime();
$sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, 'document',1,NOW(),NOW(),$doc_id,'FolderCreated',1,$group_id,NULL,0)";
VALUES ($course_id, 'document',1,'$now','$now',$doc_id,'FolderCreated',1,$group_id,NULL,0)";
Database::query($sql);
}
}

@ -63,21 +63,30 @@ Display::display_header(get_lang('UserOnlineListSession'));
$session_is_coach[$session['id']] = $session;
}
$result = Database::query("SELECT DISTINCT id,
$sql = "SELECT DISTINCT id,
name,
date_start,
date_end
FROM $tbl_session as session
WHERE session.id_coach = ".$_user['user_id']."
ORDER BY date_start, date_end, name");
ORDER BY date_start, date_end, name";
$result = Database::query($sql);
while ($session = Database:: fetch_array($result)) {
$session_is_coach[$session['id']] = $session;
}
if (empty($time_limit)) {
$time_limit = api_get_setting('time_limit_whosonline');
} else {
$time_limit = 60;
}
$online_time = time() - $time_limit*60;
$current_date = api_get_utc_datetime($online_time);
$students_online = array();
foreach ($session_is_coach as $session) {
$sql = "SELECT DISTINCT
last_access.access_user_id,
$sql = "SELECT DISTINCT last_access.access_user_id,
last_access.access_date,
last_access.c_id,
last_access.access_session_id,
@ -87,7 +96,7 @@ Display::display_header(get_lang('UserOnlineListSession'));
INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." AS user
ON user.user_id = last_access.access_user_id
WHERE access_session_id='".$session['id']."'
AND NOW()-access_date<1000
AND access_date >= '$current_date'
GROUP BY access_user_id";
$result = Database::query($sql);

Loading…
Cancel
Save