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