Пример #1
0
    echo $output->render($eventSelect);
    // Show user list if the user has permission to see other people's messages
    if ($canAdminUsers) {
        $optionSet = array(0 => get_string('optionallusers', 'block_moodletxt'));
        $userList = $userDAO->getAllUsers();
        foreach ($userList as $userObj) {
            $optionSet[$userObj->getId()] = $userObj->getFullNameForDisplay();
        }
        $userSelect = new single_select(new moodle_url('sent.php', array('course' => $courseId, 'instance' => $instanceId, 'events' => $includeEvents)), 'user', $optionSet, $userToView, false);
        $userSelect->set_label(get_string('labelshowmessagesforuser', 'block_moodletxt'));
        echo $output->render($userSelect);
    }
}
// Figure out which table item the user wants to sort by
$orderBy = '';
foreach ($table->get_sort_columns() as $field => $direction) {
    switch ($field) {
        case 'user':
            $databaseOrder = 'u.lastname %DIR%, u.firstname %DIR%';
            break;
        case 'account':
            $databaseOrder = 'acc.username %DIR%';
            break;
        case 'time':
            $databaseOrder = 'o.timesent %DIR%';
            break;
    }
    if ($direction == SORT_ASC) {
        $databaseOrder = str_replace('%DIR%', 'ASC', $databaseOrder);
    } else {
        $databaseOrder = str_replace('%DIR%', 'DESC', $databaseOrder);
$count = $DB->count_records_sql($sqlcount);
if (!$showall && !$table->is_downloading()) {
    $table->pagesize($limit, $count);
}
$table->define_columns(array('id', 'name', 'module', 'identifier', 'status', 'attempts', 'action'));
$table->define_headers(array(get_string('id', 'plagiarism_urkund'), get_string('user'), get_string('module', 'plagiarism_urkund'), get_string('identifier', 'plagiarism_urkund'), get_string('status', 'plagiarism_urkund'), get_string('attempts', 'plagiarism_urkund'), ''));
$table->define_baseurl('urkund_debug.php');
$table->sortable(true);
$table->no_sorting('file', 'action');
$table->collapsible(true);
$table->set_attribute('cellspacing', '0');
$table->set_attribute('class', 'generaltable generalbox');
$table->show_download_buttons_at(array(TABLE_P_BOTTOM));
$table->setup();
// Work out direction of sort required.
$sortcolumns = $table->get_sort_columns();
// Now do sorting if specified.
$orderby = '';
if (!empty($sort)) {
    $direction = ' DESC';
    if (!empty($sortcolumns[$sort]) && $sortcolumns[$sort] == SORT_ASC) {
        $direction = ' ASC';
    }
    if ($sort == "name") {
        $orderby = " ORDER BY u.firstname {$direction}, u.lastname {$direction}";
    } else {
        if ($sort == "module") {
            $orderby = " ORDER BY cm.id {$direction}";
        } else {
            if ($sort == "status") {
                $orderby = " ORDER BY t.statuscode {$direction}";