Added sessions count to data reporting to Chamilo Association, to know how many portals are actually using sessions

1.9.x
Yannick Warnier 11 years ago
parent 13b2328926
commit 48d356fe15
  1. 2
      main/admin/index.php
  2. 17
      main/admin/statistics/statistics.lib.php

@ -385,6 +385,7 @@ function check_system_version() {
// The number of users // The number of users
$number_of_users = Statistics::count_users(); $number_of_users = Statistics::count_users();
$number_of_active_users = Statistics::count_users(null,null,null,true); $number_of_active_users = Statistics::count_users(null,null,null,true);
$number_of_sessions = Statistics::count_sessions();
$data = array( $data = array(
'url' => api_get_path(WEB_PATH), 'url' => api_get_path(WEB_PATH),
@ -394,6 +395,7 @@ function check_system_version() {
'numberofcourses' => $number_of_courses, 'numberofcourses' => $number_of_courses,
'numberofusers' => $number_of_users, 'numberofusers' => $number_of_users,
'numberofactiveusers' => $number_of_active_users, 'numberofactiveusers' => $number_of_active_users,
'numberofsessions' => $number_of_sessions,
//The donotlistcampus setting recovery should be improved to make //The donotlistcampus setting recovery should be improved to make
// it true by default - this does not affect numbers counting // it true by default - this does not affect numbers counting
'donotlistcampus' => api_get_setting('donotlistcampus'), 'donotlistcampus' => api_get_setting('donotlistcampus'),

@ -109,6 +109,23 @@ class Statistics {
return $obj->number; return $obj->number;
} }
/**
* Count sessions
* @return int Number of sessions counted
*/
static function count_sessions() {
$session_table = Database :: get_main_table(TABLE_MAIN_SESSION);
$access_url_rel_session_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
if (api_is_multiple_url_enabled()) {
$current_url_id = api_get_current_access_url_id();
$sql = "SELECT COUNT(id) AS number FROM ".$session_table." as s, ".$access_url_rel_session_table." as u WHERE u.session_id=s.id AND access_url_id='".$current_url_id."'";
} else {
$sql = "SELECT COUNT(id) AS number FROM ".$session_table." ";
}
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->number;
}
/** /**
* Count activities from track_e_default_table * Count activities from track_e_default_table
* @return int Number of activities counted * @return int Number of activities counted

Loading…
Cancel
Save