Automatic installer.php lang files by installer_builder (20070321)
[moodle.git] / user / index.php
blob4363c37601af9d12e6a100e53694ccff8ab5ede2
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 if ($mycourses = get_my_courses($USER->id)) {
133 //print my course menus
134 echo '<td class="left">';
135 print_string('mycourses');
136 echo ': ';
137 $my_course = array();
138 foreach ($mycourses as $mycourse) {
139 $my_course[$mycourse->id] = $mycourse->shortname;
141 //choose_from_menu($my_course, 'id', $course->id, '', 'courseform.submit()');
142 popup_form($CFG->wwwroot.'/user/index.php?id=',$my_course,'courseform',$course->id);
143 echo '</td>';
146 if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) {
147 if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
148 echo '<td class="left">';
149 print_group_menu($groups, $groupmode, $currentgroup, $baseurl);
150 echo '</td>';
154 if (!empty($isteacher)) {
155 // get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
156 $minlastaccess = get_field_sql('SELECT min(timeaccess) FROM '.$CFG->prefix.'user_students WHERE course = '.$course->id.' AND timeaccess != 0');
158 $lastaccess0exists = record_exists('user_students','course',$course->id,'timeaccess',0);
159 $now = usergetmidnight(time());
160 $timeaccess = array();
162 // makes sense for this to go first.
163 $timeoptions[0] = get_string('selectperiod');
165 // days
166 for ($i = 1; $i < 7; $i++) {
167 if (strtotime('-'.$i.' days',$now) >= $minlastaccess) {
168 $timeoptions[strtotime('-'.$i.' days',$now)] = get_string('numdays','moodle',$i);
171 // weeks
172 for ($i = 1; $i < 10; $i++) {
173 if (strtotime('-'.$i.' weeks',$now) >= $minlastaccess) {
174 $timeoptions[strtotime('-'.$i.' weeks',$now)] = get_string('numweeks','moodle',$i);
177 // months
178 for ($i = 2; $i < 12; $i++) {
179 if (strtotime('-'.$i.' months',$now) >= $minlastaccess) {
180 $timeoptions[strtotime('-'.$i.' months',$now)] = get_string('nummonths','moodle',$i);
183 // try a year
184 if (strtotime('-1 year',$now) >= $minlastaccess) {
185 $timeoptions[strtotime('-1 year',$now)] = get_string('lastyear');
188 if (!empty($lastaccess0exists)) {
189 $timeoptions[-1] = get_string('never');
192 if (count($timeoptions) > 1) {
193 echo '<td class="left">';
194 echo get_string('usersnoaccesssince').': ';
195 $baseurl = preg_replace('/&amp;accesssince='.$accesssince.'/','',$baseurl);
196 echo popup_form($baseurl.'&amp;accesssince=',$timeoptions,'timeoptions',$accesssince,'','','',true);
197 echo '</td>';
201 echo '<td class="right">';
202 echo get_string('userlist').': ';
203 $formatmenu = array( '0' => get_string('detailedless'),
204 '1' => get_string('detailedmore'));
205 echo popup_form($baseurl.'&amp;mode=', $formatmenu, 'formatmenu', $fullmode, '', '', '', true);
206 echo '</td></tr></table>';
208 if ($currentgroup and (!$isseparategroups or isteacheredit($course->id))) { /// Display info about the group
209 if ($group = get_record('groups', 'id', $currentgroup)) {
210 if (!empty($group->description) or (!empty($group->picture) and empty($group->hidepicture))) {
211 echo '<table class="groupinfobox"><tr><td class="left side picture">';
212 print_group_picture($group, $course->id, true, false, false);
213 echo '</td><td class="content">';
214 echo '<h3>'.$group->name;
215 if (isteacheredit($course->id)) {
216 echo '&nbsp;<a title="'.get_string('editgroupprofile').'" href="../course/groups.php?id='.$course->id.'&amp;group='.$group->id.'">';
217 echo '<img src="'.$CFG->pixpath.'/t/edit.gif" alt="" border="0">';
218 echo '</a>';
220 echo '</h3>';
221 echo format_text($group->description);
222 echo '</td></tr></table>';
228 $exceptions = array(); // This will be an array of userids that are shown as teachers and thus
229 // do not have to be shown as users as well. Only relevant on site course.
231 if ($isteacher) {
232 echo '
233 <script Language="JavaScript">
234 <!--
235 function checksubmit(form) {
236 var destination = form.formaction.options[form.formaction.selectedIndex].value;
237 if (destination == "" || !checkchecked(form)) {
238 form.formaction.selectedIndex = 0;
239 return false;
240 } else {
241 return true;
245 function checkchecked(form) {
246 var inputs = document.getElementsByTagName(\'INPUT\');
247 var checked = false;
248 inputs = filterByParent(inputs, function() {return form;});
249 for(var i = 0; i < inputs.length; ++i) {
250 if(inputs[i].type == \'checkbox\' && inputs[i].checked) {
251 checked = true;
254 return checked;
256 //-->
257 </script>
259 echo '<form action="action_redir.php" method="post" name="studentsform" onSubmit="return checksubmit(this);">';
260 echo '<input type="hidden" name="id" value="'.$id.'" />';
261 echo '<input type="hidden" name="returnto" value="'.$_SERVER['REQUEST_URI'].'" />';
262 echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
265 if($showteachers) {
267 $tablecolumns = array('picture', 'fullname');
268 $tableheaders = array('', get_string('fullname'));
269 if (!isset($hiddenfields['city'])) {
270 $tablecolumns[] = 'city';
271 $tableheaders[] = get_string('city');
273 if (!isset($hiddenfields['country'])) {
274 $tablecolumns[] = 'country';
275 $tableheaders[] = get_string('country');
277 if (!isset($hiddenfields['lastaccess'])) {
278 $tablecolumns[] = 'lastaccess';
279 $tableheaders[] = get_string('lastaccess');
282 if ($isteacher) {
283 $tablecolumns[] = '';
284 $tableheaders[] = get_string('select');
287 $table = new flexible_table('user-index-teachers-'.$course->id);
289 $table->define_columns($tablecolumns);
290 $table->define_headers($tableheaders);
291 $table->define_baseurl($baseurl);
293 $table->sortable(true, 'lastaccess', SORT_DESC);
295 $table->set_attribute('cellspacing', '0');
296 $table->set_attribute('id', 'teachers');
297 $table->set_attribute('class', 'generaltable generalbox');
299 $table->setup();
301 if($whereclause = $table->get_sql_where()) {
302 $whereclause .= ' AND ';
305 $teachersql = "SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest,
306 u.email, u.maildisplay, u.city, u.country, u.lastlogin, u.picture, u.lang, u.timezone,
307 u.emailstop, t.authority,t.role,t.editall,t.timeaccess as lastaccess, m.groupid
308 FROM {$CFG->prefix}user u
309 LEFT JOIN {$CFG->prefix}user_teachers t ON t.userid = u.id
310 LEFT JOIN {$CFG->prefix}groups_members m ON m.userid = u.id ";
312 if($isseparategroups) {
313 $whereclause .= '(t.editall OR groupid = '.$currentgroup.') AND ';
315 else if ($currentgroup) { // Displaying a group by choice
316 $whereclause .= 'groupid = '.$currentgroup.' AND ';
319 $teachersql .= 'WHERE '.$whereclause.' t.course = '.$course->id.' AND u.deleted = 0 AND u.confirmed = 1';
320 if (!$isteacher) {
321 $teachersql .= ' AND t.authority > 0';
324 if ($isteacher) {
325 $teachersql .= get_lastaccess_sql($accesssince);
328 if($sortclause = $table->get_sql_sort()) {
329 $teachersql .= ' ORDER BY '.$sortclause;
332 $teachers = get_records_sql($teachersql);
334 if(!empty($teachers)) {
336 echo '<h2>'.$course->teachers;
337 echo ' <a href="'.$baseurl.'&amp;teachers=0">';
338 echo '<img src="'.$CFG->pixpath.'/i/hide.gif" height="16" width="16" alt="'.get_string('hide').'" /></a>';
339 if (isadmin() or ($course->category and (iscreator() or (isteacheredit($course->id) and !empty($CFG->teacherassignteachers))))) {
340 echo ' <a href="'.$CFG->wwwroot.'/course/teacher.php?id='.$course->id.'">';
341 echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="'.get_string('edit').'" /></a>';
343 echo '</h2>';
345 $exceptions = array_keys($teachers);
347 if ($fullmode) {
348 foreach ($teachers as $key => $teacher) {
349 print_user($teacher, $course, true);
351 } else {
352 $countrysort = (strpos($sortclause, 'country') !== false);
353 foreach ($teachers as $teacher) {
355 if ($teacher->lastaccess) {
356 $lastaccess = format_time(time() - $teacher->lastaccess, $datestring);
357 } else {
358 $lastaccess = $strnever;
361 if (empty($teacher->country)) {
362 $country = '';
364 else {
365 if($countrysort) {
366 $country = '('.$teacher->country.') '.$countries[$teacher->country];
368 else {
369 $country = $countries[$teacher->country];
373 $data = array (
374 print_user_picture($teacher->id, $course->id, $teacher->picture, false, true),
375 '<strong><a'.($teacher->authority?'':' class="dimmed"').' href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&amp;course='.$course->id.'">'.fullname($teacher, $isteacher).'</a></strong>');
376 if (!isset($hiddenfields['city'])) {
377 $data[] = $teacher->city;
379 if (!isset($hiddenfields['country'])) {
380 $data[] = $country;
382 if (!isset($hiddenfields['lastaccess'])) {
383 $data[] = $lastaccess;
385 if ($isteacher) {
386 $data[] = '<input type="checkbox" name="teacher'.$teacher->id.'" />';
388 $table->add_data($data);
391 $table->print_html();
395 else {
396 // Don't show teachers
397 echo '<h2>'.$course->teachers;
398 echo ' <a href="'.$baseurl.'&amp;teachers=1">';
399 echo '<img src="'.$CFG->pixpath.'/i/show.gif" height="16" width="16" alt="'.get_string('show').'" /></a>';
400 if (isadmin() or ($course->category and (iscreator() or (isteacheredit($course->id) and !empty($CFG->teacherassignteachers))))) {
401 echo ' <a href="'.$CFG->wwwroot.'/course/teacher.php?id='.$course->id.'">';
402 echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="'.get_string('edit').'" /></a>';
404 echo '</h2>';
407 $guest = get_guest();
408 $exceptions[] = $guest->id;
410 $tablecolumns = array('picture', 'fullname');
411 $tableheaders = array('', get_string('fullname'));
412 if (!isset($hiddenfields['city'])) {
413 $tablecolumns[] = 'city';
414 $tableheaders[] = get_string('city');
416 if (!isset($hiddenfields['country'])) {
417 $tablecolumns[] = 'country';
418 $tableheaders[] = get_string('country');
420 if (!isset($hiddenfields['lastaccess'])) {
421 $tablecolumns[] = 'lastaccess';
422 $tableheaders[] = get_string('lastaccess');
425 if ($course->enrolperiod) {
426 $tablecolumns[] = 'timeend';
427 $tableheaders[] = get_string('enrolmentend');
430 if ($isteacher) {
431 $tablecolumns[] = '';
432 $tableheaders[] = get_string('select');
435 $table = new flexible_table('user-index-students-'.$course->id);
437 $table->define_columns($tablecolumns);
438 $table->define_headers($tableheaders);
439 $table->define_baseurl($baseurl);
441 $table->sortable(true, 'lastaccess', SORT_DESC);
443 $table->set_attribute('cellspacing', '0');
444 $table->set_attribute('id', 'students');
445 $table->set_attribute('class', 'generaltable generalbox');
447 $table->set_control_variables(array(
448 TABLE_VAR_SORT => 'ssort',
449 TABLE_VAR_HIDE => 'shide',
450 TABLE_VAR_SHOW => 'sshow',
451 TABLE_VAR_IFIRST => 'sifirst',
452 TABLE_VAR_ILAST => 'silast',
453 TABLE_VAR_PAGE => 'spage'
455 $table->setup();
457 if(SITEID == $course->id) {
458 $select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country,
459 u.picture, u.lang, u.timezone, u.emailstop, u.maildisplay, u.lastaccess ';
460 $from = 'FROM '.$CFG->prefix.'user u ';
461 $where = 'WHERE confirmed = 1 AND u.deleted = 0 ';
463 else {
464 $select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country,
465 u.picture, u.lang, u.timezone, u.emailstop, u.maildisplay, s.timeaccess AS lastaccess ';
466 $select .= $course->enrolperiod?', s.timeend ':'';
467 $from = 'FROM '.$CFG->prefix.'user u LEFT JOIN '.$CFG->prefix.'user_students s ON s.userid = u.id ';
468 $where = 'WHERE s.course = '.$course->id.' AND u.deleted = 0 ';
471 if ($isteacher) {
472 $where .= get_lastaccess_sql($accesssince);
475 $wheresearch = '';
477 if (!empty($search)) {
478 $LIKE = sql_ilike();
479 $fullname = sql_fullname('u.firstname','u.lastname');
480 $wheresearch .= ' AND ('. $fullname .' '. $LIKE .'\'%'. $search .'%\' OR email '. $LIKE .'\'%'. $search .'%\' OR idnumber '.$LIKE.' \'%'.$search.'%\') ';
484 if ($currentgroup) { // Displaying a group by choice
485 // FIX: TODO: This will not work if $currentgroup == 0, i.e. "those not in a group"
486 $from .= 'LEFT JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid ';
487 $where .= ' AND gm.groupid = '.$currentgroup;
490 if($course->id == SITEID) {
491 $where .= ' AND u.id NOT IN ('.implode(',', $exceptions).')';
494 $totalcount = count_records_sql('SELECT COUNT(*) '.$from.$where);
496 if($table->get_sql_where()) {
497 $where .= ' AND '.$table->get_sql_where();
500 if($table->get_sql_sort()) {
501 $sort = ' ORDER BY '.$table->get_sql_sort();
503 else {
504 $sort = '';
507 $matchcount = count_records_sql('SELECT COUNT(*) '.$from.$where.$wheresearch);
509 $table->initialbars($totalcount > $perpage);
510 $table->pagesize($perpage, $matchcount);
512 if($table->get_page_start() !== '' && $table->get_page_size() !== '') {
513 $limit = ' '.sql_paging_limit($table->get_page_start(), $table->get_page_size());
515 else {
516 $limit = '';
519 $students = get_records_sql($select.$from.$where.$wheresearch.$sort.$limit);
521 $a->count = $totalcount;
522 $a->items = $totalcount == 1 ? $course->student : $course->students;
523 echo '<h2>'.get_string('counteditems', '', $a);
524 if (isteacheredit($course->id)) {
525 echo ' <a href="../course/student.php?id='.$course->id.'">';
526 echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="" /></a>';
528 echo '</h2>';
530 if ($CFG->longtimenosee > 0 && $CFG->longtimenosee < 1000 && $totalcount > 0) {
531 echo '<p id="longtimenosee">('.get_string('unusedaccounts', '', $CFG->longtimenosee).')</p>';
534 if ($fullmode) { // Print simple listing
535 if ($totalcount < 1) {
536 print_heading(get_string("nostudentsfound", "", $course->students));
538 else {
540 if($totalcount > $perpage) {
542 $firstinitial = $table->get_initial_first();
543 $lastinitial = $table->get_initial_last();
544 $strall = get_string('all');
545 $alpha = explode(',', get_string('alphabet'));
547 // Bar of first initials
549 echo '<div class="initialbar firstinitial">'.get_string('firstname').' : ';
550 if(!empty($firstinitial)) {
551 echo '<a href="'.$baseurl.'&amp;sifirst=">'.$strall.'</a>';
552 } else {
553 echo '<strong>'.$strall.'</strong>';
555 foreach ($alpha as $letter) {
556 if ($letter == $firstinitial) {
557 echo ' <strong>'.$letter.'</strong>';
558 } else {
559 echo ' <a href="'.$baseurl.'&amp;sifirst='.$letter.'">'.$letter.'</a>';
562 echo '</div>';
564 // Bar of last initials
566 echo '<div class="initialbar lastinitial">'.get_string('lastname').' : ';
567 if(!empty($lastinitial)) {
568 echo '<a href="'.$baseurl.'&amp;silast=">'.$strall.'</a>';
569 } else {
570 echo '<strong>'.$strall.'</strong>';
572 foreach ($alpha as $letter) {
573 if ($letter == $lastinitial) {
574 echo ' <strong>'.$letter.'</strong>';
575 } else {
576 echo ' <a href="'.$baseurl.'&amp;silast='.$letter.'">'.$letter.'</a>';
579 echo '</div>';
581 print_paging_bar($matchcount, intval($table->get_page_start() / $perpage), $perpage, $baseurl.'&amp;', 'spage');
585 if($matchcount > 0) {
586 foreach ($students as $student) {
587 print_user($student, $course, true);
590 else {
591 print_heading(get_string('nothingtodisplay'));
595 else {
596 $countrysort = (strpos($sort, 'country') !== false);
597 $timeformat = get_string('strftimedate');
598 if (!empty($students)) {
599 foreach ($students as $student) {
600 if ($student->lastaccess) {
601 $lastaccess = format_time(time() - $student->lastaccess, $datestring);
602 } else {
603 $lastaccess = $strnever;
606 if (empty($student->country)) {
607 $country = '';
609 else {
610 if($countrysort) {
611 $country = '('.$student->country.') '.$countries[$student->country];
613 else {
614 $country = $countries[$student->country];
618 $data = array (
619 print_user_picture($student->id, $course->id, $student->picture, false, true),
620 '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$student->id.'&amp;course='.$course->id.'">'.fullname($student).'</a></strong>');
621 if (!isset($hiddenfields['city'])) {
622 $data[] = $student->city;
624 if (!isset($hiddenfields['country'])) {
625 $data[] = $country;
627 if (!isset($hiddenfields['lastaccess'])) {
628 $data[] = $lastaccess;
630 if ($course->enrolperiod) {
631 if ($student->timeend) {
632 $data[] = userdate($student->timeend, $timeformat);
633 } else {
634 $data[] = get_string('unlimited');
637 if ($isteacher) {
638 $data[] = '<input type="checkbox" name="user'.$student->id.'" />';
640 $table->add_data($data);
645 $table->print_html();
649 if ($isteacher) {
650 echo '<br /><center>';
651 echo '<input type="button" onclick="checkall()" value="'.get_string('selectall').'" /> ';
652 echo '<input type="button" onclick="checknone()" value="'.get_string('deselectall').'" /> ';
653 $displaylist['messageselect.php'] = get_string('messageselectadd');
654 if ($course->enrolperiod) {
655 $displaylist['extendenrol.php'] = get_string('extendenrol');
657 choose_from_menu ($displaylist, "formaction", "", get_string("withselectedusers"), "if(checksubmit(this.form))this.form.submit();", "");
658 helpbutton("participantswithselectedusers", get_string("withselectedusers"));
659 echo '<input type="submit" value="' . get_string('ok') . '"';
660 echo '</center></form>';
663 if ($isteacher && $totalcount > ($perpage*3)) {
664 echo '<form action="index.php"><p align="center"><input type="hidden" name="id" value="'.$course->id.'" />'.get_string('search').':&nbsp;'."\n";
665 echo '<input type="text" name="search" value="'.$search.'" />&nbsp;<input type="submit" value="'.get_string('search').'" /></p></form>'."\n";
668 if ($perpage == 99999) {
669 echo '<div id="showall"><a href="'.$baseurl.'&amp;perpage='.DEFAULT_PAGE_SIZE.'">'.get_string('showperpage', '', DEFAULT_PAGE_SIZE).'</a></div>';
671 else if ($matchcount > 0 && $perpage < $matchcount) {
672 echo '<div id="showall"><a href="'.$baseurl.'&amp;perpage=99999">'.get_string('showall', '', $matchcount).'</a></div>';
675 print_footer($course);
678 function get_lastaccess_sql($accesssince='') {
679 if (empty($accesssince)) {
680 return '';
682 if ($accesssince == -1) { // never
683 return ' AND timeaccess = 0';
684 } else {
685 return ' AND timeaccess != 0 AND timeaccess < '.$accesssince;