. /** * This file defines the user filter form * * @package report-ilbenrol * @copyrigth 2014 Interlegis (http://www.interlegis.leg.br) * * @author Sesostris Vieira * * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html */ if (!defined('MOODLE_INTERNAL')) { die('Direct access to this script is forbidden.'); } require_once("$CFG->libdir/formslib.php"); class filter_form extends moodleform { protected $_courseid; protected $_filterfields; protected $_roles; function filter_form($courseid, $filterfields, $roles, $action=null, $customdata=null, $method='get', $target='', $attributes=null, $editable=true) { $this->_filterfields = $filterfields; $this->_courseid = $courseid; $this->_roles = $roles; parent::moodleform($action, $customdata, $method, $target, $attributes, $editable); } public function definition() { global $CFG; $mform = $this->_form; // Don't forget the underscore! $courseid = $this->_courseid; $filterfields = $this->_filterfields; $roles = $this->_roles; // 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); $options = explode("\n", $field->param1); foreach ($options as $option) { $mform->addElement('checkbox', "{$field->shortname}[$option]", $option); } } $mform->addElement('submit', 'filterbutton', get_string('applyfilter', 'report_ilbenrol')); $mform->addElement('hidden', 'course', $courseid); $mform->closeHeaderBefore('filterbutton'); } }