diff --git a/main/admin/statistics/statistics.lib.php b/main/admin/statistics/statistics.lib.php index 433766d4ad..63b5fa51a6 100644 --- a/main/admin/statistics/statistics.lib.php +++ b/main/admin/statistics/statistics.lib.php @@ -144,6 +144,7 @@ class Statistics { $track_e_default = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT); $table_user = Database::get_main_table(TABLE_MAIN_USER); $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); + $table_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); $current_url_id = api_get_current_access_url_id(); $column = intval($column); @@ -159,7 +160,8 @@ class Statistics { "default_value_type as col1, ". "default_value as col2, ". "user.username as col3, ". - "default_date as col4 ". + "user.user_id as col4, ". + "default_date as col5 ". "FROM $track_e_default as track_default, $table_user as user, $access_url_rel_user_table as url ". "WHERE track_default.default_user_id = user.user_id AND url.user_id=user.user_id AND access_url_id='".$current_url_id."'"; } else { @@ -168,7 +170,8 @@ class Statistics { "default_value_type as col1, ". "default_value as col2, ". "user.username as col3, ". - "default_date as col4 ". + "user.user_id as col4, ". + "default_date as col5 ". "FROM $track_e_default track_default, $table_user user ". "WHERE track_default.default_user_id = user.user_id "; } @@ -181,7 +184,7 @@ class Statistics { if (!empty($column) && !empty($direction)) { $sql .= " ORDER BY col$column $direction"; } else { - $sql .= " ORDER BY col4 DESC "; + $sql .= " ORDER BY col5 DESC "; } $sql .= " LIMIT $from,$number_of_items "; @@ -203,6 +206,16 @@ class Statistics { } else { $row['default_date'] = '-'; } + if (!empty($row[4])) { //user ID + $row[3] = Display::url($row[3],api_get_path(WEB_CODE_PATH).'admin/user_information?user_id='.$row[5], array('title' => get_lang('UserInfo'))); + $sql_ip = "SELECT login_date, login_ip FROM $table_login WHERE login_user_id = ".$row[4]." AND login_date < '".$row[5]."' ORDER BY login_date DESC LIMIT 1"; + $row[4] = get_lang('Unknown'); + $res_ip = Database::query($sql_ip); + if ($res_ip !== false && Database::num_rows($res_ip)>0) { + $row_ip = Database::fetch_row($res_ip); + $row[4] = Display::url($row_ip[1], 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1], array('title'=>get_lang('TraceIP'), 'target'=>'_blank')); + } + } $activities[] = $row; } return $activities; @@ -496,7 +509,7 @@ class Statistics { $form->display(); echo ''; - $table = new SortableTable('activities', array('Statistics','get_number_of_activities'), array('Statistics','get_activities_data'),4,50,'DESC'); + $table = new SortableTable('activities', array('Statistics','get_number_of_activities'), array('Statistics','get_activities_data'),5,50,'DESC'); $parameters = array(); $parameters['report'] = 'activities'; @@ -509,7 +522,8 @@ class Statistics { $table->set_header(1, get_lang('DataType')); $table->set_header(2, get_lang('Value')); $table->set_header(3, get_lang('UserName')); - $table->set_header(4, get_lang('Date')); + $table->set_header(4, get_lang('IPAddress')); + $table->set_header(5, get_lang('Date')); $table->display(); }