示例#1
0
/**
 * Finds all the information about a user. If no paramater is passed you find all the information about the current user.
 * @param $user_id (integer): the id of the user
 * @return $user_info (array): user_id, lastname, firstname, username, email, ...
 * @author Patrick Cool <*****@*****.**>
 * @version 21 September 2004
 */
function api_get_user_info($user_id = '', $check_if_user_is_online = false, $show_password = false, $add_extra_values = false)
{
    if (empty($user_id)) {
        $_user = Session::read('_user');
        return api_format_user($_user);
    }
    $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_USER) . " WHERE user_id = '" . Database::escape_string($user_id) . "'";
    $result = Database::query($sql);
    if (Database::num_rows($result) > 0) {
        $result_array = Database::fetch_array($result);
        if ($check_if_user_is_online) {
            $use_status_in_platform = Online::user_is_online($user_id);
            $result_array['user_is_online'] = $use_status_in_platform;
            $user_online_in_chat = 0;
            if ($use_status_in_platform) {
                $user_status = UserManager::get_extra_user_data_by_field($user_id, 'user_chat_status', false, true);
                if (intval($user_status['user_chat_status']) == 1) {
                    $user_online_in_chat = 1;
                }
            }
            $result_array['user_is_online_in_chat'] = $user_online_in_chat;
        }
        $user = api_format_user($result_array, $show_password);
        if ($add_extra_values) {
            $extra_field_values = new ExtraField('user');
            $user['extra_fields'] = $extra_field_values->get_handler_extra_data($user_id);
        }
        return $user;
    }
    return false;
}
示例#2
0
 echo '<a href="javascript: window.back();" ">' . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>';
 echo '<a href="javascript: void(0);" onclick="javascript: window.print();">' . Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM) . '</a>';
 echo '<a href="' . api_get_self() . '?' . Security::remove_XSS($_SERVER['QUERY_STRING']) . '&export=csv">' . Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM) . '</a> ';
 if (!empty($user_info['email'])) {
     $send_mail = '<a href="mailto:' . $user_info['email'] . '">' . Display::return_icon('mail_send.png', get_lang('SendMail'), '', ICON_SIZE_MEDIUM) . '</a>';
 } else {
     $send_mail = Display::return_icon('mail_send_na.png', get_lang('SendMail'), '', ICON_SIZE_MEDIUM);
 }
 echo $send_mail;
 if (!empty($student_id) && !empty($_GET['course'])) {
     //only show link to connection details if course and student were defined in the URL
     echo '<a href="access_details.php?student=' . $student_id . '&course=' . $courseId . '&amp;origin=' . Security::remove_XSS($_GET['origin']) . '&amp;cidReq=' . Security::remove_XSS($_GET['course']) . '&amp;id_session=' . $session_id . '">' . Display::return_icon('statistics.png', get_lang('AccessDetails'), '', ICON_SIZE_MEDIUM) . '</a>';
 }
 echo '</div>';
 // is the user online ?
 if (Online::user_is_online($_GET['student'])) {
     $online = get_lang('Yes');
 } else {
     $online = get_lang('No');
 }
 // get average of score and average of progress by student
 $avg_student_progress = $avg_student_score = 0;
 $courseId = $courseInfo['real_id'];
 if (!CourseManager::is_user_subscribed_in_course($user_info['user_id'], $courseId, true)) {
     unset($courses[$key]);
 } else {
     $avg_student_progress = Tracking::get_avg_student_progress($user_info['user_id'], $courseId, array(), $session_id);
     //the score inside the Reporting table
     $avg_student_score = Tracking::get_avg_student_score($user_info['user_id'], $courseId, array(), $session_id);
     //var_dump($avg_student_score);
 }