/**
 * Prints a summary of a user in a nice little box.
 *
 * @uses $CFG
 * @uses $USER
 * @param user $user A {@link $USER} object representing a user
 * @param course $course A {@link $COURSE} object representing a course
 */
function scheduler_print_user($user, $course, $messageselect = false, $return = false)
{
    global $CFG, $USER, $OUTPUT;
    $output = '';
    static $string;
    static $datestring;
    static $countries;
    $context = context_course::instance($course->id);
    if (isset($user->context->id)) {
        $usercontext = $user->context;
    } else {
        $usercontext = context_user::instance($user->id);
    }
    if (empty($string)) {
        // Cache all the strings for the rest of the page
        $string = new stdClass();
        $string->email = get_string('email');
        $string->lastaccess = get_string('lastaccess');
        $string->activity = get_string('activity');
        $string->loginas = get_string('loginas');
        $string->fullprofile = get_string('fullprofile');
        $string->role = get_string('role');
        $string->name = get_string('name');
        $string->never = get_string('never');
        $datestring = new stdClass();
        $datestring->day = get_string('day');
        $datestring->days = get_string('days');
        $datestring->hour = get_string('hour');
        $datestring->hours = get_string('hours');
        $datestring->min = get_string('min');
        $datestring->mins = get_string('mins');
        $datestring->sec = get_string('sec');
        $datestring->secs = get_string('secs');
        $datestring->year = get_string('year');
        $datestring->years = get_string('years');
    }
    /// Get the hidden field list
    if (has_capability('moodle/course:viewhiddenuserfields', $context)) {
        $hiddenfields = array();
    } else {
        $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
    }
    $output .= '<table class="userinfobox">';
    $output .= '<tr>';
    $output .= '<td class="left side">';
    $output .= $OUTPUT->user_picture($user, array('size' => 100));
    $output .= '</td>';
    $output .= '<td class="content">';
    $output .= '<div class="username">' . fullname($user, has_capability('moodle/site:viewfullnames', $context)) . '</div>';
    $output .= '<div class="info">';
    if (!empty($user->role) and $user->role != $course->teacher) {
        $output .= $string->role . ': ' . $user->role . '<br />';
    }
    $extrafields = scheduler_get_user_fields($user);
    foreach ($extrafields as $field) {
        $output .= $field->title . ': ' . $field->value . '<br />';
    }
    if (!isset($hiddenfields['lastaccess'])) {
        if ($user->lastaccess) {
            $output .= $string->lastaccess . ': ' . userdate($user->lastaccess);
            $output .= '&nbsp; (' . format_time(time() - $user->lastaccess, $datestring) . ')';
        } else {
            $output .= $string->lastaccess . ': ' . $string->never;
        }
    }
    $output .= '</div></td><td class="links">';
    //link to blogs
    if ($CFG->bloglevel > 0) {
        $output .= '<a href="' . $CFG->wwwroot . '/blog/index.php?userid=' . $user->id . '">' . get_string('blogs', 'blog') . '</a><br />';
    }
    //link to notes
    if (!empty($CFG->enablenotes) and has_capability('moodle/notes:manage', $context) || has_capability('moodle/notes:view', $context)) {
        $output .= '<a href="' . $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&amp;user='******'">' . get_string('notes', 'notes') . '</a><br />';
    }
    if (has_capability('moodle/site:viewreports', $context) or has_capability('moodle/user:viewuseractivitiesreport', $usercontext)) {
        $output .= '<a href="' . $CFG->wwwroot . '/course/user.php?id=' . $course->id . '&amp;user='******'">' . $string->activity . '</a><br />';
    }
    $output .= '<a href="' . $CFG->wwwroot . '/user/profile.php?id=' . $user->id . '">' . $string->fullprofile . '...</a>';
    if (!empty($messageselect)) {
        $output .= '<br /><input type="checkbox" name="user' . $user->id . '" /> ';
    }
    $output .= '</td></tr></table>';
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
 echo $maildisplay;
 echo $output->box_end();
 $userfields = scheduler_get_user_fields(null);
 $fieldtitles = array();
 foreach ($userfields as $f) {
     $fieldtitles[] = $f->title;
 }
 $studtable = new scheduler_scheduling_list($scheduler, $fieldtitles);
 $studtable->id = 'studentstoschedule';
 foreach ($students as $student) {
     $picture = $output->user_picture($student);
     $name = $output->user_profile_link($scheduler, $student);
     $actions = array();
     $actions[] = new action_menu_link_secondary(new moodle_url($actionurl, array('what' => 'schedule', 'studentid' => $student->id)), new pix_icon('e/insert_date', '', 'moodle'), get_string('scheduleinslot', 'scheduler'));
     $actions[] = new action_menu_link_secondary(new moodle_url($actionurl, array('what' => 'markasseennow', 'studentid' => $student->id)), new pix_icon('t/approve', '', 'moodle'), get_string('markasseennow', 'scheduler'));
     $userfields = scheduler_get_user_fields($student);
     $fieldvals = array();
     foreach ($userfields as $f) {
         $fieldvals[] = $f->value;
     }
     $studtable->add_line($picture, $name, $fieldvals, $actions);
 }
 $divclass = 'schedulelist ' . ($scheduler->is_group_scheduling_enabled() ? 'halfsize' : 'fullsize');
 echo html_writer::start_div($divclass);
 echo $output->heading(get_string('schedulestudents', 'scheduler'), 3);
 // Print table of students who still have to make appointments.
 echo $output->render($studtable);
 echo html_writer::end_div();
 if ($scheduler->is_group_scheduling_enabled()) {
     // Print list of groups that can be scheduled.
     echo html_writer::start_div('schedulelist halfsize');