OKAY! THIS IS IT! MOODLE 1.6!
[moodle.git] / user / index.php
blobc3c8553e3d00124b4cef9715cf3ef4ceedf5f879
1 <?PHP // $Id$
3 // Lists all the users within a given course
5 require_once('../config.php');
6 require_once($CFG->libdir.'/tablelib.php');
8 define('USER_SMALL_CLASS', 20); // Below this is considered small
9 define('USER_LARGE_CLASS', 200); // Above this is considered large
10 define('DEFAULT_PAGE_SIZE', 20);
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?
18 $accesssince = optional_param('accesssince',0,PARAM_INT); // filter by last access. -1 = never
19 $search = optional_param('search','',PARAM_CLEAN);
21 $showteachers = $showteachers && empty($search); // if we're searching, we just want students.
23 if (! $course = get_record('course', 'id', $id)) {
24 error("Course ID is incorrect");
27 require_login($course->id);
29 if (!$course->category) {
30 if (!$CFG->showsiteparticipantslist and !isteacher(SITEID)) {
31 print_header("$course->shortname: ".get_string('participants'), $course->fullname,
32 get_string('participants'), "", "", true, "&nbsp;", navmenu($course));
33 notice(get_string('sitepartlist0'));
35 if ($CFG->showsiteparticipantslist < 2 and !isteacherinanycourse()) {
36 print_header("$course->shortname: ".get_string('participants'), $course->fullname,
37 get_string('participants'), "", "", true, "&nbsp;", navmenu($course));
38 notice(get_string('sitepartlist1'));
42 add_to_log($course->id, 'user', 'view all', 'index.php?id='.$course->id, '');
44 $isteacher = isteacher($course->id);
46 if (empty($isteacher)) {
47 $search = false;
50 $countries = get_list_of_countries();
52 $strnever = get_string('never');
54 $datestring->day = get_string('day');
55 $datestring->days = get_string('days');
56 $datestring->hour = get_string('hour');
57 $datestring->hours = get_string('hours');
58 $datestring->min = get_string('min');
59 $datestring->mins = get_string('mins');
60 $datestring->sec = get_string('sec');
61 $datestring->secs = get_string('secs');
63 if ($mode !== NULL) {
64 $SESSION->userindexmode = $fullmode = ($mode == 1);
65 } else if (isset($SESSION->userindexmode)) {
66 $fullmode = $SESSION->userindexmode;
67 } else {
68 $fullmode = false;
71 /// Check to see if groups are being used in this forum
72 /// and if so, set $currentgroup to reflect the current group
74 $groupmode = groupmode($course); // Groups are being used
75 $currentgroup = get_and_set_current_group($course, $groupmode, $group);
77 if (!$currentgroup) { // To make some other functions work better later
78 $currentgroup = NULL;
81 $isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and
82 !isteacheredit($course->id));
84 if ($isseparategroups and (!$currentgroup) ) { //XXX
85 print_heading(get_string("notingroup", "forum"));
86 print_footer($course);
87 exit;
90 // Should use this variable so that we don't break stuff every time a variable is added or changed.
91 $baseurl = $CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$currentgroup.'&amp;perpage='.$perpage.'&amp;teachers='.$showteachers.'&amp;accesssince='.$accesssince.'&amp;search='.$search;
93 /// Print headers
95 if ($course->category) {
96 print_header("$course->shortname: ".get_string('participants'), $course->fullname,
97 "<a href=\"../course/view.php?id=$course->id\">$course->shortname</a> -> ".
98 get_string('participants'), "", "", true, "&nbsp;", navmenu($course));
99 } else {
100 print_header("$course->shortname: ".get_string('participants'), $course->fullname,
101 get_string('participants'), "", "", true, "&nbsp;", navmenu($course));
105 //setting up tags
106 if ($id == SITEID) {
107 $filtertype = 'site';
108 } else if ($id && !$currentgroup) {
109 $filtertype = 'course';
110 $filterselect = $id;
111 } else {
112 $filtertype = 'group';
113 $filterselect = $currentgroup;
115 $currenttab = 'participants';
116 $user = $USER;
118 require_once($CFG->dirroot .'/user/tabs.php');
121 /// Get the hidden field list
122 if ($isteacher || isadmin()) {
123 $hiddenfields = array(); // teachers and admins are allowed to see everything
124 } else {
125 $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
128 /// Print settings and things in a table across the top
130 echo '<table class="controls" cellspacing="0"><tr>';
132 //print my course menus
133 echo '<td class="left">';
134 print_string('mycourses');
135 echo ': ';
136 $mycourses = get_my_courses($USER->id);
137 foreach ($mycourses as $mycourse) {
138 $my_course[$mycourse->id] = $mycourse->shortname;
140 //choose_from_menu($my_course, 'id', $course->id, '', 'courseform.submit()');
141 popup_form($CFG->wwwroot.'/user/index.php?id=',$my_course,'courseform',$course->id);
142 echo '</td></tr>';
144 if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) {
145 if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
146 echo '<td class="left">';
147 print_group_menu($groups, $groupmode, $currentgroup, $baseurl);
148 echo '</td>';
152 if (!empty($isteacher)) {
153 // get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
154 $minlastaccess = get_field_sql('SELECT min(timeaccess) FROM '.$CFG->prefix.'user_students WHERE course = '.$course->id.' AND timeaccess != 0');
156 $lastaccess0exists = record_exists('user_students','course',$course->id,'timeaccess',0);
157 $now = usergetmidnight(time());
158 $timeaccess = array();
160 // makes sense for this to go first.
161 $timeoptions[0] = get_string('selectperiod');
163 // days
164 for ($i = 1; $i < 7; $i++) {
165 if (strtotime('-'.$i.' days',$now) >= $minlastaccess) {
166 $timeoptions[strtotime('-'.$i.' days',$now)] = get_string('numdays','moodle',$i);
169 // weeks
170 for ($i = 1; $i < 10; $i++) {
171 if (strtotime('-'.$i.' weeks',$now) >= $minlastaccess) {
172 $timeoptions[strtotime('-'.$i.' weeks',$now)] = get_string('numweeks','moodle',$i);
175 // months
176 for ($i = 2; $i < 12; $i++) {
177 if (strtotime('-'.$i.' months',$now) >= $minlastaccess) {
178 $timeoptions[strtotime('-'.$i.' months',$now)] = get_string('nummonths','moodle',$i);
181 // try a year
182 if (strtotime('-1 year',$now) >= $minlastaccess) {
183 $timeoptions[strtotime('-1 year',$now)] = get_string('lastyear');
186 if (!empty($lastaccess0exists)) {
187 $timeoptions[-1] = get_string('never');
190 if (count($timeoptions) > 1) {
191 echo '<td class="left">';
192 echo get_string('usersnoaccesssince').': ';
193 $baseurl = preg_replace('/&amp;accesssince='.$accesssince.'/','',$baseurl);
194 echo popup_form($baseurl.'&amp;accesssince=',$timeoptions,'timeoptions',$accesssince,'','','',true);
195 echo '</td>';
199 echo '<td class="right">';
200 echo get_string('userlist').': ';
201 $formatmenu = array( '0' => get_string('detailedless'),
202 '1' => get_string('detailedmore'));
203 echo popup_form($baseurl.'&amp;mode=', $formatmenu, 'formatmenu', $fullmode, '', '', '', true);
204 echo '</td></tr></table>';
206 if ($currentgroup and (!$isseparategroups or isteacheredit($course->id))) { /// Display info about the group
207 if ($group = get_record('groups', 'id', $currentgroup)) {
208 if (!empty($group->description) or (!empty($group->picture) and empty($group->hidepicture))) {
209 echo '<table class="groupinfobox"><tr><td class="left side picture">';
210 print_group_picture($group, $course->id, true, false, false);
211 echo '</td><td class="content">';
212 echo '<h3>'.$group->name;
213 if (isteacheredit($course->id)) {
214 echo '&nbsp;<a title="'.get_string('editgroupprofile').'" href="../course/groups.php?id='.$course->id.'&amp;group='.$group->id.'">';
215 echo '<img src="'.$CFG->pixpath.'/t/edit.gif" alt="" border="0">';
216 echo '</a>';
218 echo '</h3>';
219 echo format_text($group->description);
220 echo '</td></tr></table>';
226 $exceptions = array(); // This will be an array of userids that are shown as teachers and thus
227 // do not have to be shown as users as well. Only relevant on site course.
229 if ($isteacher) {
230 echo '
231 <script Language="JavaScript">
232 <!--
233 function checksubmit(form) {
234 var destination = form.formaction.options[form.formaction.selectedIndex].value;
235 if (destination == "" || !checkchecked(form)) {
236 form.formaction.selectedIndex = 0;
237 return false;
238 } else {
239 return true;
243 function checkchecked(form) {
244 var inputs = document.getElementsByTagName(\'INPUT\');
245 var checked = false;
246 inputs = filterByParent(inputs, function() {return form;});
247 for(var i = 0; i < inputs.length; ++i) {
248 if(inputs[i].type == \'checkbox\' && inputs[i].checked) {
249 checked = true;
252 return checked;
254 //-->
255 </script>
257 echo '<form action="action_redir.php" method="post" name="studentsform" onSubmit="return checksubmit(this);">';
258 echo '<input type="hidden" name="id" value="'.$id.'" />';
259 echo '<input type="hidden" name="returnto" value="'.$_SERVER['REQUEST_URI'].'" />';
260 echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
263 if($showteachers) {
265 $tablecolumns = array('picture', 'fullname');
266 $tableheaders = array('', get_string('fullname'));
267 if (!isset($hiddenfields['city'])) {
268 $tablecolumns[] = 'city';
269 $tableheaders[] = get_string('city');
271 if (!isset($hiddenfields['country'])) {
272 $tablecolumns[] = 'country';
273 $tableheaders[] = get_string('country');
275 if (!isset($hiddenfields['lastaccess'])) {
276 $tablecolumns[] = 'lastaccess';
277 $tableheaders[] = get_string('lastaccess');
280 if ($isteacher) {
281 $tablecolumns[] = '';
282 $tableheaders[] = get_string('select');
285 $table = new flexible_table('user-index-teachers-'.$course->id);
287 $table->define_columns($tablecolumns);
288 $table->define_headers($tableheaders);
289 $table->define_baseurl($baseurl);
291 $table->sortable(true, 'lastaccess', SORT_DESC);
293 $table->set_attribute('cellspacing', '0');
294 $table->set_attribute('id', 'teachers');
295 $table->set_attribute('class', 'generaltable generalbox');
297 $table->setup();
299 if($whereclause = $table->get_sql_where()) {
300 $whereclause .= ' AND ';
303 $teachersql = "SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest,
304 u.email, u.maildisplay, u.city, u.country, u.lastlogin, u.picture, u.lang, u.timezone,
305 u.emailstop, t.authority,t.role,t.editall,t.timeaccess as lastaccess, m.groupid
306 FROM {$CFG->prefix}user u
307 LEFT JOIN {$CFG->prefix}user_teachers t ON t.userid = u.id
308 LEFT JOIN {$CFG->prefix}groups_members m ON m.userid = u.id ";
310 if($isseparategroups) {
311 $whereclause .= '(t.editall OR groupid = '.$currentgroup.') AND ';
313 else if ($currentgroup) { // Displaying a group by choice
314 $whereclause .= 'groupid = '.$currentgroup.' AND ';
317 $teachersql .= 'WHERE '.$whereclause.' t.course = '.$course->id.' AND u.deleted = 0 AND u.confirmed = 1';
318 if (!$isteacher) {
319 $teachersql .= ' AND t.authority > 0';
322 if ($isteacher) {
323 $teachersql .= get_lastaccess_sql($accesssince);
326 if($sortclause = $table->get_sql_sort()) {
327 $teachersql .= ' ORDER BY '.$sortclause;
330 $teachers = get_records_sql($teachersql);
332 if(!empty($teachers)) {
334 echo '<h2>'.$course->teachers;
335 echo ' <a href="'.$baseurl.'&amp;teachers=0">';
336 echo '<img src="'.$CFG->pixpath.'/i/hide.gif" height="16" width="16" alt="'.get_string('hide').'" /></a>';
337 if (isadmin() or ($course->category and (iscreator() or (isteacheredit($course->id) and !empty($CFG->teacherassignteachers))))) {
338 echo ' <a href="'.$CFG->wwwroot.'/course/teacher.php?id='.$course->id.'">';
339 echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="'.get_string('edit').'" /></a>';
341 echo '</h2>';
343 $exceptions = array_keys($teachers);
345 if ($fullmode) {
346 foreach ($teachers as $key => $teacher) {
347 print_user($teacher, $course, true);
349 } else {
350 $countrysort = (strpos($sortclause, 'country') !== false);
351 foreach ($teachers as $teacher) {
353 if ($teacher->lastaccess) {
354 $lastaccess = format_time(time() - $teacher->lastaccess, $datestring);
355 } else {
356 $lastaccess = $strnever;
359 if (empty($teacher->country)) {
360 $country = '';
362 else {
363 if($countrysort) {
364 $country = '('.$teacher->country.') '.$countries[$teacher->country];
366 else {
367 $country = $countries[$teacher->country];
371 $data = array (
372 print_user_picture($teacher->id, $course->id, $teacher->picture, false, true),
373 '<strong><a'.($teacher->authority?'':' class="dimmed"').' href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&amp;course='.$course->id.'">'.fullname($teacher, $isteacher).'</a></strong>');
374 if (!isset($hiddenfields['city'])) {
375 $data[] = $teacher->city;
377 if (!isset($hiddenfields['country'])) {
378 $data[] = $country;
380 if (!isset($hiddenfields['lastaccess'])) {
381 $data[] = $lastaccess;
383 if ($isteacher) {
384 $data[] = '<input type="checkbox" name="teacher'.$teacher->id.'" />';
386 $table->add_data($data);
389 $table->print_html();
393 else {
394 // Don't show teachers
395 echo '<h2>'.$course->teachers;
396 echo ' <a href="'.$baseurl.'&amp;teachers=1">';
397 echo '<img src="'.$CFG->pixpath.'/i/show.gif" height="16" width="16" alt="'.get_string('show').'" /></a>';
398 if (isadmin() or ($course->category and (iscreator() or (isteacheredit($course->id) and !empty($CFG->teacherassignteachers))))) {
399 echo ' <a href="'.$CFG->wwwroot.'/course/teacher.php?id='.$course->id.'">';
400 echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="'.get_string('edit').'" /></a>';
402 echo '</h2>';
405 $guest = get_guest();
406 $exceptions[] = $guest->id;
408 $tablecolumns = array('picture', 'fullname');
409 $tableheaders = array('', get_string('fullname'));
410 if (!isset($hiddenfields['city'])) {
411 $tablecolumns[] = 'city';
412 $tableheaders[] = get_string('city');
414 if (!isset($hiddenfields['country'])) {
415 $tablecolumns[] = 'country';
416 $tableheaders[] = get_string('country');
418 if (!isset($hiddenfields['lastaccess'])) {
419 $tablecolumns[] = 'lastaccess';
420 $tableheaders[] = get_string('lastaccess');
423 if ($course->enrolperiod) {
424 $tablecolumns[] = 'timeend';
425 $tableheaders[] = get_string('enrolmentend');
428 if ($isteacher) {
429 $tablecolumns[] = '';
430 $tableheaders[] = get_string('select');
433 $table = new flexible_table('user-index-students-'.$course->id);
435 $table->define_columns($tablecolumns);
436 $table->define_headers($tableheaders);
437 $table->define_baseurl($baseurl);
439 $table->sortable(true, 'lastaccess', SORT_DESC);
441 $table->set_attribute('cellspacing', '0');
442 $table->set_attribute('id', 'students');
443 $table->set_attribute('class', 'generaltable generalbox');
445 $table->set_control_variables(array(
446 TABLE_VAR_SORT => 'ssort',
447 TABLE_VAR_HIDE => 'shide',
448 TABLE_VAR_SHOW => 'sshow',
449 TABLE_VAR_IFIRST => 'sifirst',
450 TABLE_VAR_ILAST => 'silast',
451 TABLE_VAR_PAGE => 'spage'
453 $table->setup();
455 if(SITEID == $course->id) {
456 $select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country,
457 u.picture, u.lang, u.timezone, u.emailstop, u.maildisplay, u.lastaccess ';
458 $from = 'FROM '.$CFG->prefix.'user u ';
459 $where = 'WHERE confirmed = 1 AND u.deleted = 0 ';
461 else {
462 $select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country,
463 u.picture, u.lang, u.timezone, u.emailstop, u.maildisplay, s.timeaccess AS lastaccess ';
464 $select .= $course->enrolperiod?', s.timeend ':'';
465 $from = 'FROM '.$CFG->prefix.'user u LEFT JOIN '.$CFG->prefix.'user_students s ON s.userid = u.id ';
466 $where = 'WHERE s.course = '.$course->id.' AND u.deleted = 0 ';
469 if ($isteacher) {
470 $where .= get_lastaccess_sql($accesssince);
473 $wheresearch = '';
475 if (!empty($search)) {
476 $LIKE = sql_ilike();
477 $fullname = sql_fullname('u.firstname','u.lastname');
478 $wheresearch .= ' AND ('. $fullname .' '. $LIKE .'\'%'. $search .'%\' OR email '. $LIKE .'\'%'. $search .'%\' OR idnumber '.$LIKE.' \'%'.$search.'%\') ';
482 if ($currentgroup) { // Displaying a group by choice
483 // FIX: TODO: This will not work if $currentgroup == 0, i.e. "those not in a group"
484 $from .= 'LEFT JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid ';
485 $where .= ' AND gm.groupid = '.$currentgroup;
488 if($course->id == SITEID) {
489 $where .= ' AND u.id NOT IN ('.implode(',', $exceptions).')';
492 $totalcount = count_records_sql('SELECT COUNT(*) '.$from.$where);
494 if($table->get_sql_where()) {
495 $where .= ' AND '.$table->get_sql_where();
498 if($table->get_sql_sort()) {
499 $sort = ' ORDER BY '.$table->get_sql_sort();
501 else {
502 $sort = '';
505 $matchcount = count_records_sql('SELECT COUNT(*) '.$from.$where.$wheresearch);
507 $table->initialbars($totalcount > $perpage);
508 $table->pagesize($perpage, $matchcount);
510 if($table->get_page_start() !== '' && $table->get_page_size() !== '') {
511 $limit = ' '.sql_paging_limit($table->get_page_start(), $table->get_page_size());
513 else {
514 $limit = '';
517 $students = get_records_sql($select.$from.$where.$wheresearch.$sort.$limit);
519 $a->count = $totalcount;
520 $a->items = $totalcount == 1 ? $course->student : $course->students;
521 echo '<h2>'.get_string('counteditems', '', $a);
522 if (isteacheredit($course->id)) {
523 echo ' <a href="../course/student.php?id='.$course->id.'">';
524 echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="" /></a>';
526 echo '</h2>';
528 if ($CFG->longtimenosee > 0 && $CFG->longtimenosee < 1000 && $totalcount > 0) {
529 echo '<p id="longtimenosee">('.get_string('unusedaccounts', '', $CFG->longtimenosee).')</p>';
532 if ($fullmode) { // Print simple listing
533 if ($totalcount < 1) {
534 print_heading(get_string("nostudentsfound", "", $course->students));
536 else {
538 if($totalcount > $perpage) {
540 $firstinitial = $table->get_initial_first();
541 $lastinitial = $table->get_initial_last();
542 $strall = get_string('all');
543 $alpha = explode(',', get_string('alphabet'));
545 // Bar of first initials
547 echo '<div class="initialbar firstinitial">'.get_string('firstname').' : ';
548 if(!empty($firstinitial)) {
549 echo '<a href="'.$baseurl.'&amp;sifirst=">'.$strall.'</a>';
550 } else {
551 echo '<strong>'.$strall.'</strong>';
553 foreach ($alpha as $letter) {
554 if ($letter == $firstinitial) {
555 echo ' <strong>'.$letter.'</strong>';
556 } else {
557 echo ' <a href="'.$baseurl.'&amp;sifirst='.$letter.'">'.$letter.'</a>';
560 echo '</div>';
562 // Bar of last initials
564 echo '<div class="initialbar lastinitial">'.get_string('lastname').' : ';
565 if(!empty($lastinitial)) {
566 echo '<a href="'.$baseurl.'&amp;silast=">'.$strall.'</a>';
567 } else {
568 echo '<strong>'.$strall.'</strong>';
570 foreach ($alpha as $letter) {
571 if ($letter == $lastinitial) {
572 echo ' <strong>'.$letter.'</strong>';
573 } else {
574 echo ' <a href="'.$baseurl.'&amp;silast='.$letter.'">'.$letter.'</a>';
577 echo '</div>';
579 print_paging_bar($matchcount, intval($table->get_page_start() / $perpage), $perpage, $baseurl.'&amp;', 'spage');
583 if($matchcount > 0) {
584 foreach ($students as $student) {
585 print_user($student, $course, true);
588 else {
589 print_heading(get_string('nothingtodisplay'));
593 else {
594 $countrysort = (strpos($sort, 'country') !== false);
595 $timeformat = get_string('strftimedate');
596 if (!empty($students)) {
597 foreach ($students as $student) {
598 if ($student->lastaccess) {
599 $lastaccess = format_time(time() - $student->lastaccess, $datestring);
600 } else {
601 $lastaccess = $strnever;
604 if (empty($student->country)) {
605 $country = '';
607 else {
608 if($countrysort) {
609 $country = '('.$student->country.') '.$countries[$student->country];
611 else {
612 $country = $countries[$student->country];
616 $data = array (
617 print_user_picture($student->id, $course->id, $student->picture, false, true),
618 '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$student->id.'&amp;course='.$course->id.'">'.fullname($student).'</a></strong>');
619 if (!isset($hiddenfields['city'])) {
620 $data[] = $student->city;
622 if (!isset($hiddenfields['country'])) {
623 $data[] = $country;
625 if (!isset($hiddenfields['lastaccess'])) {
626 $data[] = $lastaccess;
628 if ($course->enrolperiod) {
629 if ($student->timeend) {
630 $data[] = userdate($student->timeend, $timeformat);
631 } else {
632 $data[] = get_string('unlimited');
635 if ($isteacher) {
636 $data[] = '<input type="checkbox" name="user'.$student->id.'" />';
638 $table->add_data($data);
643 $table->print_html();
647 if ($isteacher) {
648 echo '<br /><center>';
649 echo '<input type="button" onclick="checkall()" value="'.get_string('selectall').'" /> ';
650 echo '<input type="button" onclick="checknone()" value="'.get_string('deselectall').'" /> ';
651 $displaylist['messageselect.php'] = get_string('messageselectadd');
652 if ($course->enrolperiod) {
653 $displaylist['extendenrol.php'] = get_string('extendenrol');
655 choose_from_menu ($displaylist, "formaction", "", get_string("withselectedusers"), "if(checksubmit(this.form))this.form.submit();", "");
656 helpbutton("participantswithselectedusers", get_string("withselectedusers"));
657 echo '<input type="submit" value="' . get_string('ok') . '"';
658 echo '</center></form>';
661 if ($isteacher && $totalcount > ($perpage*3)) {
662 echo '<form action="index.php"><p align="center"><input type="hidden" name="id" value="'.$course->id.'" />'.get_string('search').':&nbsp;'."\n";
663 echo '<input type="text" name="search" value="'.$search.'" />&nbsp;<input type="submit" value="'.get_string('search').'" /></p></form>'."\n";
666 if ($perpage == 99999) {
667 echo '<div id="showall"><a href="'.$baseurl.'&amp;perpage='.DEFAULT_PAGE_SIZE.'">'.get_string('showperpage', '', DEFAULT_PAGE_SIZE).'</a></div>';
669 else if ($matchcount > 0 && $perpage < $matchcount) {
670 echo '<div id="showall"><a href="'.$baseurl.'&amp;perpage=99999">'.get_string('showall', '', $matchcount).'</a></div>';
673 print_footer($course);
676 function get_lastaccess_sql($accesssince='') {
677 if (empty($accesssince)) {
678 return '';
680 if ($accesssince == -1) { // never
681 return ' AND timeaccess = 0';
682 } else {
683 return ' AND timeaccess != 0 AND timeaccess < '.$accesssince;