MDL-11517 reserved word MOD used in table alias in questions backup code
[moodle-pu.git] / user / filters / lib.php
blobba6e92dafe1cc76221067bad7ab857cae798c69f
1 <?php //$Id$
3 /**
4 * Library of functions and constants for user filters
5 */
7 require_once($CFG->dirroot . '/user/filters/user_filter_form.php');
9 /**
10 * The base user filter.
12 class user_filter_type {
13 /**
14 * The name of this filter instance.
16 var $_name;
17 /**
18 * The label of this filter instance.
20 var $_label;
21 /**
22 * The field database used for filtering data.
24 var $_field;
25 /**
26 * The value used for filtering data.
28 var $_value;
29 /**
30 * Constructor
31 * @param string $name the name of the filter instance
32 * @param string $label the label of the filter instance
33 * @param string $field the field used for filtering data
34 * @param string $value the value used for filtering data
36 function user_filter_type($name, $label, $field, $value=null) {
37 $this->_name = $name;
38 $this->_label = $label;
39 $this->_field = $field;
40 $this->_value = $value;
43 /**
44 * Returns the condition to be used with SQL where
45 * @return string the filtering condition or null if the filter is disabled
47 function getSQLFilter() {
48 return $this->_field . '="' . $this->_value . '"';
51 /**
52 * Retrieves data from the form data
53 * @param object $formdata data submited with the form
55 function checkData($formdata) {
56 $field = $this->_name;
57 $this->_value = (string)@$formdata->$field;
60 /**
61 * Adds controls specific to this filter in the form.
62 * @param object $mform a MoodleForm object to setup
64 function setupForm(&$mform) {
65 $mform->addElement('text', $this->_name, $this->_label);
66 $mform->setDefault($this->_name, $this->_value);
69 /**
70 * Returns a human friendly description of the filter.
71 * @return string filter description
73 function getDescription() {
74 return $this->_label . ' is "' . $this->_value . '"';