Exemplo n.º 1
0
$navigation = array(array('name' => $blockname, 'link' => '', 'type' => 'title'), array('name' => $heading_main, 'link' => '', 'type' => 'title'));
// Some javascript
require_js($CFG->wwwroot . '/blocks/student_gradeviewer/functions.js');
// Start of the form output
print_header_simple($heading_main, '', build_navigation($navigation));
// An empty prequery and no admin means that they have no association
list($table, $prequery) = get_pre_query($USER->id);
if (empty($prequery) && !has_capability('block/student_gradeviewer:academicadmin', $context) && !has_capability('block/student_gradeviewer:sportsadmin', $context)) {
    echo '<div class="results">' . get_string('no_mentees', 'block_student_gradeviewer') . '<div>';
    print_footer();
    die;
}
// Used for paging the results
$per_page = optional_param('per_page', 10, PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
$components = cps_user_component::build_components();
if ($viewsports) {
    $components->components[] = new sports_drop_down(cps_transform_filter('sports'));
}
// Per page selector
$components->components[] = new results_drop_down($per_page);
$components->display_as_table($heading_main);
$where = $components->where_clause();
// Do a prequery to figure out if the table doesn't just print out
$threshold = get_config('', 'block_student_gradeviewer_threshold');
//Running a count on the pre query info
if (!empty($prequery) && empty($where)) {
    $sql = "SELECT COUNT(u.id) FROM {$CFG->prefix}block_courseprefs_users u {$table} WHERE " . $prequery;
    $count = count_records_sql($sql);
} else {
    $count = $threshold;