MDL-11514:
[moodle-linuxchix.git] / user / index.php
blobdc2da43b304c874cbfa46053520708f86b7f1733
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);
11 define('SHOW_ALL_PAGE_SIZE', 5000);
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 $accesssince = optional_param('accesssince',0,PARAM_INT); // filter by last access. -1 = never
17 $search = optional_param('search','',PARAM_CLEAN);
18 $roleid = optional_param('roleid', 0, PARAM_INT); // optional roleid
20 $contextid = optional_param('contextid', 0, PARAM_INT); // one of this or
21 $courseid = optional_param('id', 0, PARAM_INT); // this are required
23 if ($contextid) {
24 if (! $context = get_context_instance_by_id($contextid)) {
25 error("Context ID is incorrect");
27 if (! $course = get_record('course', 'id', $context->instanceid)) {
28 error("Course ID is incorrect");
30 } else {
31 if (! $course = get_record('course', 'id', $courseid)) {
32 error("Course ID is incorrect");
34 if (! $context = get_context_instance(CONTEXT_COURSE, $course->id)) {
35 error("Context ID is incorrect");
38 // not needed anymore
39 unset($contextid);
40 unset($courseid);
42 require_login($course);
44 $sitecontext = get_context_instance(CONTEXT_SYSTEM);
45 $frontpagectx = get_context_instance(CONTEXT_COURSE, SITEID);
47 if ($context->id != $frontpagectx->id) {
48 if (!has_capability('moodle/course:viewparticipants', $context)) {
49 print_error('nopermissions');
51 } else {
52 if (!has_capability('moodle/site:viewparticipants', $sitecontext)) {
53 print_error('nopermissions');
57 /// front page course is different
58 $rolenames = array();
59 $avoidroles = array();
61 if ($roles = get_roles_used_in_context($context, true)) {
62 // We should ONLY allow roles with moodle/course:view because otherwise we get little niggly issues
63 // like MDL-8093
64 // We should further exclude "admin" users (those with "doanything" at site level) because
65 // Otherwise they appear in every participant list
67 $canviewroles = get_roles_with_capability('moodle/course:view', CAP_ALLOW, $context);
68 $doanythingroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, $sitecontext);
70 foreach ($roles as $role) {
71 if (!isset($canviewroles[$role->id])) { // Avoid this role (eg course creator)
72 $avoidroles[] = $role->id;
73 unset($roles[$role->id]);
74 continue;
76 if (isset($doanythingroles[$role->id])) { // Avoid this role (ie admin)
77 $avoidroles[] = $role->id;
78 unset($roles[$role->id]);
79 continue;
81 $rolenames[$role->id] = strip_tags(role_get_name($role, $context)); // Used in menus etc later on
85 // no roles to display yet?
86 // frontpage course is an exception, on the front page course we should display all users
87 if (empty($rolenames) && $context->id != $frontpagectx->id) {
88 if (has_capability('moodle/role:assign', $context)) {
89 redirect($CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id);
90 } else {
91 error ('No participants found for this course');
95 add_to_log($course->id, 'user', 'view all', 'index.php?id='.$course->id, '');
97 $bulkoperations = has_capability('moodle/course:bulkmessaging', $context);
99 $countries = get_list_of_countries();
101 $strnever = get_string('never');
103 $datestring->year = get_string('year');
104 $datestring->years = get_string('years');
105 $datestring->day = get_string('day');
106 $datestring->days = get_string('days');
107 $datestring->hour = get_string('hour');
108 $datestring->hours = get_string('hours');
109 $datestring->min = get_string('min');
110 $datestring->mins = get_string('mins');
111 $datestring->sec = get_string('sec');
112 $datestring->secs = get_string('secs');
114 if ($mode !== NULL) {
115 $SESSION->userindexmode = $fullmode = ($mode == 1);
116 } else if (isset($SESSION->userindexmode)) {
117 $fullmode = $SESSION->userindexmode;
118 } else {
119 $fullmode = false;
122 /// Check to see if groups are being used in this forum
123 /// and if so, set $currentgroup to reflect the current group
125 $groupmode = groups_get_course_groupmode($course); // Groups are being used
126 $currentgroup = groups_get_course_group($course, true);
128 if (!$currentgroup) { // To make some other functions work better later
129 $currentgroup = NULL;
132 $isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and
133 !has_capability('moodle/site:accessallgroups', $context));
135 if ($isseparategroups and (!$currentgroup) ) {
136 $navlinks = array();
137 $navlinks[] = array('name' => get_string('participants'), 'link' => null, 'type' => 'misc');
138 $navigation = build_navigation($navlinks);
140 print_header("$course->shortname: ".get_string('participants'), $course->fullname, $navigation, "", "", true, "&nbsp;", navmenu($course));
141 print_heading(get_string("notingroup", "forum"));
142 print_footer($course);
143 exit;
146 // Should use this variable so that we don't break stuff every time a variable is added or changed.
147 $baseurl = $CFG->wwwroot.'/user/index.php?contextid='.$context->id.'&amp;roleid='.$roleid.'&amp;id='.$course->id.'&amp;perpage='.$perpage.'&amp;accesssince='.$accesssince.'&amp;search='.s($search);
149 /// Print headers
151 $navlinks = array();
152 $navlinks[] = array('name' => get_string('participants'), 'link' => null, 'type' => 'misc');
153 $navigation = build_navigation($navlinks);
155 print_header("$course->shortname: ".get_string('participants'), $course->fullname, $navigation, "", "", true, "&nbsp;", navmenu($course));
157 /// setting up tags
158 if ($course->id == SITEID) {
159 $filtertype = 'site';
160 } else if ($course->id && !$currentgroup) {
161 $filtertype = 'course';
162 $filterselect = $course->id;
163 } else {
164 $filtertype = 'group';
165 $filterselect = $currentgroup;
167 $currenttab = 'participants';
168 $user = $USER;
170 require_once($CFG->dirroot .'/user/tabs.php');
173 /// Get the hidden field list
174 if (has_capability('moodle/course:viewhiddenuserfields', $context)) {
175 $hiddenfields = array(); // teachers and admins are allowed to see everything
176 } else {
177 $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
181 /// Print settings and things in a table across the top
183 echo '<table class="controls" cellspacing="0"><tr>';
185 /// Print my course menus
186 if ($mycourses = get_my_courses($USER->id)) {
187 echo '<td class="left">';
188 $courselist = array();
189 foreach ($mycourses as $mycourse) {
190 $courselist[$mycourse->id] = format_string($mycourse->shortname);
192 popup_form($CFG->wwwroot.'/user/index.php?roleid='.$roleid.'&amp;sifirst=&amp;silast=&amp;id=',
193 $courselist, 'courseform', $course->id, '', '', '', false, 'self', get_string('mycourses'));
194 echo '</td>';
197 echo '<td class="left">';
198 groups_print_course_menu($course, $baseurl);
199 echo '</td>';
201 // get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
202 // this might not work anymore because you always going to get yourself as the most recent entry? added $USER!=$user ch
203 $minlastaccess = get_field_sql('SELECT min(timeaccess) FROM '.$CFG->prefix.'user_lastaccess WHERE courseid = '.$course->id.' AND timeaccess != 0 AND userid!='.$USER->id);
204 $lastaccess0exists = record_exists('user_lastaccess','courseid',$course->id,'timeaccess',0);
205 $now = usergetmidnight(time());
206 $timeaccess = array();
208 // makes sense for this to go first.
209 $timeoptions[0] = get_string('selectperiod');
211 // days
212 for ($i = 1; $i < 7; $i++) {
213 if (strtotime('-'.$i.' days',$now) >= $minlastaccess) {
214 $timeoptions[strtotime('-'.$i.' days',$now)] = get_string('numdays','moodle',$i);
217 // weeks
218 for ($i = 1; $i < 10; $i++) {
219 if (strtotime('-'.$i.' weeks',$now) >= $minlastaccess) {
220 $timeoptions[strtotime('-'.$i.' weeks',$now)] = get_string('numweeks','moodle',$i);
223 // months
224 for ($i = 2; $i < 12; $i++) {
225 if (strtotime('-'.$i.' months',$now) >= $minlastaccess) {
226 $timeoptions[strtotime('-'.$i.' months',$now)] = get_string('nummonths','moodle',$i);
229 // try a year
230 if (strtotime('-1 year',$now) >= $minlastaccess) {
231 $timeoptions[strtotime('-1 year',$now)] = get_string('lastyear');
234 if (!empty($lastaccess0exists)) {
235 $timeoptions[-1] = get_string('never');
238 if (count($timeoptions) > 1) {
239 echo '<td class="left">';
240 $baseurl = preg_replace('/&amp;accesssince='.$accesssince.'/','',$baseurl);
241 popup_form($baseurl.'&amp;accesssince=',$timeoptions,'timeoptions',$accesssince, '', '', '', false, 'self', get_string('usersnoaccesssince'));
242 echo '</td>';
246 echo '<td class="right">';
247 $formatmenu = array( '0' => get_string('detailedless'),
248 '1' => get_string('detailedmore'));
249 popup_form($baseurl.'&amp;mode=', $formatmenu, 'formatmenu', $fullmode, '', '', '', false, 'self', get_string('userlist'));
250 echo '</td></tr></table>';
252 if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', $context))) { /// Display info about the group
253 if ($group = groups_get_group($currentgroup)) {
254 if (!empty($group->description) or (!empty($group->picture) and empty($group->hidepicture))) {
255 echo '<table class="groupinfobox"><tr><td class="left side picture">';
256 print_group_picture($group, $course->id, true, false, false);
257 echo '</td><td class="content">';
258 echo '<h3>'.$group->name;
259 if (has_capability('moodle/course:managegroups', $context)) {
260 echo '&nbsp;<a title="'.get_string('editgroupprofile').'" href="'.$CFG->wwwroot.'/group/group.php?id='.$group->id.'&amp;courseid='.$group->courseid.'">';
261 echo '<img src="'.$CFG->pixpath.'/t/edit.gif" alt="'.get_string('editgroupprofile').'" />';
262 echo '</a>';
264 echo '</h3>';
265 echo format_text($group->description);
266 echo '</td></tr></table>';
271 /// Define a table showing a list of users in the current role selection
273 $tablecolumns = array('userpic', 'fullname');
274 $tableheaders = array(get_string('userpic'), get_string('fullname'));
275 if (!isset($hiddenfields['city'])) {
276 $tablecolumns[] = 'city';
277 $tableheaders[] = get_string('city');
279 if (!isset($hiddenfields['country'])) {
280 $tablecolumns[] = 'country';
281 $tableheaders[] = get_string('country');
283 if (!isset($hiddenfields['lastaccess'])) {
284 $tablecolumns[] = 'lastaccess';
285 $tableheaders[] = get_string('lastaccess');
288 if ($course->enrolperiod) {
289 $tablecolumns[] = 'timeend';
290 $tableheaders[] = get_string('enrolmentend');
293 if ($bulkoperations) {
294 $tablecolumns[] = '';
295 $tableheaders[] = get_string('select');
298 $table = new flexible_table('user-index-participants-'.$course->id);
300 $table->define_columns($tablecolumns);
301 $table->define_headers($tableheaders);
302 $table->define_baseurl($baseurl);
304 $table->sortable(true, 'lastaccess', SORT_DESC);
306 $table->set_attribute('cellspacing', '0');
307 $table->set_attribute('id', 'participants');
308 $table->set_attribute('class', 'generaltable generalbox');
310 $table->set_control_variables(array(
311 TABLE_VAR_SORT => 'ssort',
312 TABLE_VAR_HIDE => 'shide',
313 TABLE_VAR_SHOW => 'sshow',
314 TABLE_VAR_IFIRST => 'sifirst',
315 TABLE_VAR_ILAST => 'silast',
316 TABLE_VAR_PAGE => 'spage'
318 $table->setup();
321 // we are looking for all users with this role assigned in this context or higher
322 if ($usercontexts = get_parent_contexts($context)) {
323 $listofcontexts = '('.implode(',', $usercontexts).')';
324 } else {
325 $listofcontexts = '('.$sitecontext->id.')'; // must be site
327 if ($roleid) {
328 $selectrole = " AND r.roleid = $roleid ";
329 } else {
330 $selectrole = " ";
333 if ($context->id != $frontpagectx->id) {
334 $select = 'SELECT DISTINCT u.id, u.username, u.firstname, u.lastname,
335 u.email, u.city, u.country, u.picture,
336 u.lang, u.timezone, u.emailstop, u.maildisplay, u.imagealt,
337 COALESCE(ul.timeaccess, 0) AS lastaccess,
338 r.hidden,
339 ctx.id AS ctxid, ctx.path AS ctxpath,
340 ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel ';
341 $select .= $course->enrolperiod?', r.timeend ':'';
342 } else {
343 $select = 'SELECT u.id, u.username, u.firstname, u.lastname,
344 u.email, u.city, u.country, u.picture,
345 u.lang, u.timezone, u.emailstop, u.maildisplay, u.imagealt,
346 u.lastaccess,
347 ctx.id AS ctxid, ctx.path AS ctxpath,
348 ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel ';
351 if ($context->id != $frontpagectx->id) {
352 $from = "FROM {$CFG->prefix}user u
353 LEFT OUTER JOIN {$CFG->prefix}context ctx
354 ON (u.id=ctx.instanceid AND ctx.contextlevel = ".CONTEXT_USER.")
355 JOIN {$CFG->prefix}role_assignments r
356 ON u.id=r.userid
357 LEFT OUTER JOIN {$CFG->prefix}user_lastaccess ul
358 ON (r.userid=ul.userid and ul.courseid = $course->id) ";
359 } else {
360 $from = "FROM {$CFG->prefix}user u
361 LEFT OUTER JOIN {$CFG->prefix}context ctx
362 ON (u.id=ctx.instanceid AND ctx.contextlevel = ".CONTEXT_USER.") ";
366 $hiddensql = has_capability('moodle/role:viewhiddenassigns', $context)? '':' AND r.hidden = 0 ';
368 // exclude users with roles we are avoiding
369 if ($avoidroles) {
370 $adminroles = 'AND r.roleid NOT IN (';
371 $adminroles .= implode(',', $avoidroles);
372 $adminroles .= ')';
373 } else {
374 $adminroles = '';
377 // join on 2 conditions
378 // otherwise we run into the problem of having records in ul table, but not relevant course
379 // and user record is not pulled out
381 if ($context->id != $frontpagectx->id) {
382 $where = "WHERE (r.contextid = $context->id OR r.contextid in $listofcontexts)
383 AND u.deleted = 0 $selectrole
384 AND (ul.courseid = $course->id OR ul.courseid IS NULL)
385 AND u.username != 'guest'
386 $adminroles
387 $hiddensql ";
388 $where .= get_lastaccess_sql($accesssince);
389 } else {
390 $where = "WHERE u.deleted = 0
391 AND u.username != 'guest'";
392 $where .= get_lastaccess_sql($accesssince);
394 $wheresearch = '';
396 if (!empty($search)) {
397 $LIKE = sql_ilike();
398 $fullname = sql_fullname('u.firstname','u.lastname');
399 $wheresearch .= ' AND ('. $fullname .' '. $LIKE .'\'%'. $search .'%\' OR email '. $LIKE .'\'%'. $search .'%\' OR idnumber '.$LIKE.' \'%'.$search.'%\') ';
403 if ($currentgroup) { // Displaying a group by choice
404 // FIX: TODO: This will not work if $currentgroup == 0, i.e. "those not in a group"
405 $from .= 'LEFT JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid ';
406 $where .= ' AND gm.groupid = '.$currentgroup;
409 $totalcount = count_records_sql('SELECT COUNT(distinct u.id) '.$from.$where); // Each user could have > 1 role
411 if ($table->get_sql_where()) {
412 $where .= ' AND '.$table->get_sql_where();
415 if ($table->get_sql_sort()) {
416 $sort = ' ORDER BY '.$table->get_sql_sort();
417 } else {
418 $sort = '';
421 $matchcount = count_records_sql('SELECT COUNT(distinct u.id) '.$from.$where.$wheresearch);
423 $table->initialbars($totalcount > $perpage);
424 $table->pagesize($perpage, $matchcount);
426 $userlist = get_recordset_sql($select.$from.$where.$wheresearch.$sort,
427 $table->get_page_start(), $table->get_page_size());
429 /// If there are multiple Roles in the course, then show a drop down menu for switching
431 if (count($rolenames) > 1) {
432 echo '<div class="rolesform">';
433 echo get_string('currentrole', 'role').': ';
434 $rolenames = array(0 => get_string('all')) + $rolenames;
435 popup_form("$CFG->wwwroot/user/index.php?contextid=$context->id&amp;sifirst=&amp;silast=&amp;roleid=", $rolenames,
436 'rolesform', $roleid, '');
437 echo '</div>';
440 if ($roleid) {
441 if (!$currentrole = get_record('role','id',$roleid)) {
442 error('That role does not exist');
444 $a->number = $totalcount;
445 $a->role = $currentrole->name;
446 $heading = format_string(get_string('xuserswiththerole', 'role', $a));
447 if (user_can_assign($context, $roleid)) {
448 $heading .= ' <a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?roleid='.$roleid.'&amp;contextid='.$context->id.'">';
449 $heading .= '<img src="'.$CFG->pixpath.'/i/edit.gif" class="icon" alt="" /></a>';
451 print_heading($heading, 'center', 3);
452 } else {
453 if ($matchcount < $totalcount) {
454 print_heading(get_string('allparticipants').': '.$matchcount.'/'.$totalcount, '', 3);
455 } else {
456 print_heading(get_string('allparticipants').': '.$matchcount, '', 3);
461 if ($bulkoperations) {
462 echo '
463 <script type="text/javascript">
464 //<![CDATA[
465 function checksubmit(form) {
466 var destination = form.formaction.options[form.formaction.selectedIndex].value;
467 if (destination == "" || !checkchecked(form)) {
468 form.formaction.selectedIndex = 0;
469 return false;
470 } else {
471 return true;
475 function checkchecked(form) {
476 var inputs = document.getElementsByTagName(\'INPUT\');
477 var checked = false;
478 inputs = filterByParent(inputs, function() {return form;});
479 for(var i = 0; i < inputs.length; ++i) {
480 if (inputs[i].type == \'checkbox\' && inputs[i].checked) {
481 checked = true;
484 return checked;
486 //]]>
487 </script>
489 echo '<form action="action_redir.php" method="post" id="participantsform" onsubmit="return checksubmit(this);">';
490 echo '<div>';
491 echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
492 echo '<input type="hidden" name="returnto" value="'.s($_SERVER['REQUEST_URI']).'" />';
495 if ($CFG->longtimenosee > 0 && $CFG->longtimenosee < 1000 && $totalcount > 0) {
496 echo '<p id="longtimenosee">('.get_string('unusedaccounts', '', $CFG->longtimenosee).')</p>';
499 if ($fullmode) { // Print simple listing
500 if ($totalcount < 1) {
501 print_heading(get_string('nothingtodisplay'));
502 } else {
503 if ($totalcount > $perpage) {
505 $firstinitial = $table->get_initial_first();
506 $lastinitial = $table->get_initial_last();
507 $strall = get_string('all');
508 $alpha = explode(',', get_string('alphabet'));
510 // Bar of first initials
512 echo '<div class="initialbar firstinitial">'.get_string('firstname').' : ';
513 if(!empty($firstinitial)) {
514 echo '<a href="'.$baseurl.'&amp;sifirst=">'.$strall.'</a>';
515 } else {
516 echo '<strong>'.$strall.'</strong>';
518 foreach ($alpha as $letter) {
519 if ($letter == $firstinitial) {
520 echo ' <strong>'.$letter.'</strong>';
521 } else {
522 echo ' <a href="'.$baseurl.'&amp;sifirst='.$letter.'">'.$letter.'</a>';
525 echo '</div>';
527 // Bar of last initials
529 echo '<div class="initialbar lastinitial">'.get_string('lastname').' : ';
530 if(!empty($lastinitial)) {
531 echo '<a href="'.$baseurl.'&amp;silast=">'.$strall.'</a>';
532 } else {
533 echo '<strong>'.$strall.'</strong>';
535 foreach ($alpha as $letter) {
536 if ($letter == $lastinitial) {
537 echo ' <strong>'.$letter.'</strong>';
538 } else {
539 echo ' <a href="'.$baseurl.'&amp;silast='.$letter.'">'.$letter.'</a>';
542 echo '</div>';
544 print_paging_bar($matchcount, intval($table->get_page_start() / $perpage), $perpage, $baseurl.'&amp;', 'spage');
547 if ($matchcount > 0) {
548 while ($user = rs_fetch_next_record($userlist)) {
549 $user = make_context_subobj($user);
550 print_user($user, $course, $bulkoperations);
553 } else {
554 print_heading(get_string('nothingtodisplay'));
558 } else {
559 $countrysort = (strpos($sort, 'country') !== false);
560 $timeformat = get_string('strftimedate');
563 if ($userlist->RecordCount() > 0) {
564 while ($user = rs_fetch_next_record($userlist)) {
565 $user = make_context_subobj($user);
566 if ($user->hidden) {
567 // if the assignment is hidden, display icon
568 $hidden = "<img src=\"{$CFG->pixpath}/t/hide.gif\" alt=\"".get_string('hiddenassign')."\" class=\"hide-show-image\"/>";
569 } else {
570 $hidden = '';
573 if ($user->lastaccess) {
574 $lastaccess = format_time(time() - $user->lastaccess, $datestring);
575 } else {
576 $lastaccess = $strnever;
579 if (empty($user->country)) {
580 $country = '';
582 } else {
583 if($countrysort) {
584 $country = '('.$user->country.') '.$countries[$user->country];
586 else {
587 $country = $countries[$user->country];
591 if (!isset($user->context)) {
592 $usercontext = get_context_instance(CONTEXT_USER, $user->id);
593 } else {
594 $usercontext = $user->context;
597 if ($piclink = ($USER->id == $user->id || has_capability('moodle/user:viewdetails', $context) ||has_capability('moodle/user:viewdetails', $context))) {
598 $profilelink = '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.fullname($user).'</a></strong>';
599 } else {
600 $profilelink = '<strong>'.fullname($user).'</strong>';
603 $data = array (
604 print_user_picture($user, $course->id, $user->picture, false, true, $piclink),
605 $profilelink);
607 if (!isset($hiddenfields['city'])) {
608 $data[] = $user->city;
610 if (!isset($hiddenfields['country'])) {
611 $data[] = $country;
613 if (!isset($hiddenfields['lastaccess'])) {
614 $data[] = $lastaccess;
616 if ($course->enrolperiod) {
617 if ($user->timeend) {
618 $data[] = userdate($user->timeend, $timeformat);
619 } else {
620 $data[] = get_string('unlimited');
623 if ($bulkoperations) {
624 $data[] = '<input type="checkbox" name="user'.$user->id.'" />';
626 $table->add_data($data);
631 $table->print_html();
635 if ($bulkoperations) {
636 echo '<br /><div class="buttons">';
637 echo '<input type="button" onclick="checkall()" value="'.get_string('selectall').'" /> ';
638 echo '<input type="button" onclick="checknone()" value="'.get_string('deselectall').'" /> ';
639 $displaylist = array();
640 // fix for MDL-8885, only show this if user has capability
641 if (has_capability('moodle/site:readallmessages', $context) && !empty($CFG->messaging)) {
642 $displaylist['messageselect.php'] = get_string('messageselectadd');
644 if (has_capability('moodle/notes:manage', $context) && $context->id != $frontpagectx->id) {
645 $displaylist['addnote.php'] = get_string('addnewnote', 'notes');
646 $displaylist['groupaddnote.php'] = get_string('groupaddnewnote', 'notes');
649 if ($context->id != $frontpagectx->id) {
650 $displaylist['extendenrol.php'] = get_string('extendenrol');
651 $displaylist['groupextendenrol.php'] = get_string('groupextendenrol');
654 helpbutton("participantswithselectedusers", get_string("withselectedusers"));
655 choose_from_menu ($displaylist, "formaction", "", get_string("withselectedusers"), "if(checksubmit(this.form))this.form.submit();", "");
656 echo '<input type="hidden" name="id" value="'.$course->id.'" />';
657 echo '<input type="submit" value="' . get_string('ok') . '" />';
658 echo '</div>';
659 echo '</div>';
660 echo '</form>';
664 if ($bulkoperations && $totalcount > ($perpage*3)) {
665 echo '<form action="index.php"><div><input type="hidden" name="id" value="'.$course->id.'" />'.get_string('search').':&nbsp;'."\n";
666 echo '<input type="text" name="search" value="'.s($search).'" />&nbsp;<input type="submit" value="'.get_string('search').'" /></div></form>'."\n";
669 $perpageurl = preg_replace('/&amp;perpage=\d*/','', $baseurl);
670 if ($perpage == SHOW_ALL_PAGE_SIZE) {
671 echo '<div id="showall"><a href="'.$perpageurl.'&amp;perpage='.DEFAULT_PAGE_SIZE.'">'.get_string('showperpage', '', DEFAULT_PAGE_SIZE).'</a></div>';
673 } else if ($matchcount > 0 && $perpage < $matchcount) {
674 echo '<div id="showall"><a href="'.$perpageurl.'&amp;perpage='.SHOW_ALL_PAGE_SIZE.'">'.get_string('showall', '', $matchcount).'</a></div>';
677 print_footer($course);
682 function get_lastaccess_sql($accesssince='') {
683 if (empty($accesssince)) {
684 return '';
686 if ($accesssince == -1) { // never
687 return ' AND ul.timeaccess = 0';
688 } else {
689 return ' AND ul.timeaccess != 0 AND timeaccess < '.$accesssince;