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