& instead of & in participants list base url (from last commit - make participant...
[moodle.git] / user / index.php
CommitLineData
f9903ed0 1<?PHP // $Id$
2
3// Lists all the users within a given course
4
cc038b47 5 require_once('../config.php');
68b38e8d 6 require_once($CFG->libdir.'/tablelib.php');
951b22a8 7
8 define('USER_SMALL_CLASS', 20); // Below this is considered small
9 define('USER_LARGE_CLASS', 200); // Above this is considered large
cc038b47 10 define('DEFAULT_PAGE_SIZE', 20);
f9903ed0 11
cc038b47 12 $id = required_param('id', PARAM_INT); // Course id
13 $group = optional_param('group', -1, PARAM_INT); // Group to show
14 $page = optional_param('page', 0, PARAM_INT); // which page to show
15 $perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT); // how many per page
16 $mode = optional_param('mode', NULL); // '0' for less details, '1' for more
17 $showteachers = optional_param('teachers', 1, PARAM_INT); // do we want to see the teacher list?
31b71336 18 $accesssince = optional_param('accesssince',0,PARAM_INT); // filter by last access. -1 = never
f1e24e7a 19 $search = optional_param('search','',PARAM_TEXT);
20
21 $showteachers = $showteachers && empty($search); // if we're searching, we just want students.
cc038b47 22
23 if (! $course = get_record('course', 'id', $id)) {
f9903ed0 24 error("Course ID is incorrect");
25 }
26
27 require_login($course->id);
28
4bc162b7 29 if (!$course->category) {
30 if (!$CFG->showsiteparticipantslist and !isteacher(SITEID)) {
31 notice(get_string('sitepartlist0'));
32 }
9407d456 33 if ($CFG->showsiteparticipantslist < 2 and !isteacherinanycourse()) {
4bc162b7 34 notice(get_string('sitepartlist1'));
35 }
36 }
37
cc038b47 38 add_to_log($course->id, 'user', 'view all', 'index.php?id='.$course->id, '');
f9903ed0 39
951b22a8 40 $isteacher = isteacher($course->id);
4969ad74 41
f1e24e7a 42 if (empty($isteacher)) {
43 $search = false;
44 }
45
68b38e8d 46 $countries = get_list_of_countries();
47
cc038b47 48 $strnever = get_string('never');
68b38e8d 49
cc038b47 50 $datestring->day = get_string('day');
51 $datestring->days = get_string('days');
52 $datestring->hour = get_string('hour');
53 $datestring->hours = get_string('hours');
54 $datestring->min = get_string('min');
55 $datestring->mins = get_string('mins');
56 $datestring->sec = get_string('sec');
57 $datestring->secs = get_string('secs');
d578afc8 58
ff3caf30 59 if ($mode !== NULL) {
60 $SESSION->userindexmode = $fullmode = ($mode == 1);
61 } else if (isset($SESSION->userindexmode)) {
62 $fullmode = $SESSION->userindexmode;
63 } else {
64 $fullmode = false;
65 }
66
ff3caf30 67/// Check to see if groups are being used in this forum
68/// and if so, set $currentgroup to reflect the current group
69
ff3caf30 70 $groupmode = groupmode($course); // Groups are being used
cc038b47 71 $currentgroup = get_and_set_current_group($course, $groupmode, $group);
ff3caf30 72
cc038b47 73 if (!$currentgroup) { // To make some other functions work better later
74 $currentgroup = NULL;
75 }
ff3caf30 76
4bc162b7 77 $isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and
2cb2ce61 78 !isteacheredit($course->id));
79
ff3caf30 80 if ($isseparategroups and (!$currentgroup) ) { //XXX
81 print_heading(get_string("notingroup", "forum"));
82 print_footer($course);
83 exit;
84 }
85
cc038b47 86 // Should use this variable so that we don't break stuff every time a variable is added or changed.
e4103b6a 87 $baseurl = $CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$currentgroup.'&amp;perpage='.$perpage.'&amp;teachers='.$showteachers.'&amp;accesssince='.$accesssince.'&amp;search='.$search;
ff3caf30 88
89/// Print headers
2cb2ce61 90
4969ad74 91 if ($course->category) {
cc038b47 92 print_header("$course->shortname: ".get_string('participants'), $course->fullname,
031c49fa 93 "<a href=\"../course/view.php?id=$course->id\">$course->shortname</a> -> ".
cc038b47 94 get_string('participants'), "", "", true, "&nbsp;", navmenu($course));
dc0dc7d5 95 } else {
cc038b47 96 print_header("$course->shortname: ".get_string('participants'), $course->fullname,
97 get_string('participants'), "", "", true, "&nbsp;", navmenu($course));
4969ad74 98 }
99
ff3caf30 100/// Print settings and things in a table across the top
101
cc038b47 102 echo '<table class="controls" cellspacing="0"><tr>';
ff3caf30 103
104 if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) {
105 if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
106 echo '<td class="left">';
cc038b47 107 print_group_menu($groups, $groupmode, $currentgroup, $baseurl);
ff3caf30 108 echo '</td>';
109 }
110 }
111
31b71336 112 // get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
113 $minlastaccess = get_field_sql('SELECT min(timeaccess) FROM '.$CFG->prefix.'user_students WHERE course = '.$course->id.' AND timeaccess != 0');
114
115 $lastaccess0exists = record_exists('user_students','course',$course->id,'timeaccess',0);
116 $now = usergetmidnight(time());
117 $timeaccess = array();
118
119 // makes sense for this to go first.
120 $timeoptions[0] = get_string('selectperiod');
121
122 // days
123 for ($i = 1; $i < 7; $i++) {
124 if (strtotime('-'.$i.' days',$now) >= $minlastaccess) {
125 $timeoptions[strtotime('-'.$i.' days',$now)] = get_string('numdays','moodle',$i);
126 }
127 }
128 // weeks
129 for ($i = 1; $i < 10; $i++) {
130 if (strtotime('-'.$i.' weeks',$now) >= $minlastaccess) {
131 $timeoptions[strtotime('-'.$i.' weeks',$now)] = get_string('numweeks','moodle',$i);
132 }
133 }
134 // months
135 for ($i = 2; $i < 12; $i++) {
136 if (strtotime('-'.$i.' months',$now) >= $minlastaccess) {
137 $timeoptions[strtotime('-'.$i.' months',$now)] = get_string('nummonths','moodle',$i);
138 }
139 }
140 // try a year
141 if (strtotime('-1 year',$now) >= $minlastaccess) {
142 $timeoptions[strtotime('-1 year',$now)] = get_string('lastyear');
143 }
144
145 if (!empty($lastaccess0exists)) {
146 $timeoptions[-1] = get_string('never');
147 }
148
149 if (count($timeoptions) > 1) {
150 echo '<td class="left">';
151 echo get_string('usersnoaccesssince').': ';
152 $baseurl = preg_replace('/&amp;accesssince='.$accesssince.'/','',$baseurl);
153 echo popup_form($baseurl.'&amp;accesssince=',$timeoptions,'timeoptions',$accesssince,'','','',true);
154 echo '</td>';
155 }
156
cc038b47 157 echo '<td class="right">';
4bc162b7 158 echo get_string('userlist').': ';
ff3caf30 159 $formatmenu = array( '0' => get_string('detailedless'),
160 '1' => get_string('detailedmore'));
cc038b47 161 echo popup_form($baseurl.'&amp;mode=', $formatmenu, 'formatmenu', $fullmode, '', '', '', true);
ff3caf30 162 echo '</td></tr></table>';
163
164 if ($currentgroup and (!$isseparategroups or isteacheredit($course->id))) { /// Display info about the group
165 if ($group = get_record('groups', 'id', $currentgroup)) {
166 if (!empty($group->description) or (!empty($group->picture) and empty($group->hidepicture))) {
167 echo '<table class="groupinfobox"><tr><td class="left side picture">';
168 print_group_picture($group, $course->id, true, false, false);
169 echo '</td><td class="content">';
170 echo '<h3>'.$group->name;
2c27cd19 171 if (isteacheredit($course->id)) {
172 echo '&nbsp;<a title="'.get_string('editgroupprofile').'" href="../course/groups.php?id='.$course->id.'&amp;group='.$group->id.'">';
173 echo '<img src="'.$CFG->pixpath.'/t/edit.gif" alt="" border="0">';
174 echo '</a>';
175 }
ff3caf30 176 echo '</h3>';
177 echo format_text($group->description);
178 echo '</td></tr></table>';
179 }
180 }
181 }
182
4bc162b7 183
cc038b47 184 $exceptions = array(); // This will be an array of userids that are shown as teachers and thus
185 // do not have to be shown as users as well. Only relevant on site course.
68b38e8d 186
187 if($showteachers) {
188
68b38e8d 189 $tablecolumns = array('picture', 'fullname', 'city', 'country', 'lastaccess');
190 $tableheaders = array('', get_string('fullname'), get_string('city'), get_string('country'), get_string('lastaccess'));
191
e5ada99f 192 $table = new flexible_table('user-index-teachers-'.$course->id);
68b38e8d 193
194 $table->define_columns($tablecolumns);
195 $table->define_headers($tableheaders);
cc038b47 196 $table->define_baseurl($baseurl);
68b38e8d 197
a5a3f48a 198 $table->sortable(true, 'lastaccess', SORT_DESC);
68b38e8d 199
200 $table->set_attribute('cellspacing', '0');
201 $table->set_attribute('id', 'teachers');
202 $table->set_attribute('class', 'generaltable generalbox');
203
204 $table->setup();
205
206 if($whereclause = $table->get_sql_where()) {
207 $whereclause .= ' AND ';
208 }
209
210 $teachersql = "SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest,
cc038b47 211 u.email, u.maildisplay, u.city, u.country, u.lastlogin, u.picture, u.lang, u.timezone,
68b38e8d 212 u.emailstop, t.authority,t.role,t.editall,t.timeaccess as lastaccess, m.groupid
213 FROM {$CFG->prefix}user u
214 LEFT JOIN {$CFG->prefix}user_teachers t ON t.userid = u.id
215 LEFT JOIN {$CFG->prefix}groups_members m ON m.userid = u.id ";
216
217 if($isseparategroups) {
218 $whereclause .= '(t.editall OR groupid = '.$currentgroup.') AND ';
219 }
220 else if ($currentgroup) { // Displaying a group by choice
221 $whereclause .= 'groupid = '.$currentgroup.' AND ';
222 }
223
224 $teachersql .= 'WHERE '.$whereclause.' t.course = '.$course->id.' AND u.deleted = 0 AND u.confirmed = 1 AND t.authority > 0';
225
31b71336 226 $teachersql .= get_lastaccess_sql($accesssince);
227
68b38e8d 228 if($sortclause = $table->get_sql_sort()) {
229 $teachersql .= ' ORDER BY '.$sortclause;
230 }
231
232 $teachers = get_records_sql($teachersql);
233
234 if(!empty($teachers)) {
235
cc038b47 236 echo '<h2>'.$course->teachers;
237 echo ' <a href="'.$baseurl.'&amp;teachers=0">';
238 echo '<img src="'.$CFG->pixpath.'/i/hide.gif" height="16" width="16" alt="'.get_string('hide').'" /></a>';
ec99b88e 239 if (isadmin() or ($course->category and (iscreator() or (isteacheredit($course->id) and !empty($CFG->teacherassignteachers))))) {
cc038b47 240 echo ' <a href="'.$CFG->wwwroot.'/course/teacher.php?id='.$course->id.'">';
241 echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="'.get_string('edit').'" /></a>';
03f191ad 242 }
243 echo '</h2>';
480dda61 244
cc038b47 245 $exceptions = array_keys($teachers);
68b38e8d 246
ff3caf30 247 if ($fullmode) {
248 foreach ($teachers as $key => $teacher) {
249 print_user($teacher, $course);
4969ad74 250 }
ff3caf30 251 } else {
bf845f2b 252 $countrysort = (strpos($sortclause, 'country') !== false);
68b38e8d 253 foreach ($teachers as $teacher) {
254
255 if ($teacher->lastaccess) {
256 $lastaccess = format_time(time() - $teacher->lastaccess, $datestring);
257 } else {
258 $lastaccess = $strnever;
259 }
bf845f2b 260
261 if (empty($teacher->country)) {
262 $country = '';
263 }
264 else {
265 if($countrysort) {
266 $country = '('.$teacher->country.') '.$countries[$teacher->country];
267 }
268 else {
269 $country = $countries[$teacher->country];
270 }
271 }
68b38e8d 272
273 $table->add_data(array (
274 //'<input type="checkbox" name="userid[]" value="'.$teacher->id.'" />',
275 print_user_picture($teacher->id, $course->id, $teacher->picture, false, true),
276 '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&amp;course='.$course->id.'">'.fullname($teacher, $isteacher).'</a></strong>',
277 $teacher->city,
bf845f2b 278 $country,
68b38e8d 279 $lastaccess));
280 }
cc038b47 281
282 $table->print_html();
4969ad74 283 }
284 }
dc0dc7d5 285 }
cc038b47 286 else {
287 // Don't show teachers
288 echo '<h2>'.$course->teachers;
289 echo ' <a href="'.$baseurl.'&amp;teachers=1">';
290 echo '<img src="'.$CFG->pixpath.'/i/show.gif" height="16" width="16" alt="'.get_string('show').'" /></a>';
291 if (isadmin() or ($course->category and (iscreator() or (isteacheredit($course->id) and !empty($CFG->teacherassignteachers))))) {
292 echo ' <a href="'.$CFG->wwwroot.'/course/teacher.php?id='.$course->id.'">';
293 echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="'.get_string('edit').'" /></a>';
62b80756 294 }
cc038b47 295 echo '</h2>';
2cb2ce61 296 }
a328425d 297
cc038b47 298 $guest = get_guest();
299 $exceptions[] = $guest->id;
300
6746bb8a 301 $tablecolumns = array('picture', 'fullname', 'city', 'country', 'lastaccess');
302 $tableheaders = array('', get_string('fullname'), get_string('city'), get_string('country'), get_string('lastaccess'));
303
304 if ($course->enrolperiod) {
305 $tablecolumns[] = 'timeend';
306 $tableheaders[] = get_string('enrolmentend');
307 }
308
309 if ($isteacher) {
310 $tablecolumns[] = '';
311 $tableheaders[] = get_string('select');
312 }
cc038b47 313
e5ada99f 314 $table = new flexible_table('user-index-students-'.$course->id);
cc038b47 315
316 $table->define_columns($tablecolumns);
317 $table->define_headers($tableheaders);
318 $table->define_baseurl($baseurl);
319
a5a3f48a 320 $table->sortable(true, 'lastaccess', SORT_DESC);
cc038b47 321
322 $table->set_attribute('cellspacing', '0');
323 $table->set_attribute('id', 'students');
324 $table->set_attribute('class', 'generaltable generalbox');
325
326 $table->set_control_variables(array(
327 TABLE_VAR_SORT => 'ssort',
328 TABLE_VAR_HIDE => 'shide',
329 TABLE_VAR_SHOW => 'sshow',
330 TABLE_VAR_IFIRST => 'sifirst',
331 TABLE_VAR_ILAST => 'silast',
332 TABLE_VAR_PAGE => 'spage'
333 ));
334 $table->setup();
335
336 if(SITEID == $course->id) {
337 $select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country,
338 u.picture, u.lang, u.timezone, u.emailstop, u.maildisplay, u.lastaccess ';
339 $from = 'FROM '.$CFG->prefix.'user u ';
340 $where = 'WHERE confirmed = 1 AND u.deleted = 0 ';
03f191ad 341 }
cc038b47 342 else {
343 $select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country,
344 u.picture, u.lang, u.timezone, u.emailstop, u.maildisplay, s.timeaccess AS lastaccess ';
6746bb8a 345 $select .= $course->enrolperiod?', s.timeend ':'';
cc038b47 346 $from = 'FROM '.$CFG->prefix.'user u LEFT JOIN '.$CFG->prefix.'user_students s ON s.userid = u.id ';
347 $where = 'WHERE s.course = '.$course->id.' AND u.deleted = 0 ';
69ec0a8b 348 }
349
31b71336 350 $where .= get_lastaccess_sql($accesssince);
351
f1e24e7a 352 if (!empty($search)) {
353 $LIKE = sql_ilike();
354 $fullname = sql_fullname('u.firstname','u.lastname');
355 $wheresearch .= ' AND ('. $fullname .' '. $LIKE .'\'%'. $search .'%\' OR email '. $LIKE .'\'%'. $search .'%\' OR nickname '.$LIKE.' \'%'.$search.'%\' OR idnumber '.$LIKE.' \'%'.$search.'%\') ';
356
357 }
358
cc038b47 359 if ($currentgroup) { // Displaying a group by choice
360 // FIX: TODO: This will not work if $currentgroup == 0, i.e. "those not in a group"
361 $from .= 'LEFT JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid ';
362 $where .= ' AND gm.groupid = '.$currentgroup;
363 }
4969ad74 364
cc038b47 365 if($course->id == SITEID) {
366 $where .= ' AND u.id NOT IN ('.implode(',', $exceptions).')';
367 }
a328425d 368
cc038b47 369 $totalcount = count_records_sql('SELECT COUNT(*) '.$from.$where);
a328425d 370
cc038b47 371 if($table->get_sql_where()) {
372 $where .= ' AND '.$table->get_sql_where();
a328425d 373 }
374
cc038b47 375 if($table->get_sql_sort()) {
cc038b47 376 $sort = ' ORDER BY '.$table->get_sql_sort();
377 }
378 else {
379 $sort = '';
380 }
a328425d 381
f1e24e7a 382 $matchcount = count_records_sql('SELECT COUNT(*) '.$from.$where.$wheresearch);
ff3caf30 383
cc038b47 384 $table->initialbars($totalcount > $perpage);
385 $table->pagesize($perpage, $matchcount);
4bc162b7 386
cc038b47 387 if($table->get_page_start() !== '' && $table->get_page_size() !== '') {
388 $limit = ' '.sql_paging_limit($table->get_page_start(), $table->get_page_size());
4bc162b7 389 }
cc038b47 390 else {
391 $limit = '';
392 }
393
f1e24e7a 394 $students = get_records_sql($select.$from.$where.$wheresearch.$sort.$limit);
cbb0fee0 395
cc038b47 396 $a->count = $totalcount;
397 $a->items = $totalcount == 1 ? $course->student : $course->students;
398 echo '<h2>'.get_string('counteditems', '', $a);
399 if (isteacheredit($course->id)) {
400 echo ' <a href="../course/student.php?id='.$course->id.'">';
401 echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="" /></a>';
402 }
403 echo '</h2>';
ff3caf30 404
cc038b47 405 if ($CFG->longtimenosee > 0 && $CFG->longtimenosee < 1000 && $totalcount > 0) {
406 echo '<p id="longtimenosee">('.get_string('unusedaccounts', '', $CFG->longtimenosee).')</p>';
407 }
4bc162b7 408
f19570d0 409 if ($isteacher) {
6746bb8a 410 echo '
411<script Language="JavaScript">
412<!--
413function checksubmit(form) {
414 var destination = form.formaction.options[form.formaction.selectedIndex].value;
415 if (destination == "" || !checkchecked(form)) {
416 form.formaction.selectedIndex = 0;
417 return false;
418 } else {
419 return true;
420 }
421}
422
423function checkchecked(form) {
424 var inputs = document.getElementsByTagName(\'INPUT\');
425 var checked = false;
426 inputs = filterByParent(inputs, function() {return form;});
427 for(var i = 0; i < inputs.length; ++i) {
428 if(inputs[i].type == \'checkbox\' && inputs[i].checked) {
429 checked = true;
430 }
431 }
432 return checked;
433}
434//-->
435</script>
436';
db0a8174 437 echo '<form action="action_redir.php" method="post" name="studentsform" onSubmit="return checksubmit(this);">';
f19570d0 438 echo '<input type="hidden" name="id" value="'.$id.'" />';
439 echo '<input type="hidden" name="returnto" value="'.$_SERVER['REQUEST_URI'].'" />';
6746bb8a 440 echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
f19570d0 441 }
442
cc038b47 443 if ($fullmode) { // Print simple listing
444 if ($totalcount < 1) {
445 print_heading(get_string("nostudentsfound", "", $course->students));
68b38e8d 446 }
cc038b47 447 else {
448
449 if($totalcount > $perpage) {
450
451 $firstinitial = $table->get_initial_first();
452 $lastinitial = $table->get_initial_last();
453 $strall = get_string('all');
454 $alpha = explode(',', get_string('alphabet'));
455
456 // Bar of first initials
457
458 echo '<div class="initialbar firstinitial">'.get_string('firstname').' : ';
459 if(!empty($firstinitial)) {
460 echo '<a href="'.$baseurl.'&amp;sifirst=">'.$strall.'</a>';
d578afc8 461 } else {
cc038b47 462 echo '<strong>'.$strall.'</strong>';
d578afc8 463 }
cc038b47 464 foreach ($alpha as $letter) {
465 if ($letter == $firstinitial) {
466 echo ' <strong>'.$letter.'</strong>';
467 } else {
468 echo ' <a href="'.$baseurl.'&amp;sifirst='.$letter.'">'.$letter.'</a>';
469 }
470 }
471 echo '</div>';
472
473 // Bar of last initials
474
475 echo '<div class="initialbar lastinitial">'.get_string('lastname').' : ';
476 if(!empty($lastinitial)) {
477 echo '<a href="'.$baseurl.'&amp;silast=">'.$strall.'</a>';
d578afc8 478 } else {
cc038b47 479 echo '<strong>'.$strall.'</strong>';
480 }
481 foreach ($alpha as $letter) {
482 if ($letter == $lastinitial) {
483 echo ' <strong>'.$letter.'</strong>';
484 } else {
485 echo ' <a href="'.$baseurl.'&amp;silast='.$letter.'">'.$letter.'</a>';
486 }
d578afc8 487 }
cc038b47 488 echo '</div>';
489
490 print_paging_bar($matchcount, intval($table->get_page_start() / $perpage), $perpage, $baseurl.'&amp;', 'spage');
491
32b4b974 492 }
d578afc8 493
cc038b47 494 if($matchcount > 0) {
495 foreach ($students as $student) {
f19570d0 496 print_user($student, $course, true);
cc038b47 497 }
adcb3ac5 498 }
cc038b47 499 else {
500 print_heading(get_string('nothingtodisplay'));
adcb3ac5 501 }
4969ad74 502 }
cc038b47 503 }
504 else {
505 $countrysort = (strpos($sort, 'country') !== false);
6746bb8a 506 $timeformat = get_string('strftimedate');
cc038b47 507 if (!empty($students)) {
508 foreach ($students as $student) {
509 if ($student->lastaccess) {
510 $lastaccess = format_time(time() - $student->lastaccess, $datestring);
511 } else {
512 $lastaccess = $strnever;
513 }
514
515 if (empty($student->country)) {
516 $country = '';
517 }
518 else {
519 if($countrysort) {
520 $country = '('.$student->country.') '.$countries[$student->country];
521 }
522 else {
523 $country = $countries[$student->country];
524 }
525 }
adcb3ac5 526
6746bb8a 527 $data = array (
cc038b47 528 //'<input type="checkbox" name="userid[]" value="'.$teacher->id.'" />',
529 print_user_picture($student->id, $course->id, $student->picture, false, true),
530 '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$student->id.'&amp;course='.$course->id.'">'.fullname($student).'</a></strong>',
531 $student->city,
532 $country,
6746bb8a 533 $lastaccess);
534 if ($course->enrolperiod) {
535 $data[] = userdate($student->timeend, $timeformat);
536 }
537 if ($isteacher) {
538 $data[] = '<input type="checkbox" name="user'.$student->id.'" />';
539 }
540 $table->add_data($data);
f19570d0 541
4969ad74 542 }
cc038b47 543 }
dc0dc7d5 544
cc038b47 545 $table->print_html();
6b281f1f 546
cc038b47 547 }
eca1c454 548
f19570d0 549 if ($isteacher) {
6746bb8a 550 echo '<br /><center>';
0f24c257 551 echo '<input type="button" onclick="checkall()" value="'.get_string('selectall').'" /> ';
552 echo '<input type="button" onclick="checknone()" value="'.get_string('deselectall').'" /> ';
6746bb8a 553 $displaylist['messageselect.php'] = get_string('messageselectadd');
554 if ($course->enrolperiod) {
555 $displaylist['extendenrol.php'] = get_string('extendenrol');
556 }
5e2c3024 557 choose_from_menu ($displaylist, "formaction", "", get_string("withselectedusers"), "if(checksubmit(this.form))this.form.submit();", "");
6746bb8a 558 echo '<input type="submit" value="' . get_string('ok') . '"';
f19570d0 559 echo '</center></form>';
560 }
561
f1e24e7a 562 if ($isteacher && $totalcount > ($perpage*3)) {
563 echo '<form action="index.php"><p align="center"><input type="hidden" name="id" value="'.$course->id.'" />'.get_string('search').':&nbsp;'."\n";
564 echo '<input type="text" name="search" value="'.$search.'" />&nbsp;<input type="submit" value="'.get_string('search').'" /></p></form>'."\n";
565 }
566
cc038b47 567 if ($perpage == 99999) {
568 echo '<div id="showall"><a href="'.$baseurl.'&amp;perpage='.DEFAULT_PAGE_SIZE.'">'.get_string('showperpage', '', DEFAULT_PAGE_SIZE).'</a></div>';
569 }
570 else if ($matchcount > 0 && $perpage < $matchcount) {
571 echo '<div id="showall"><a href="'.$baseurl.'&amp;perpage=99999">'.get_string('showall', '', $matchcount).'</a></div>';
572 }
573
574 print_footer($course);
f9903ed0 575
31b71336 576
577function get_lastaccess_sql($accesssince='') {
578 if (empty($accesssince)) {
579 return '';
580 }
581 if ($accesssince == -1) { // never
582 return ' AND timeaccess = 0';
583 } else {
584 return ' AND timeaccess != 0 AND timeaccess < '.$accesssince;
585 }
586}
587
f9903ed0 588?>