2009-11-04 08:11:02 +00:00
|
|
|
<?php
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
// Lists all the users within a given course
|
|
|
|
|
2005-06-03 23:20:01 +00:00
|
|
|
require_once('../config.php');
|
2005-04-27 18:30:02 +00:00
|
|
|
require_once($CFG->libdir.'/tablelib.php');
|
2011-01-23 18:34:41 +01:00
|
|
|
require_once($CFG->libdir.'/filelib.php');
|
2004-01-10 16:41:29 +00:00
|
|
|
|
|
|
|
define('USER_SMALL_CLASS', 20); // Below this is considered small
|
|
|
|
define('USER_LARGE_CLASS', 200); // Above this is considered large
|
2005-06-03 23:20:01 +00:00
|
|
|
define('DEFAULT_PAGE_SIZE', 20);
|
2006-09-15 14:32:35 +00:00
|
|
|
define('SHOW_ALL_PAGE_SIZE', 5000);
|
2007-11-23 00:23:39 +00:00
|
|
|
define('MODE_BRIEF', 0);
|
|
|
|
define('MODE_USERDETAILS', 1);
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2005-06-03 23:20:01 +00:00
|
|
|
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
|
|
|
$perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT); // how many per page
|
2010-09-05 12:35:51 +00:00
|
|
|
$mode = optional_param('mode', NULL, PARAM_INT); // use the MODE_ constants
|
2008-04-18 08:35:16 +00:00
|
|
|
$accesssince = optional_param('accesssince',0,PARAM_INT); // filter by last access. -1 = never
|
2010-09-02 18:25:30 +00:00
|
|
|
$search = optional_param('search','',PARAM_RAW); // make sure it is processed with p() or s() when sending to output!
|
|
|
|
$roleid = optional_param('roleid', 0, PARAM_INT); // optional roleid, 0 means all enrolled users (or all on the frontpage)
|
2006-08-14 08:38:49 +00:00
|
|
|
|
2008-04-18 08:35:16 +00:00
|
|
|
$contextid = optional_param('contextid', 0, PARAM_INT); // one of this or
|
|
|
|
$courseid = optional_param('id', 0, PARAM_INT); // this are required
|
2009-08-18 05:19:25 +00:00
|
|
|
|
2010-01-16 15:39:56 +00:00
|
|
|
$PAGE->set_url('/user/index.php', array(
|
2009-11-04 08:11:02 +00:00
|
|
|
'page' => $page,
|
|
|
|
'perpage' => $perpage,
|
|
|
|
'mode' => $mode,
|
|
|
|
'accesssince' => $accesssince,
|
|
|
|
'search' => $search,
|
|
|
|
'roleid' => $roleid,
|
|
|
|
'contextid' => $contextid,
|
2009-09-08 08:58:45 +00:00
|
|
|
'courseid' => $courseid));
|
2005-11-17 03:09:07 +00:00
|
|
|
|
2006-08-14 08:38:49 +00:00
|
|
|
if ($contextid) {
|
2010-03-31 07:41:31 +00:00
|
|
|
$context = get_context_instance_by_id($contextid, MUST_EXIST);
|
|
|
|
if ($context->contextlevel != CONTEXT_COURSE) {
|
2008-07-21 07:18:58 +00:00
|
|
|
print_error('invalidcontext');
|
2006-08-14 08:38:49 +00:00
|
|
|
}
|
2010-03-31 07:41:31 +00:00
|
|
|
$course = $DB->get_record('course', array('id'=>$context->instanceid), '*', MUST_EXIST);
|
2006-08-14 08:38:49 +00:00
|
|
|
} else {
|
2010-03-31 07:41:31 +00:00
|
|
|
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2006-10-01 19:55:47 +00:00
|
|
|
// not needed anymore
|
|
|
|
unset($contextid);
|
|
|
|
unset($courseid);
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2007-03-05 20:13:16 +00:00
|
|
|
require_login($course);
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2008-07-28 07:17:34 +00:00
|
|
|
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
2010-03-31 07:41:31 +00:00
|
|
|
$isfrontpage = ($course->id == SITEID);
|
|
|
|
|
2007-10-02 03:37:30 +00:00
|
|
|
$frontpagectx = get_context_instance(CONTEXT_COURSE, SITEID);
|
2007-03-05 20:13:16 +00:00
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
if ($isfrontpage) {
|
2010-05-14 07:07:15 +00:00
|
|
|
$PAGE->set_pagelayout('admin');
|
2008-07-28 07:17:34 +00:00
|
|
|
require_capability('moodle/site:viewparticipants', $systemcontext);
|
2010-03-31 07:41:31 +00:00
|
|
|
} else {
|
2010-05-14 07:07:15 +00:00
|
|
|
$PAGE->set_pagelayout('incourse');
|
2010-03-31 07:41:31 +00:00
|
|
|
require_capability('moodle/course:viewparticipants', $context);
|
2006-11-20 20:47:17 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 03:40:04 +00:00
|
|
|
$rolenamesurl = new moodle_url("$CFG->wwwroot/user/index.php?contextid=$context->id&sifirst=&silast=");
|
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
$allroles = get_all_roles();
|
|
|
|
$roles = get_profile_roles($context);
|
|
|
|
$allrolenames = array();
|
|
|
|
if ($isfrontpage) {
|
|
|
|
$rolenames = array(0=>get_string('allsiteusers', 'role'));
|
|
|
|
} else {
|
|
|
|
$rolenames = array(0=>get_string('allparticipants'));
|
|
|
|
}
|
2008-04-18 08:35:16 +00:00
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
foreach ($allroles as $role) {
|
|
|
|
$allrolenames[$role->id] = strip_tags(role_get_name($role, $context)); // Used in menus etc later on
|
|
|
|
if (isset($roles[$role->id])) {
|
|
|
|
$rolenames[$role->id] = $allrolenames[$role->id];
|
2006-08-25 08:27:27 +00:00
|
|
|
}
|
2006-11-20 20:47:17 +00:00
|
|
|
}
|
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
// make sure other roles may not be selected by any means
|
|
|
|
if (empty($rolenames[$roleid])) {
|
|
|
|
print_error('noparticipants');
|
2008-04-18 08:35:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// no roles to display yet?
|
2007-10-02 03:37:30 +00:00
|
|
|
// frontpage course is an exception, on the front page course we should display all users
|
2010-03-31 07:41:31 +00:00
|
|
|
if (empty($rolenames) && !$isfrontpage) {
|
2007-08-31 08:21:16 +00:00
|
|
|
if (has_capability('moodle/role:assign', $context)) {
|
2006-10-01 19:55:47 +00:00
|
|
|
redirect($CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id);
|
2006-08-25 08:27:27 +00:00
|
|
|
} else {
|
2008-07-21 07:18:58 +00:00
|
|
|
print_error('noparticipants');
|
2006-08-25 08:27:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-03 23:20:01 +00:00
|
|
|
add_to_log($course->id, 'user', 'view all', 'index.php?id='.$course->id, '');
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2006-09-28 06:41:07 +00:00
|
|
|
$bulkoperations = has_capability('moodle/course:bulkmessaging', $context);
|
2005-11-17 03:09:07 +00:00
|
|
|
|
2010-04-14 14:27:10 +00:00
|
|
|
$countries = get_string_manager()->get_list_of_countries();
|
2005-04-27 18:30:02 +00:00
|
|
|
|
2005-06-03 23:20:01 +00:00
|
|
|
$strnever = get_string('never');
|
2005-04-27 18:30:02 +00:00
|
|
|
|
2007-02-15 03:14:40 +00:00
|
|
|
$datestring->year = get_string('year');
|
|
|
|
$datestring->years = get_string('years');
|
2005-06-03 23:20:01 +00:00
|
|
|
$datestring->day = get_string('day');
|
|
|
|
$datestring->days = get_string('days');
|
|
|
|
$datestring->hour = get_string('hour');
|
|
|
|
$datestring->hours = get_string('hours');
|
|
|
|
$datestring->min = get_string('min');
|
|
|
|
$datestring->mins = get_string('mins');
|
|
|
|
$datestring->sec = get_string('sec');
|
|
|
|
$datestring->secs = get_string('secs');
|
2002-09-22 14:06:38 +00:00
|
|
|
|
2005-03-22 16:04:10 +00:00
|
|
|
if ($mode !== NULL) {
|
2007-11-23 00:23:39 +00:00
|
|
|
$mode = (int)$mode;
|
|
|
|
$SESSION->userindexmode = $mode;
|
2005-03-22 16:04:10 +00:00
|
|
|
} else if (isset($SESSION->userindexmode)) {
|
2007-11-23 00:23:39 +00:00
|
|
|
$mode = (int)$SESSION->userindexmode;
|
2005-03-22 16:04:10 +00:00
|
|
|
} else {
|
2007-11-23 00:23:39 +00:00
|
|
|
$mode = MODE_BRIEF;
|
2005-03-22 16:04:10 +00:00
|
|
|
}
|
|
|
|
|
2008-05-28 15:01:50 +00:00
|
|
|
/// Check to see if groups are being used in this course
|
2005-03-22 16:04:10 +00:00
|
|
|
/// and if so, set $currentgroup to reflect the current group
|
|
|
|
|
2007-09-08 20:53:05 +00:00
|
|
|
$groupmode = groups_get_course_groupmode($course); // Groups are being used
|
|
|
|
$currentgroup = groups_get_course_group($course, true);
|
2005-03-22 16:04:10 +00:00
|
|
|
|
2005-06-03 23:20:01 +00:00
|
|
|
if (!$currentgroup) { // To make some other functions work better later
|
|
|
|
$currentgroup = NULL;
|
|
|
|
}
|
2005-03-22 16:04:10 +00:00
|
|
|
|
2009-04-09 07:58:49 +00:00
|
|
|
$isseparategroups = ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context));
|
2004-01-31 04:08:10 +00:00
|
|
|
|
2009-09-08 09:07:20 +00:00
|
|
|
if ($course->id===SITEID) {
|
|
|
|
$PAGE->navbar->ignore_active();
|
|
|
|
}
|
|
|
|
|
2009-09-02 08:36:16 +00:00
|
|
|
$PAGE->navbar->add(get_string('participants'));
|
|
|
|
$PAGE->set_title("$course->shortname: ".get_string('participants'));
|
|
|
|
$PAGE->set_heading($course->fullname);
|
2010-05-04 13:04:35 +00:00
|
|
|
$PAGE->set_pagetype('course-view-' . $course->format);
|
2010-05-16 08:21:12 +00:00
|
|
|
$PAGE->add_body_class('path-user'); // So we can style it independently
|
2010-05-04 13:04:35 +00:00
|
|
|
$PAGE->set_other_editing_capability('moodle/course:manageactivities');
|
2009-09-02 08:36:16 +00:00
|
|
|
|
|
|
|
echo $OUTPUT->header();
|
2007-08-17 19:09:11 +00:00
|
|
|
|
2010-05-16 08:21:12 +00:00
|
|
|
echo '<div class="userlist">';
|
|
|
|
|
2009-09-02 08:36:16 +00:00
|
|
|
if ($isseparategroups and (!$currentgroup) ) {
|
|
|
|
// The user is not in the group so show message and exit
|
2009-08-06 08:15:05 +00:00
|
|
|
echo $OUTPUT->heading(get_string("notingroup"));
|
2009-08-06 14:08:20 +00:00
|
|
|
echo $OUTPUT->footer();
|
2005-03-22 16:04:10 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2010-05-04 13:04:35 +00:00
|
|
|
|
2005-06-03 23:20:01 +00:00
|
|
|
// Should use this variable so that we don't break stuff every time a variable is added or changed.
|
2010-01-16 15:39:56 +00:00
|
|
|
$baseurl = new moodle_url('/user/index.php', array(
|
2009-08-10 03:40:04 +00:00
|
|
|
'contextid' => $context->id,
|
|
|
|
'roleid' => $roleid,
|
|
|
|
'id' => $course->id,
|
|
|
|
'perpage' => $perpage,
|
|
|
|
'accesssince' => $accesssince,
|
|
|
|
'search' => s($search)));
|
2005-03-22 16:04:10 +00:00
|
|
|
|
2007-03-05 20:13:16 +00:00
|
|
|
/// setting up tags
|
2006-08-14 08:38:49 +00:00
|
|
|
if ($course->id == SITEID) {
|
2006-03-09 09:09:20 +00:00
|
|
|
$filtertype = 'site';
|
2006-08-14 08:38:49 +00:00
|
|
|
} else if ($course->id && !$currentgroup) {
|
2006-03-09 09:09:20 +00:00
|
|
|
$filtertype = 'course';
|
2006-08-14 08:38:49 +00:00
|
|
|
$filterselect = $course->id;
|
2006-03-09 09:09:20 +00:00
|
|
|
} else {
|
|
|
|
$filtertype = 'group';
|
|
|
|
$filterselect = $currentgroup;
|
|
|
|
}
|
|
|
|
|
2010-05-04 13:04:35 +00:00
|
|
|
|
2006-03-09 09:09:20 +00:00
|
|
|
|
2005-11-20 21:29:59 +00:00
|
|
|
/// Get the hidden field list
|
2007-03-05 20:13:16 +00:00
|
|
|
if (has_capability('moodle/course:viewhiddenuserfields', $context)) {
|
2005-11-20 21:29:59 +00:00
|
|
|
$hiddenfields = array(); // teachers and admins are allowed to see everything
|
|
|
|
} else {
|
|
|
|
$hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
|
|
|
|
}
|
|
|
|
|
2008-12-01 20:45:46 +00:00
|
|
|
if (isset($hiddenfields['lastaccess'])) {
|
|
|
|
// do not allow access since filtering
|
|
|
|
$accesssince = 0;
|
|
|
|
}
|
2006-08-08 05:13:06 +00:00
|
|
|
|
2005-03-22 16:04:10 +00:00
|
|
|
/// Print settings and things in a table across the top
|
2009-09-08 08:58:45 +00:00
|
|
|
$controlstable = new html_table();
|
2010-03-20 22:15:54 +00:00
|
|
|
$controlstable->attributes['class'] = 'controls';
|
2009-09-08 08:58:45 +00:00
|
|
|
$controlstable->cellspacing = 0;
|
|
|
|
$controlstable->data[] = new html_table_row();
|
2005-03-22 16:04:10 +00:00
|
|
|
|
2006-08-25 08:54:22 +00:00
|
|
|
/// Print my course menus
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
if ($mycourses = enrol_get_my_courses()) {
|
2006-09-13 05:05:17 +00:00
|
|
|
$courselist = array();
|
2010-01-16 15:39:56 +00:00
|
|
|
$popupurl = new moodle_url('/user/index.php?roleid='.$roleid.'&sifirst=&silast=');
|
2006-09-13 05:05:17 +00:00
|
|
|
foreach ($mycourses as $mycourse) {
|
2007-03-15 15:46:53 +00:00
|
|
|
$courselist[$mycourse->id] = format_string($mycourse->shortname);
|
2006-09-13 05:05:17 +00:00
|
|
|
}
|
2008-07-28 07:17:34 +00:00
|
|
|
if (has_capability('moodle/site:viewparticipants', $systemcontext)) {
|
2008-04-18 08:35:16 +00:00
|
|
|
unset($courselist[SITEID]);
|
|
|
|
$courselist = array(SITEID => format_string($SITE->shortname)) + $courselist;
|
|
|
|
}
|
2010-02-10 09:37:50 +00:00
|
|
|
$select = new single_select($popupurl, 'id', $courselist, $course->id, array(''=>'choosedots'), 'courseform');
|
2009-08-10 03:40:04 +00:00
|
|
|
$select->set_label(get_string('mycourses'));
|
2010-02-10 09:37:50 +00:00
|
|
|
$controlstable->data[0]->cells[] = $OUTPUT->render($select);
|
2006-09-13 05:05:17 +00:00
|
|
|
}
|
2006-10-01 19:55:47 +00:00
|
|
|
|
2010-07-19 03:52:38 +00:00
|
|
|
$controlstable->data[0]->cells[] = groups_print_course_menu($course, $baseurl->out(), true);
|
2005-03-22 16:04:10 +00:00
|
|
|
|
2008-12-01 20:45:46 +00:00
|
|
|
if (!isset($hiddenfields['lastaccess'])) {
|
|
|
|
// get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
|
|
|
|
// we need to make it diferently for normal courses and site course
|
2010-03-31 07:41:31 +00:00
|
|
|
if (!$isfrontpage) {
|
2008-12-01 20:45:46 +00:00
|
|
|
$minlastaccess = $DB->get_field_sql('SELECT min(timeaccess)
|
|
|
|
FROM {user_lastaccess}
|
|
|
|
WHERE courseid = ?
|
|
|
|
AND timeaccess != 0', array($course->id));
|
|
|
|
$lastaccess0exists = $DB->record_exists('user_lastaccess', array('courseid'=>$course->id, 'timeaccess'=>0));
|
|
|
|
} else {
|
|
|
|
$minlastaccess = $DB->get_field_sql('SELECT min(lastaccess)
|
|
|
|
FROM {user}
|
|
|
|
WHERE lastaccess != 0');
|
|
|
|
$lastaccess0exists = $DB->record_exists('user', array('lastaccess'=>0));
|
|
|
|
}
|
2008-04-02 06:35:49 +00:00
|
|
|
|
2008-12-01 20:45:46 +00:00
|
|
|
$now = usergetmidnight(time());
|
|
|
|
$timeaccess = array();
|
2009-08-10 03:40:04 +00:00
|
|
|
$baseurl->remove_params('accesssince');
|
2006-10-01 19:55:47 +00:00
|
|
|
|
2008-12-01 20:45:46 +00:00
|
|
|
// makes sense for this to go first.
|
|
|
|
$timeoptions[0] = get_string('selectperiod');
|
2006-10-01 19:55:47 +00:00
|
|
|
|
2008-12-01 20:45:46 +00:00
|
|
|
// days
|
|
|
|
for ($i = 1; $i < 7; $i++) {
|
|
|
|
if (strtotime('-'.$i.' days',$now) >= $minlastaccess) {
|
|
|
|
$timeoptions[strtotime('-'.$i.' days',$now)] = get_string('numdays','moodle',$i);
|
|
|
|
}
|
2006-06-15 21:37:20 +00:00
|
|
|
}
|
2008-12-01 20:45:46 +00:00
|
|
|
// weeks
|
|
|
|
for ($i = 1; $i < 10; $i++) {
|
|
|
|
if (strtotime('-'.$i.' weeks',$now) >= $minlastaccess) {
|
|
|
|
$timeoptions[strtotime('-'.$i.' weeks',$now)] = get_string('numweeks','moodle',$i);
|
|
|
|
}
|
2006-06-15 21:37:20 +00:00
|
|
|
}
|
2008-12-01 20:45:46 +00:00
|
|
|
// months
|
|
|
|
for ($i = 2; $i < 12; $i++) {
|
|
|
|
if (strtotime('-'.$i.' months',$now) >= $minlastaccess) {
|
|
|
|
$timeoptions[strtotime('-'.$i.' months',$now)] = get_string('nummonths','moodle',$i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// try a year
|
|
|
|
if (strtotime('-1 year',$now) >= $minlastaccess) {
|
|
|
|
$timeoptions[strtotime('-1 year',$now)] = get_string('lastyear');
|
2005-11-17 02:46:27 +00:00
|
|
|
}
|
2006-10-01 19:55:47 +00:00
|
|
|
|
2008-12-01 20:45:46 +00:00
|
|
|
if (!empty($lastaccess0exists)) {
|
|
|
|
$timeoptions[-1] = get_string('never');
|
|
|
|
}
|
2006-10-01 19:55:47 +00:00
|
|
|
|
2008-12-01 20:45:46 +00:00
|
|
|
if (count($timeoptions) > 1) {
|
2010-02-10 09:37:50 +00:00
|
|
|
$select = new single_select($baseurl, 'accesssince', $timeoptions, $accesssince, null, 'timeoptions');
|
2009-08-10 03:40:04 +00:00
|
|
|
$select->set_label(get_string('usersnoaccesssince'));
|
2010-02-10 09:37:50 +00:00
|
|
|
$controlstable->data[0]->cells[] = $OUTPUT->render($select);
|
2008-12-01 20:45:46 +00:00
|
|
|
}
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
2006-10-01 19:55:47 +00:00
|
|
|
|
2007-11-23 00:23:39 +00:00
|
|
|
$formatmenu = array( '0' => get_string('brief'),
|
|
|
|
'1' => get_string('userdetails'));
|
2010-02-10 09:37:50 +00:00
|
|
|
$select = new single_select($baseurl, 'mode', $formatmenu, $mode, null, 'formatmenu');
|
2009-08-10 03:40:04 +00:00
|
|
|
$select->set_label(get_string('userlist'));
|
2009-09-08 08:58:45 +00:00
|
|
|
$userlistcell = new html_table_cell();
|
2010-03-20 22:15:54 +00:00
|
|
|
$userlistcell->attributes['class'] = 'right';
|
2010-02-10 09:37:50 +00:00
|
|
|
$userlistcell->text = $OUTPUT->render($select);
|
2009-09-08 08:58:45 +00:00
|
|
|
$controlstable->data[0]->cells[] = $userlistcell;
|
|
|
|
|
2010-03-20 22:15:54 +00:00
|
|
|
echo html_writer::table($controlstable);
|
2005-03-22 16:04:10 +00:00
|
|
|
|
2007-03-05 20:13:16 +00:00
|
|
|
if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', $context))) { /// Display info about the group
|
2007-09-08 20:53:05 +00:00
|
|
|
if ($group = groups_get_group($currentgroup)) {
|
2006-10-01 19:55:47 +00:00
|
|
|
if (!empty($group->description) or (!empty($group->picture) and empty($group->hidepicture))) {
|
2009-09-08 08:58:45 +00:00
|
|
|
$groupinfotable = new html_table();
|
2010-03-20 22:15:54 +00:00
|
|
|
$groupinfotable->attributes['class'] = 'groupinfobox';
|
2009-09-08 08:58:45 +00:00
|
|
|
$picturecell = new html_table_cell();
|
2010-03-20 22:15:54 +00:00
|
|
|
$picturecell->attributes['class'] = 'left side picture';
|
2010-07-19 03:52:38 +00:00
|
|
|
$picturecell->text = print_group_picture($group, $course->id, true, true, false);
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2009-09-08 08:58:45 +00:00
|
|
|
$contentcell = new html_table_cell();
|
2010-03-20 22:15:54 +00:00
|
|
|
$contentcell->attributes['class'] = 'content';
|
2009-09-08 08:58:45 +00:00
|
|
|
|
|
|
|
$contentheading = $group->name;
|
2007-03-05 20:13:16 +00:00
|
|
|
if (has_capability('moodle/course:managegroups', $context)) {
|
2010-01-16 15:39:56 +00:00
|
|
|
$aurl = new moodle_url('/group/group.php', array('id' => $group->id, 'courseid' => $group->courseid));
|
2010-02-16 16:24:49 +00:00
|
|
|
$contentheading .= ' ' . $OUTPUT->action_icon($aurl, new pix_icon('t/edit', get_string('editgroupprofile')));
|
2005-05-03 18:11:34 +00:00
|
|
|
}
|
2009-11-04 06:14:06 +00:00
|
|
|
|
2010-07-03 13:37:13 +00:00
|
|
|
$group->description = file_rewrite_pluginfile_urls($group->description, 'pluginfile.php', $context->id, 'group', 'description', $group->id);
|
2009-11-04 06:14:06 +00:00
|
|
|
if (!isset($group->descriptionformat)) {
|
|
|
|
$group->descriptionformat = FORMAT_MOODLE;
|
|
|
|
}
|
2010-11-05 02:53:47 +00:00
|
|
|
$options = array('overflowdiv'=>true);
|
|
|
|
$contentcell->text = $OUTPUT->heading($contentheading, 3) . format_text($group->description, $group->descriptionformat, $options);
|
2010-02-17 19:33:24 +00:00
|
|
|
$groupinfotable->data[] = new html_table_row(array($picturecell, $contentcell));
|
2010-03-20 22:15:54 +00:00
|
|
|
echo html_writer::table($groupinfotable);
|
2005-03-22 16:04:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-28 06:41:07 +00:00
|
|
|
/// Define a table showing a list of users in the current role selection
|
|
|
|
|
2006-11-13 03:43:12 +00:00
|
|
|
$tablecolumns = array('userpic', 'fullname');
|
2008-03-19 08:49:23 +00:00
|
|
|
$tableheaders = array(get_string('userpic'), get_string('fullnameuser'));
|
2007-11-23 00:23:39 +00:00
|
|
|
if ($mode === MODE_BRIEF && !isset($hiddenfields['city'])) {
|
2006-09-28 06:41:07 +00:00
|
|
|
$tablecolumns[] = 'city';
|
|
|
|
$tableheaders[] = get_string('city');
|
|
|
|
}
|
2007-11-23 00:23:39 +00:00
|
|
|
if ($mode === MODE_BRIEF && !isset($hiddenfields['country'])) {
|
2006-09-28 06:41:07 +00:00
|
|
|
$tablecolumns[] = 'country';
|
|
|
|
$tableheaders[] = get_string('country');
|
|
|
|
}
|
|
|
|
if (!isset($hiddenfields['lastaccess'])) {
|
|
|
|
$tablecolumns[] = 'lastaccess';
|
|
|
|
$tableheaders[] = get_string('lastaccess');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($bulkoperations) {
|
2007-11-23 00:22:56 +00:00
|
|
|
$tablecolumns[] = 'select';
|
2006-09-28 06:41:07 +00:00
|
|
|
$tableheaders[] = get_string('select');
|
|
|
|
}
|
|
|
|
|
2006-10-01 06:18:18 +00:00
|
|
|
$table = new flexible_table('user-index-participants-'.$course->id);
|
2006-09-28 06:41:07 +00:00
|
|
|
|
|
|
|
$table->define_columns($tablecolumns);
|
|
|
|
$table->define_headers($tableheaders);
|
2009-08-10 03:40:04 +00:00
|
|
|
$table->define_baseurl($baseurl->out());
|
2007-08-17 19:09:11 +00:00
|
|
|
|
2008-12-01 20:45:46 +00:00
|
|
|
if (!isset($hiddenfields['lastaccess'])) {
|
|
|
|
$table->sortable(true, 'lastaccess', SORT_DESC);
|
|
|
|
}
|
|
|
|
|
2007-11-23 00:22:56 +00:00
|
|
|
$table->no_sorting('roles');
|
|
|
|
$table->no_sorting('groups');
|
|
|
|
$table->no_sorting('groupings');
|
|
|
|
$table->no_sorting('select');
|
2006-09-28 06:41:07 +00:00
|
|
|
|
|
|
|
$table->set_attribute('cellspacing', '0');
|
2006-10-01 06:18:18 +00:00
|
|
|
$table->set_attribute('id', 'participants');
|
2006-09-28 06:41:07 +00:00
|
|
|
$table->set_attribute('class', 'generaltable generalbox');
|
|
|
|
|
|
|
|
$table->set_control_variables(array(
|
|
|
|
TABLE_VAR_SORT => 'ssort',
|
|
|
|
TABLE_VAR_HIDE => 'shide',
|
|
|
|
TABLE_VAR_SHOW => 'sshow',
|
|
|
|
TABLE_VAR_IFIRST => 'sifirst',
|
|
|
|
TABLE_VAR_ILAST => 'silast',
|
|
|
|
TABLE_VAR_PAGE => 'spage'
|
|
|
|
));
|
|
|
|
$table->setup();
|
|
|
|
|
|
|
|
// we are looking for all users with this role assigned in this context or higher
|
2010-03-31 07:41:31 +00:00
|
|
|
$contextlist = get_related_contexts_string($context);
|
2008-04-18 08:35:16 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
list($esql, $params) = get_enrolled_sql($context, NULL, $currentgroup);
|
2010-03-31 07:41:31 +00:00
|
|
|
$joins = array("FROM {user} u");
|
|
|
|
$wheres = array();
|
|
|
|
|
|
|
|
if ($isfrontpage) {
|
|
|
|
$select = "SELECT u.id, u.username, u.firstname, u.lastname,
|
2008-04-18 08:35:16 +00:00
|
|
|
u.email, u.city, u.country, u.picture,
|
2010-11-05 08:04:40 +00:00
|
|
|
u.lang, u.timezone, u.maildisplay, u.imagealt,
|
2010-03-31 07:41:31 +00:00
|
|
|
u.lastaccess";
|
|
|
|
$joins[] = "JOIN ($esql) e ON e.id = u.id"; // everybody on the frontpage usually
|
|
|
|
if ($accesssince) {
|
|
|
|
$wheres[] = get_user_lastaccess_sql($accesssince);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$select = "SELECT u.id, u.username, u.firstname, u.lastname,
|
2008-04-18 08:35:16 +00:00
|
|
|
u.email, u.city, u.country, u.picture,
|
2010-11-05 08:04:40 +00:00
|
|
|
u.lang, u.timezone, u.maildisplay, u.imagealt,
|
2010-03-31 07:41:31 +00:00
|
|
|
COALESCE(ul.timeaccess, 0) AS lastaccess";
|
|
|
|
$joins[] = "JOIN ($esql) e ON e.id = u.id"; // course enrolled users only
|
|
|
|
$joins[] = "LEFT JOIN {user_lastaccess} ul ON (ul.userid = u.id AND ul.courseid = :courseid)"; // not everybody accessed course yet
|
|
|
|
$params['courseid'] = $course->id;
|
|
|
|
if ($accesssince) {
|
|
|
|
$wheres[] = get_course_lastaccess_sql($accesssince);
|
2008-04-18 08:35:16 +00:00
|
|
|
}
|
2007-10-02 03:37:30 +00:00
|
|
|
}
|
2008-04-18 08:35:16 +00:00
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
// performance hacks - we preload user contexts together with accounts
|
|
|
|
list($ccselect, $ccjoin) = context_instance_preload_sql('u.id', CONTEXT_USER, 'ctx');
|
|
|
|
$select .= $ccselect;
|
|
|
|
$joins[] = $ccjoin;
|
2006-12-04 03:05:40 +00:00
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
|
|
|
|
// limit list to users with some role only
|
|
|
|
if ($roleid) {
|
|
|
|
$wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $contextlist)";
|
|
|
|
$params['roleid'] = $roleid;
|
2006-12-04 03:05:40 +00:00
|
|
|
}
|
2007-08-17 19:09:11 +00:00
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
$from = implode("\n", $joins);
|
|
|
|
if ($wheres) {
|
|
|
|
$where = "WHERE " . implode(" AND ", $wheres);
|
2007-10-02 03:37:30 +00:00
|
|
|
} else {
|
2010-03-31 07:41:31 +00:00
|
|
|
$where = "";
|
2007-10-02 03:37:30 +00:00
|
|
|
}
|
2010-03-31 07:41:31 +00:00
|
|
|
|
|
|
|
$totalcount = $DB->count_records_sql("SELECT COUNT(u.id) $from $where", $params);
|
2006-09-28 06:41:07 +00:00
|
|
|
|
|
|
|
if (!empty($search)) {
|
2008-05-31 11:13:21 +00:00
|
|
|
$fullname = $DB->sql_fullname('u.firstname','u.lastname');
|
2010-09-04 11:46:00 +00:00
|
|
|
$wheres[] = "(". $DB->sql_like($fullname, ':search1', false, false) .
|
|
|
|
" OR ". $DB->sql_like('email', ':search2', false, false) .
|
|
|
|
" OR ". $DB->sql_like('idnumber', ':search3', false, false) .") ";
|
2008-05-31 11:13:21 +00:00
|
|
|
$params['search1'] = "%$search%";
|
|
|
|
$params['search2'] = "%$search%";
|
|
|
|
$params['search3'] = "%$search%";
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
|
|
|
|
2010-09-05 12:35:51 +00:00
|
|
|
list($twhere, $tparams) = $table->get_sql_where();
|
|
|
|
if ($twhere) {
|
|
|
|
$wheres[] = $twhere;
|
|
|
|
$params = array_merge($params, $tparams);
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
$from = implode("\n", $joins);
|
|
|
|
if ($wheres) {
|
|
|
|
$where = "WHERE " . implode(" AND ", $wheres);
|
|
|
|
} else {
|
|
|
|
$where = "";
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($table->get_sql_sort()) {
|
2008-03-24 01:29:30 +00:00
|
|
|
$sort = ' ORDER BY '.$table->get_sql_sort();
|
2006-09-28 06:41:07 +00:00
|
|
|
} else {
|
2008-03-24 01:29:30 +00:00
|
|
|
$sort = '';
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
$matchcount = $DB->count_records_sql("SELECT COUNT(u.id) $from $where", $params);
|
2006-09-28 06:41:07 +00:00
|
|
|
|
2007-12-20 17:43:19 +00:00
|
|
|
$table->initialbars(true);
|
2006-09-28 06:41:07 +00:00
|
|
|
$table->pagesize($perpage, $matchcount);
|
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
// list of users at the current visible page - paging makes it relatively short
|
|
|
|
$userlist = $DB->get_recordset_sql("$select $from $where $sort", $params, $table->get_page_start(), $table->get_page_size());
|
2006-09-28 06:04:39 +00:00
|
|
|
|
2008-04-18 08:35:16 +00:00
|
|
|
/// If there are multiple Roles in the course, then show a drop down menu for switching
|
2006-11-20 20:47:17 +00:00
|
|
|
if (count($rolenames) > 1) {
|
2006-09-28 06:41:07 +00:00
|
|
|
echo '<div class="rolesform">';
|
2008-04-18 08:35:16 +00:00
|
|
|
echo '<label for="rolesform_jump">'.get_string('currentrole', 'role').' </label>';
|
2010-02-10 09:37:50 +00:00
|
|
|
echo $OUTPUT->single_select($rolenamesurl, 'roleid', $rolenames, $roleid, null, 'rolesform');
|
2007-07-31 20:10:05 +00:00
|
|
|
echo '</div>';
|
2008-04-18 08:35:16 +00:00
|
|
|
|
|
|
|
} else if (count($rolenames) == 1) {
|
|
|
|
// when all users with the same role - print its name
|
|
|
|
echo '<div class="rolesform">';
|
2010-07-02 12:15:36 +00:00
|
|
|
echo get_string('role').get_string('labelsep', 'langconfig');
|
2008-04-18 08:35:16 +00:00
|
|
|
$rolename = reset($rolenames);
|
|
|
|
echo $rolename;
|
|
|
|
echo '</div>';
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
2006-09-28 06:04:39 +00:00
|
|
|
|
2008-04-18 08:35:16 +00:00
|
|
|
if ($roleid > 0) {
|
2006-09-28 04:45:39 +00:00
|
|
|
$a->number = $totalcount;
|
2010-03-31 07:41:31 +00:00
|
|
|
$a->role = $rolenames[$roleid];
|
2008-04-18 08:35:16 +00:00
|
|
|
$heading = format_string(get_string('xuserswiththerole', 'role', $a));
|
2008-03-13 12:13:26 +00:00
|
|
|
|
|
|
|
if ($currentgroup and $group) {
|
|
|
|
$a->group = $group->name;
|
2008-04-18 08:35:16 +00:00
|
|
|
$heading .= ' ' . format_string(get_string('ingroup', 'role', $a));
|
|
|
|
}
|
2008-03-13 12:13:26 +00:00
|
|
|
|
|
|
|
if ($accesssince) {
|
|
|
|
$a->timeperiod = $timeoptions[$accesssince];
|
2008-04-18 08:35:16 +00:00
|
|
|
$heading .= ' ' . format_string(get_string('inactiveformorethan', 'role', $a));
|
2008-03-13 12:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$heading .= ": $a->number";
|
2006-09-06 08:55:23 +00:00
|
|
|
if (user_can_assign($context, $roleid)) {
|
2006-09-28 06:04:39 +00:00
|
|
|
$heading .= ' <a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?roleid='.$roleid.'&contextid='.$context->id.'">';
|
2009-12-16 21:50:45 +00:00
|
|
|
$heading .= '<img src="'.$OUTPUT->pix_url('i/edit') . '" class="icon" alt="" /></a>';
|
2006-09-28 06:04:39 +00:00
|
|
|
}
|
2009-08-06 08:55:02 +00:00
|
|
|
echo $OUTPUT->heading($heading, 3);
|
2006-09-28 06:04:39 +00:00
|
|
|
} else {
|
2010-09-22 16:40:53 +00:00
|
|
|
if ($course->id != SITEID && has_capability('moodle/course:enrolreview', $context)) {
|
|
|
|
$editlink = $OUTPUT->action_icon(new moodle_url('/enrol/users.php', array('id' => $course->id)),
|
|
|
|
new pix_icon('i/edit', get_string('edit')));
|
2008-02-29 04:30:27 +00:00
|
|
|
} else {
|
|
|
|
$editlink = '';
|
|
|
|
}
|
2008-04-18 08:35:16 +00:00
|
|
|
if ($course->id == SITEID and $roleid < 0) {
|
|
|
|
$strallparticipants = get_string('allsiteusers', 'role');
|
|
|
|
} else {
|
|
|
|
$strallparticipants = get_string('allparticipants');
|
|
|
|
}
|
2006-10-31 01:21:48 +00:00
|
|
|
if ($matchcount < $totalcount) {
|
2010-07-02 12:15:36 +00:00
|
|
|
echo $OUTPUT->heading($strallparticipants.get_string('labelsep', 'langconfig').$matchcount.'/'.$totalcount . $editlink, 3);
|
2006-10-31 01:21:48 +00:00
|
|
|
} else {
|
2010-07-02 12:15:36 +00:00
|
|
|
echo $OUTPUT->heading($strallparticipants.get_string('labelsep', 'langconfig').$matchcount . $editlink, 3);
|
2006-10-31 01:21:48 +00:00
|
|
|
}
|
2006-09-28 06:04:39 +00:00
|
|
|
}
|
|
|
|
|
2006-09-28 06:41:07 +00:00
|
|
|
|
|
|
|
if ($bulkoperations) {
|
2010-02-11 09:12:17 +00:00
|
|
|
echo '<form action="action_redir.php" method="post" id="participantsform">';
|
2007-01-06 14:07:00 +00:00
|
|
|
echo '<div>';
|
2009-01-02 10:36:25 +00:00
|
|
|
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
2008-04-11 05:34:23 +00:00
|
|
|
echo '<input type="hidden" name="returnto" value="'.s(me()).'" />';
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
if ($mode === MODE_USERDETAILS) { // Print simple listing
|
2006-09-28 06:41:07 +00:00
|
|
|
if ($totalcount < 1) {
|
2009-08-06 08:15:05 +00:00
|
|
|
echo $OUTPUT->heading(get_string('nothingtodisplay'));
|
2006-09-28 06:41:07 +00:00
|
|
|
} else {
|
|
|
|
if ($totalcount > $perpage) {
|
|
|
|
|
|
|
|
$firstinitial = $table->get_initial_first();
|
|
|
|
$lastinitial = $table->get_initial_last();
|
|
|
|
$strall = get_string('all');
|
2010-04-10 17:30:00 +00:00
|
|
|
$alpha = explode(',', get_string('alphabet', 'langconfig'));
|
2006-09-28 06:41:07 +00:00
|
|
|
|
|
|
|
// Bar of first initials
|
|
|
|
|
|
|
|
echo '<div class="initialbar firstinitial">'.get_string('firstname').' : ';
|
|
|
|
if(!empty($firstinitial)) {
|
2009-08-10 03:40:04 +00:00
|
|
|
echo '<a href="'.$baseurl->out().'&sifirst=">'.$strall.'</a>';
|
2006-09-28 06:41:07 +00:00
|
|
|
} else {
|
|
|
|
echo '<strong>'.$strall.'</strong>';
|
|
|
|
}
|
|
|
|
foreach ($alpha as $letter) {
|
|
|
|
if ($letter == $firstinitial) {
|
|
|
|
echo ' <strong>'.$letter.'</strong>';
|
2006-08-09 13:53:12 +00:00
|
|
|
} else {
|
2009-08-10 03:40:04 +00:00
|
|
|
echo ' <a href="'.$baseurl->out().'&sifirst='.$letter.'">'.$letter.'</a>';
|
2006-08-09 13:53:12 +00:00
|
|
|
}
|
|
|
|
}
|
2006-09-28 06:41:07 +00:00
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
// Bar of last initials
|
|
|
|
|
|
|
|
echo '<div class="initialbar lastinitial">'.get_string('lastname').' : ';
|
|
|
|
if(!empty($lastinitial)) {
|
2009-08-10 03:40:04 +00:00
|
|
|
echo '<a href="'.$baseurl->out().'&silast=">'.$strall.'</a>';
|
2006-09-28 06:41:07 +00:00
|
|
|
} else {
|
|
|
|
echo '<strong>'.$strall.'</strong>';
|
|
|
|
}
|
|
|
|
foreach ($alpha as $letter) {
|
|
|
|
if ($letter == $lastinitial) {
|
|
|
|
echo ' <strong>'.$letter.'</strong>';
|
|
|
|
} else {
|
2009-08-10 03:40:04 +00:00
|
|
|
echo ' <a href="'.$baseurl->out().'&silast='.$letter.'">'.$letter.'</a>';
|
2006-08-09 13:53:12 +00:00
|
|
|
}
|
|
|
|
}
|
2006-09-28 06:41:07 +00:00
|
|
|
echo '</div>';
|
|
|
|
|
2010-02-17 16:59:41 +00:00
|
|
|
$pagingbar = new paging_bar($matchcount, intval($table->get_page_start() / $perpage), $perpage, $baseurl);
|
2009-08-07 00:29:44 +00:00
|
|
|
$pagingbar->pagevar = 'spage';
|
2010-04-21 07:36:34 +00:00
|
|
|
echo $OUTPUT->render($pagingbar);
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($matchcount > 0) {
|
2008-03-15 21:57:25 +00:00
|
|
|
$usersprinted = array();
|
2008-05-31 11:13:21 +00:00
|
|
|
foreach ($userlist as $user) {
|
2008-03-15 21:57:25 +00:00
|
|
|
if (in_array($user->id, $usersprinted)) { /// Prevent duplicates by r.hidden - MDL-13935
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$usersprinted[] = $user->id; /// Add new user to the array of users printed
|
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
context_instance_preload($user);
|
2009-08-05 02:03:50 +00:00
|
|
|
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
2010-03-31 07:41:31 +00:00
|
|
|
$usercontext = get_context_instance(CONTEXT_USER, $user->id);
|
2009-08-05 02:03:50 +00:00
|
|
|
|
2010-04-14 14:27:10 +00:00
|
|
|
$countries = get_string_manager()->get_list_of_countries();
|
2009-08-05 02:03:50 +00:00
|
|
|
|
|
|
|
/// Get the hidden field list
|
|
|
|
if (has_capability('moodle/course:viewhiddenuserfields', $context)) {
|
|
|
|
$hiddenfields = array();
|
|
|
|
} else {
|
|
|
|
$hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
|
|
|
|
}
|
|
|
|
$table = new html_table();
|
2010-03-20 22:15:54 +00:00
|
|
|
$table->attributes['class'] = 'userinfobox';
|
2009-08-05 02:03:50 +00:00
|
|
|
|
|
|
|
$row = new html_table_row();
|
|
|
|
$row->cells[0] = new html_table_cell();
|
2010-03-20 22:15:54 +00:00
|
|
|
$row->cells[0]->attributes['class'] = 'left side';
|
2009-08-20 08:50:22 +00:00
|
|
|
|
2010-12-01 08:53:05 +00:00
|
|
|
$row->cells[0]->text = $OUTPUT->user_picture($user, array('size' => 100, 'courseid'=>$course->id));
|
2009-08-05 02:03:50 +00:00
|
|
|
$row->cells[1] = new html_table_cell();
|
2010-03-20 22:15:54 +00:00
|
|
|
$row->cells[1]->attributes['class'] = 'content';
|
2009-08-05 02:03:50 +00:00
|
|
|
|
|
|
|
$row->cells[1]->text = $OUTPUT->container(fullname($user, has_capability('moodle/site:viewfullnames', $context)), 'username');
|
|
|
|
$row->cells[1]->text .= $OUTPUT->container_start('info');
|
|
|
|
|
|
|
|
if (!empty($user->role)) {
|
2010-07-02 12:15:36 +00:00
|
|
|
$row->cells[1]->text .= get_string('role').get_string('labelsep', 'langconfig').$user->role.'<br />';
|
2009-08-05 02:03:50 +00:00
|
|
|
}
|
2009-10-15 03:43:28 +00:00
|
|
|
if ($user->maildisplay == 1 or ($user->maildisplay == 2 and ($course->id != SITEID) and !isguestuser()) or
|
2009-08-05 02:03:50 +00:00
|
|
|
has_capability('moodle/course:viewhiddenuserfields', $context)) {
|
2010-07-02 12:15:36 +00:00
|
|
|
$row->cells[1]->text .= get_string('email').get_string('labelsep', 'langconfig').html_writer::link("mailto:$user->email", $user->email) . '<br />';
|
2009-08-05 02:03:50 +00:00
|
|
|
}
|
|
|
|
if (($user->city or $user->country) and (!isset($hiddenfields['city']) or !isset($hiddenfields['country']))) {
|
2010-07-02 12:15:36 +00:00
|
|
|
$row->cells[1]->text .= get_string('city').get_string('labelsep', 'langconfig');
|
2009-08-05 02:03:50 +00:00
|
|
|
if ($user->city && !isset($hiddenfields['city'])) {
|
|
|
|
$row->cells[1]->text .= $user->city;
|
|
|
|
}
|
|
|
|
if (!empty($countries[$user->country]) && !isset($hiddenfields['country'])) {
|
|
|
|
if ($user->city && !isset($hiddenfields['city'])) {
|
|
|
|
$row->cells[1]->text .= ', ';
|
|
|
|
}
|
|
|
|
$row->cells[1]->text .= $countries[$user->country];
|
|
|
|
}
|
|
|
|
$row->cells[1]->text .= '<br />';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($hiddenfields['lastaccess'])) {
|
|
|
|
if ($user->lastaccess) {
|
2010-07-02 12:15:36 +00:00
|
|
|
$row->cells[1]->text .= get_string('lastaccess').get_string('labelsep', 'langconfig').userdate($user->lastaccess);
|
2009-08-05 02:03:50 +00:00
|
|
|
$row->cells[1]->text .= ' ('. format_time(time() - $user->lastaccess, $datestring) .')';
|
|
|
|
} else {
|
2010-07-02 12:15:36 +00:00
|
|
|
$row->cells[1]->text .= get_string('lastaccess').get_string('labelsep', 'langconfig').get_string('never');
|
2009-08-05 02:03:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$row->cells[1]->text .= $OUTPUT->container_end();
|
2009-08-18 05:19:25 +00:00
|
|
|
|
2009-08-05 02:03:50 +00:00
|
|
|
$row->cells[2] = new html_table_cell();
|
2010-03-20 22:15:54 +00:00
|
|
|
$row->cells[2]->attributes['class'] = 'links';
|
2009-08-05 02:03:50 +00:00
|
|
|
$row->cells[2]->text = '';
|
2009-08-18 05:19:25 +00:00
|
|
|
|
2009-08-05 02:03:50 +00:00
|
|
|
$links = array();
|
|
|
|
|
|
|
|
if ($CFG->bloglevel > 0) {
|
2010-01-16 15:39:56 +00:00
|
|
|
$links[] = html_writer::link(new moodle_url('/blog/index.php?userid='.$user->id), get_string('blogs','blog'));
|
2009-08-05 02:03:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($CFG->enablenotes) and (has_capability('moodle/notes:manage', $context) || has_capability('moodle/notes:view', $context))) {
|
2010-01-16 15:39:56 +00:00
|
|
|
$links[] = html_writer::link(new moodle_url('/notes/index.php?course=' . $course->id. '&user='.$user->id), get_string('notes','notes'));
|
2009-08-05 02:03:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (has_capability('moodle/site:viewreports', $context) or has_capability('moodle/user:viewuseractivitiesreport', $usercontext)) {
|
2010-01-16 15:39:56 +00:00
|
|
|
$links[] = html_writer::link(new moodle_url('/course/user.php?id='. $course->id .'&user='. $user->id), get_string('activity'));
|
2009-08-05 02:03:50 +00:00
|
|
|
}
|
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
if ($USER->id != $user->id && !session_is_loggedinas() && has_capability('moodle/user:loginas', $context) && !is_siteadmin($user->id)) {
|
2010-01-16 15:39:56 +00:00
|
|
|
$links[] = html_writer::link(new moodle_url('/course/loginas.php?id='. $course->id .'&user='. $user->id .'&sesskey='. sesskey()), get_string('loginas'));
|
2009-08-05 02:03:50 +00:00
|
|
|
}
|
|
|
|
|
2010-01-16 15:39:56 +00:00
|
|
|
$links[] = html_writer::link(new moodle_url('/user/view.php?id='. $user->id .'&course='. $course->id), get_string('fullprofile') . '...');
|
2009-08-18 05:19:25 +00:00
|
|
|
|
2010-02-10 09:37:50 +00:00
|
|
|
$row->cells[2]->text .= implode('', $links);
|
2009-08-05 02:03:50 +00:00
|
|
|
|
|
|
|
if (!empty($messageselect)) {
|
|
|
|
$row->cells[2]->text .= '<br /><input type="checkbox" name="user'.$user->id.'" /> ';
|
|
|
|
}
|
|
|
|
$table->data = array($row);
|
2010-03-20 22:15:54 +00:00
|
|
|
echo html_writer::table($table);
|
2006-08-09 13:53:12 +00:00
|
|
|
}
|
2006-09-28 06:41:07 +00:00
|
|
|
|
|
|
|
} else {
|
2009-08-06 08:15:05 +00:00
|
|
|
echo $OUTPUT->heading(get_string('nothingtodisplay'));
|
2006-08-09 13:53:12 +00:00
|
|
|
}
|
|
|
|
}
|
2006-09-28 06:41:07 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
$countrysort = (strpos($sort, 'country') !== false);
|
|
|
|
$timeformat = get_string('strftimedate');
|
2006-11-15 04:28:18 +00:00
|
|
|
|
|
|
|
|
2007-10-10 12:19:27 +00:00
|
|
|
if ($userlist) {
|
2007-11-23 00:22:56 +00:00
|
|
|
|
2008-03-15 21:57:25 +00:00
|
|
|
$usersprinted = array();
|
2008-05-31 11:13:21 +00:00
|
|
|
foreach ($userlist as $user) {
|
2008-03-15 21:57:25 +00:00
|
|
|
if (in_array($user->id, $usersprinted)) { /// Prevent duplicates by r.hidden - MDL-13935
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$usersprinted[] = $user->id; /// Add new user to the array of users printed
|
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
context_instance_preload($user);
|
2007-08-17 19:09:11 +00:00
|
|
|
|
2006-10-01 06:18:18 +00:00
|
|
|
if ($user->lastaccess) {
|
|
|
|
$lastaccess = format_time(time() - $user->lastaccess, $datestring);
|
2006-09-28 06:41:07 +00:00
|
|
|
} else {
|
|
|
|
$lastaccess = $strnever;
|
|
|
|
}
|
|
|
|
|
2006-10-01 06:18:18 +00:00
|
|
|
if (empty($user->country)) {
|
2006-09-28 06:41:07 +00:00
|
|
|
$country = '';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if($countrysort) {
|
2006-10-01 06:18:18 +00:00
|
|
|
$country = '('.$user->country.') '.$countries[$user->country];
|
2006-08-09 13:53:12 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-10-01 06:18:18 +00:00
|
|
|
$country = $countries[$user->country];
|
2006-08-09 13:53:12 +00:00
|
|
|
}
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
2007-08-17 19:09:11 +00:00
|
|
|
|
2010-03-31 07:41:31 +00:00
|
|
|
$usercontext = get_context_instance(CONTEXT_USER, $user->id);
|
2007-08-17 19:09:11 +00:00
|
|
|
|
2008-02-08 03:59:38 +00:00
|
|
|
if ($piclink = ($USER->id == $user->id || has_capability('moodle/user:viewdetails', $context) || has_capability('moodle/user:viewdetails', $usercontext))) {
|
2006-12-07 06:14:52 +00:00
|
|
|
$profilelink = '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id.'">'.fullname($user).'</a></strong>';
|
|
|
|
} else {
|
2007-08-17 19:09:11 +00:00
|
|
|
$profilelink = '<strong>'.fullname($user).'</strong>';
|
2006-12-07 06:14:52 +00:00
|
|
|
}
|
2007-08-17 19:09:11 +00:00
|
|
|
|
2010-12-01 08:53:05 +00:00
|
|
|
$data = array ($OUTPUT->user_picture($user, array('size' => 35, 'courseid'=>$course->id)), $profilelink);
|
2006-12-07 06:14:52 +00:00
|
|
|
|
2007-11-23 00:23:39 +00:00
|
|
|
if ($mode === MODE_BRIEF && !isset($hiddenfields['city'])) {
|
2006-10-01 06:18:18 +00:00
|
|
|
$data[] = $user->city;
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
2007-11-23 00:23:39 +00:00
|
|
|
if ($mode === MODE_BRIEF && !isset($hiddenfields['country'])) {
|
2006-09-28 06:41:07 +00:00
|
|
|
$data[] = $country;
|
|
|
|
}
|
|
|
|
if (!isset($hiddenfields['lastaccess'])) {
|
|
|
|
$data[] = $lastaccess;
|
|
|
|
}
|
2007-11-23 00:22:56 +00:00
|
|
|
|
|
|
|
if (isset($userlist_extra) && isset($userlist_extra[$user->id])) {
|
|
|
|
$ras = $userlist_extra[$user->id]['ra'];
|
|
|
|
$rastring = '';
|
|
|
|
foreach ($ras AS $key=>$ra) {
|
2010-03-31 07:41:31 +00:00
|
|
|
$rolename = $allrolenames[$ra['roleid']] ;
|
2007-11-23 00:22:56 +00:00
|
|
|
if ($ra['ctxlevel'] == CONTEXT_COURSECAT) {
|
2007-11-23 00:23:39 +00:00
|
|
|
$rastring .= $rolename. ' @ ' . '<a href="'.$CFG->wwwroot.'/course/category.php?id='.$ra['ctxinstanceid'].'">'.s($ra['ccname']).'</a>';
|
2007-11-23 00:22:56 +00:00
|
|
|
} elseif ($ra['ctxlevel'] == CONTEXT_SYSTEM) {
|
2007-11-23 00:23:39 +00:00
|
|
|
$rastring .= $rolename. ' - ' . get_string('globalrole','role');
|
2007-11-23 00:22:56 +00:00
|
|
|
} else {
|
|
|
|
$rastring .= $rolename;
|
|
|
|
}
|
|
|
|
}
|
2008-07-21 07:18:58 +00:00
|
|
|
$data[] = $rastring;
|
2007-11-23 00:23:24 +00:00
|
|
|
if ($groupmode != 0) {
|
2007-11-23 00:22:56 +00:00
|
|
|
// htmlescape with s() and implode the array
|
|
|
|
$data[] = implode(', ', array_map('s',$userlist_extra[$user->id]['group']));
|
2010-04-07 07:37:12 +00:00
|
|
|
$data[] = implode(', ', array_map('s', $userlist_extra[$user->id]['gping']));
|
2007-11-23 00:22:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-28 06:41:07 +00:00
|
|
|
if ($bulkoperations) {
|
2010-02-11 09:12:17 +00:00
|
|
|
$data[] = '<input type="checkbox" class="usercheckbox" name="user'.$user->id.'" />';
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
|
|
|
$table->add_data($data);
|
2006-08-09 13:53:12 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2006-09-28 04:45:39 +00:00
|
|
|
|
2006-09-28 06:41:07 +00:00
|
|
|
$table->print_html();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($bulkoperations) {
|
2007-01-06 14:07:00 +00:00
|
|
|
echo '<br /><div class="buttons">';
|
2010-02-11 09:12:17 +00:00
|
|
|
echo '<input type="button" id="checkall" value="'.get_string('selectall').'" /> ';
|
|
|
|
echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" /> ';
|
2007-03-14 01:50:54 +00:00
|
|
|
$displaylist = array();
|
2007-11-21 07:53:42 +00:00
|
|
|
$displaylist['messageselect.php'] = get_string('messageselectadd');
|
2008-08-26 05:45:07 +00:00
|
|
|
if (!empty($CFG->enablenotes) && has_capability('moodle/notes:manage', $context) && $context->id != $frontpagectx->id) {
|
2007-07-05 06:53:17 +00:00
|
|
|
$displaylist['addnote.php'] = get_string('addnewnote', 'notes');
|
|
|
|
$displaylist['groupaddnote.php'] = get_string('groupaddnewnote', 'notes');
|
|
|
|
}
|
2007-11-21 07:53:42 +00:00
|
|
|
|
2010-06-28 14:37:48 +00:00
|
|
|
echo $OUTPUT->help_icon('withselectedusers');
|
2010-02-18 18:15:56 +00:00
|
|
|
echo html_writer::tag('label', get_string("withselectedusers"), array('for'=>'formactionid'));
|
2010-02-11 09:12:17 +00:00
|
|
|
echo html_writer::select($displaylist, 'formaction', '', array(''=>'choosedots'), array('id'=>'formactionid'));
|
|
|
|
|
2006-09-28 06:48:50 +00:00
|
|
|
echo '<input type="hidden" name="id" value="'.$course->id.'" />';
|
2010-02-11 09:12:17 +00:00
|
|
|
echo '<noscript style="display:inline">';
|
2010-10-13 17:39:06 +00:00
|
|
|
echo '<div><input type="submit" value="'.get_string('ok').'" /></div>';
|
2010-02-11 09:12:17 +00:00
|
|
|
echo '</noscript>';
|
|
|
|
echo '</div></div>';
|
2007-01-06 14:07:00 +00:00
|
|
|
echo '</form>';
|
2007-03-26 09:28:58 +00:00
|
|
|
|
2010-02-11 09:12:17 +00:00
|
|
|
$module = array('name'=>'core_user', 'fullpath'=>'/user/module.js');
|
|
|
|
$PAGE->requires->js_init_call('M.core_user.init_participation', null, false, $module);
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
2006-09-28 04:45:39 +00:00
|
|
|
|
2009-10-02 06:51:56 +00:00
|
|
|
if (has_capability('moodle/site:viewparticipants', $context) && $totalcount > ($perpage*3)) {
|
2009-02-04 09:15:12 +00:00
|
|
|
echo '<form action="index.php" class="searchform"><div><input type="hidden" name="id" value="'.$course->id.'" />'.get_string('search').': '."\n";
|
2007-07-04 08:31:54 +00:00
|
|
|
echo '<input type="text" name="search" value="'.s($search).'" /> <input type="submit" value="'.get_string('search').'" /></div></form>'."\n";
|
2006-09-28 06:41:07 +00:00
|
|
|
}
|
2006-09-28 04:45:39 +00:00
|
|
|
|
2009-08-10 03:40:04 +00:00
|
|
|
$perpageurl = clone($baseurl);
|
|
|
|
$perpageurl->remove_params('perpage');
|
2006-09-28 06:41:07 +00:00
|
|
|
if ($perpage == SHOW_ALL_PAGE_SIZE) {
|
2009-08-10 03:40:04 +00:00
|
|
|
$perpageurl->param('perpage', DEFAULT_PAGE_SIZE);
|
2010-01-14 22:10:20 +00:00
|
|
|
echo $OUTPUT->container(html_writer::link($perpageurl, get_string('showperpage', '', DEFAULT_PAGE_SIZE)), array(), 'showall');
|
2006-09-28 06:41:07 +00:00
|
|
|
|
|
|
|
} else if ($matchcount > 0 && $perpage < $matchcount) {
|
2009-08-10 03:40:04 +00:00
|
|
|
$perpageurl->param('perpage', SHOW_ALL_PAGE_SIZE);
|
2010-01-14 22:10:20 +00:00
|
|
|
echo $OUTPUT->container(html_writer::link($perpageurl, get_string('showall', '', $matchcount)), array(), 'showall');
|
2006-09-28 04:45:39 +00:00
|
|
|
}
|
2006-09-28 06:41:07 +00:00
|
|
|
|
2010-05-16 08:21:12 +00:00
|
|
|
echo '</div>'; // userlist
|
|
|
|
|
2009-08-06 14:08:20 +00:00
|
|
|
echo $OUTPUT->footer();
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2007-10-10 12:19:27 +00:00
|
|
|
if ($userlist) {
|
2008-05-31 11:13:21 +00:00
|
|
|
$userlist->close();
|
2007-10-10 12:19:27 +00:00
|
|
|
}
|
2006-09-28 06:41:07 +00:00
|
|
|
|
|
|
|
|
2008-04-02 06:35:49 +00:00
|
|
|
function get_course_lastaccess_sql($accesssince='') {
|
2005-11-17 02:46:27 +00:00
|
|
|
if (empty($accesssince)) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if ($accesssince == -1) { // never
|
2010-03-31 07:41:31 +00:00
|
|
|
return 'ul.timeaccess = 0';
|
2005-11-17 02:46:27 +00:00
|
|
|
} else {
|
2010-03-31 07:41:31 +00:00
|
|
|
return 'ul.timeaccess != 0 AND ul.timeaccess < '.$accesssince;
|
2008-04-02 06:35:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_user_lastaccess_sql($accesssince='') {
|
|
|
|
if (empty($accesssince)) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if ($accesssince == -1) { // never
|
2010-03-31 07:41:31 +00:00
|
|
|
return 'u.lastaccess = 0';
|
2008-04-02 06:35:49 +00:00
|
|
|
} else {
|
2010-03-31 07:41:31 +00:00
|
|
|
return 'u.lastaccess != 0 AND u.lastaccess < '.$accesssince;
|
2005-11-17 02:46:27 +00:00
|
|
|
}
|
|
|
|
}
|