0 ) { foreach ($list_info_user_in_chat as $list_info_user) { $date_db_date = date('Y-m-d', strtotime($list_info_user['last_connection'])); $date_db_h = date('H', strtotime($list_info_user['last_connection'])); $date_db_m = date('i', strtotime($list_info_user['last_connection'])); $date_db_s = date('s', strtotime($list_info_user['last_connection'])); $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']; Database::query($sql); } } } } } /** * @param string $database_name (optional) * @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(); $extra_condition = ''; 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; }