diff --git a/index.php b/index.php
index 0a2fc6d..7330d96 100644
--- a/index.php
+++ b/index.php
@@ -92,7 +92,6 @@ if ($group===0 && $course->groupmode==SEPARATEGROUPS) {
// Get data for user filtering
$manager = new course_enrolment_manager($PAGE, $course);
-$mform = new filter_form($course->id, $filterfields);
$instances = $manager->get_enrolment_instances();
$contextids = $context->get_parent_context_ids(true);
@@ -106,6 +105,7 @@ if (!$role_confirmed or !$role_revoked) {
}
$roles = array($role_confirmed=>$allroles[$role_confirmed], $role_revoked=>$allroles[$role_revoked]);
+$mform = new filter_form($course->id, $filterfields, $roles);
// Generate where clause
$where = array();
@@ -134,6 +134,16 @@ if ($formdata = $mform->get_data()) {
}
}
+// Role filter
+if (array_key_exists('role', $formdata)) {
+ list($in_roles, $param_roles) = $DB->get_in_or_equal(array_keys($formdata->role), SQL_PARAMS_NAMED);
+} else {
+ list($in_roles, $param_roles) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED);
+}
+
+$where[] = "ra.roleid {$in_roles}";
+$where_params = $where_params + $param_roles;
+
list($in_instances, $param_instances) = $DB->get_in_or_equal(array_keys($instances), SQL_PARAMS_NAMED);
list($in_contexts, $param_contexts) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
list($in_fields, $param_fields) = $DB->get_in_or_equal(array_keys($filterfields), SQL_PARAMS_NAMED);
@@ -361,7 +371,7 @@ if ($total > ILBENROL_REPORT_PAGE) {
// Start of table
if (!$csv) {
print '
'; // ugh
-
+ echo $OUTPUT->box_start();
print $pagingbar;
if (!$total) {
@@ -486,32 +496,30 @@ print '';
print $pagingbar;
// Bulk operations
-if (!$csv) {
- echo '
';
- echo '
';
- echo '
';
- echo '';
- $module = array('name'=>'core_user', 'fullpath'=>'/user/module.js');
- $PAGE->requires->js_init_call('M.core_user.init_participation', null, false, $module);
- $displaylist = array();
- $displaylist['confirmenrol'] = get_string('confirmenrol', 'report_ilbenrol');
- $displaylist['revokeenrol'] = get_string('revokeenrol', 'report_ilbenrol');
- echo $OUTPUT->help_icon('withselectedusers', 'report_ilbenrol');
- echo html_writer::tag('label', get_string("withselectedusers"), array('for'=>'formactionid'));
- echo html_writer::select($displaylist, 'formaction', '', array(''=>'choosedots'), array('id'=>'formactionid'));
- echo '
';
- echo '
';
- echo '
';
- echo '
';
-
-}
+echo '
';
+echo '
';
+echo '
';
+echo '';
+$module = array('name'=>'core_user', 'fullpath'=>'/user/module.js');
+$PAGE->requires->js_init_call('M.core_user.init_participation', null, false, $module);
+$displaylist = array();
+$displaylist['confirmenrol'] = get_string('confirmenrol', 'report_ilbenrol');
+$displaylist['revokeenrol'] = get_string('revokeenrol', 'report_ilbenrol');
+echo $OUTPUT->help_icon('withselectedusers', 'report_ilbenrol');
+echo html_writer::tag('label', get_string("withselectedusers"), array('for'=>'formactionid'));
+echo html_writer::select($displaylist, 'formaction', '', array(''=>'choosedots'), array('id'=>'formactionid'));
+echo '
';
+echo '
';
+echo '
';
+echo '
';
print '
';
+echo $OUTPUT->box_end();
echo $OUTPUT->footer();
diff --git a/report_form.php b/report_form.php
index d91f922..ae68973 100644
--- a/report_form.php
+++ b/report_form.php
@@ -35,10 +35,12 @@ require_once("$CFG->libdir/formslib.php");
class filter_form extends moodleform {
protected $_courseid;
protected $_filterfields;
+ protected $_roles;
- function filter_form($courseid, $filterfields, $action=null, $customdata=null, $method='get', $target='', $attributes=null, $editable=true) {
+ function filter_form($courseid, $filterfields, $roles, $action=null, $customdata=null, $method='get', $target='', $attributes=null, $editable=true) {
$this->_filterfields = $filterfields;
- $this->_courseid = $courseid;
+ $this->_courseid = $courseid;
+ $this->_roles = $roles;
parent::moodleform($action, $customdata, $method, $target, $attributes, $editable);
}
@@ -48,8 +50,13 @@ class filter_form extends moodleform {
$mform = $this->_form; // Don't forget the underscore!
$courseid = $this->_courseid;
$filterfields = $this->_filterfields;
+ $roles = $this->_roles;
-// $mform->addElement('header', 'filter', get_string('filter', 'report_ilbenrol'));
+ // Role filter
+ $mform->addElement('header', 'filter', get_string('roles'));
+ foreach ($roles as $role) {
+ $mform->addElement('checkbox', "role[{$role->id}]", $role->localname);
+ }
foreach ($filterfields as $field) {
$mform->addElement('header', $field->shortname, $field->name);