static $isteacher;
$context = get_context_instance(CONTEXT_COURSE, $course->id);
+
if (empty($string)) { // Cache all the strings for the rest of the page
$string->email = get_string('email');
}
/// Get the hidden field list
- if (has_capability('moodle/course:viewhiddenuserfields', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ if (has_capability('moodle/course:viewhiddenuserfields', $context)) {
$hiddenfields = array();
} else {
$hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
if (!empty($user->role) and ($user->role <> $course->teacher)) {
$output .= $string->role .': '. $user->role .'<br />';
}
- if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category and !isguest()) or has_capability('moodle/course:viewhiddenuserfields', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category and !isguest()) or
+has_capability('moodle/course:viewhiddenuserfields', $context)) {
$output .= $string->email .': <a href="mailto:'. $user->email .'">'. $user->email .'</a><br />';
}
if (($user->city or $user->country) and (!isset($hiddenfields['city']) or !isset($hiddenfields['country']))) {
$output .= '<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$user->id.'">'.get_string('blogs','blog').'</a><br />';
}
- if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ if (has_capability('moodle/site:viewreports', $context)) {
$timemidnight = usergetmidnight(time());
$output .= '<a href="'. $CFG->wwwroot .'/course/user.php?id='. $course->id .'&user='. $user->id .'">'. $string->activity .'</a><br />';
- if (!has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID, $user->id)) or ($isadmin and !isadmin($user->id))) { // Includes admins
- if ($course->category and isteacheredit($course->id) and isstudent($course->id, $user->id)) { // Includes admins
- $output .= '<a href="'. $CFG->wwwroot .'/course/unenrol.php?id='. $course->id .'&user='. $user->id .'">'. $string->unenrol .'</a><br />';
- }
- if ($USER->id != $user->id) {
- $output .= '<a href="'. $CFG->wwwroot .'/course/loginas.php?id='. $course->id .'&user='. $user->id .'">'. $string->loginas .'</a><br />';
- }
- }
+ }
+ if (has_capability('moodle/role:assign', $context, NULL)) { // Includes admins
+ $output .= '<a href="'. $CFG->wwwroot .'/course/unenrol.php?id='. $course->id .'&user='. $user->id .'">'. $string->unenrol .'</a><br />';
+ }
+ if ($USER->id != $user->id && has_capability('moodle/user:loginas', $context)) {
+ $output .= '<a href="'. $CFG->wwwroot .'/course/loginas.php?id='. $course->id .'&user='. $user->id .'">'. $string->loginas .'</a><br />';
}
$output .= '<a href="'. $CFG->wwwroot .'/user/view.php?id='. $user->id .'&course='. $course->id .'">'. $string->fullprofile .'...</a>';
- if (!empty($messageselect) && $isteacher) {
- $output .= '<br /><input type="checkbox" name="';
- if (isteacher($course->id, $user->id)) {
- $output .= 'teacher';
- } else {
- $output .= 'user';
- }
- $output .= $user->id.'" /> ';
+ if (!empty($messageselect)) {
+ $output .= '<br /><input type="checkbox" name="user'.$user->id.'" /> ';
}
$output .= '</td></tr></table>';
$tableheaders[] = get_string('select');
}
- $table = new flexible_table('user-index-students-'.$course->id);
+ $table = new flexible_table('user-index-participants-'.$course->id);
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->sortable(true, 'lastaccess', SORT_DESC);
$table->set_attribute('cellspacing', '0');
- $table->set_attribute('id', 'students');
+ $table->set_attribute('id', 'participants');
$table->set_attribute('class', 'generaltable generalbox');
$table->set_control_variables(array(
$table->initialbars($totalcount > $perpage);
$table->pagesize($perpage, $matchcount);
- $students = get_records_sql($select.$from.$where.$wheresearch.$sort,
+ $userlist = get_records_sql($select.$from.$where.$wheresearch.$sort,
$table->get_page_start(), $table->get_page_size());
/// If there are multiple Roles in the course, then show a drop down menu for switching
//-->
</script>
';
- echo '<form action="action_redir.php" method="post" name="studentsform" onSubmit="return checksubmit(this);">';
+ echo '<form action="action_redir.php" method="post" name="participantsform" onSubmit="return checksubmit(this);">';
echo '<input type="hidden" name="returnto" value="'.$_SERVER['REQUEST_URI'].'" />';
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
}
if ($fullmode) { // Print simple listing
if ($totalcount < 1) {
- print_heading(get_string("nostudentsfound", "", $course->students));
-
+ print_heading(get_string('nothingtodisplay'));
} else {
if ($totalcount > $perpage) {
}
if ($matchcount > 0) {
- foreach ($students as $student) {
- print_user($student, $course, true);
+ foreach ($userlist as $user) {
+ print_user($user, $course, $bulkoperations);
}
} else {
} else {
$countrysort = (strpos($sort, 'country') !== false);
$timeformat = get_string('strftimedate');
- if (!empty($students)) {
- foreach ($students as $student) {
- if ($student->lastaccess) {
- $lastaccess = format_time(time() - $student->lastaccess, $datestring);
+ if (!empty($userlist)) {
+ foreach ($userlist as $user) {
+ if ($user->lastaccess) {
+ $lastaccess = format_time(time() - $user->lastaccess, $datestring);
} else {
$lastaccess = $strnever;
}
- if (empty($student->country)) {
+ if (empty($user->country)) {
$country = '';
} else {
if($countrysort) {
- $country = '('.$student->country.') '.$countries[$student->country];
+ $country = '('.$user->country.') '.$countries[$user->country];
}
else {
- $country = $countries[$student->country];
+ $country = $countries[$user->country];
}
}
$data = array (
- print_user_picture($student->id, $course->id, $student->picture, false, true),
- '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$student->id.'&course='.$course->id.'">'.fullname($student).'</a></strong>');
+ print_user_picture($user->id, $course->id, $user->picture, false, true),
+ '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id.'">'.fullname($user).'</a></strong>');
if (!isset($hiddenfields['city'])) {
- $data[] = $student->city;
+ $data[] = $user->city;
}
if (!isset($hiddenfields['country'])) {
$data[] = $country;
$data[] = $lastaccess;
}
if ($course->enrolperiod) {
- if ($student->timeend) {
- $data[] = userdate($student->timeend, $timeformat);
+ if ($user->timeend) {
+ $data[] = userdate($user->timeend, $timeformat);
} else {
$data[] = get_string('unlimited');
}
}
if ($bulkoperations) {
- $data[] = '<input type="checkbox" name="user'.$student->id.'" />';
+ $data[] = '<input type="checkbox" name="user'.$user->id.'" />';
}
$table->add_data($data);