ÿØÿà JFIF    ÿÛ „  ( %!1"%)+...383-7(-.+  -%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ     ÿÄ @    !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ    ÿÄ '   1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ϗ -3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéߦ$$½—šÙÜCC¯¶è8β–Åkèwx LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2޿د­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÁ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’שT ] ªb—ÊîKC^×M“xùäñz¬zJ× {4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi [0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú Ò˜Æ}2VE•Ѐp¡Ô3Úº …h³^LJºçì¥Ánó|˜ÖˆÎˆ+« ¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<̉Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈ Àá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ ƒÜÒ? :õdsÀ –3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LǐÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl Í›G¹ÀPá¼Nc¡šÒ…ÙWͳœ±vÊáЄ×9‹P‰cEØ‘™›µŸP<×g1 º©Ø¬wiÁ^l5× I/';Ë+´Z‡ÓÄFÕp[Èð’ HÄ ó 9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ QãñQtIeórVB,ÏÂf‹4#Μc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ  ÷jsςҒKÈcø(é›;k(’#ôŒQ ™C> õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~Ȧ—’-$fe«"FâUˆÊwµPÏu w+"åÉó¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ɏdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt ·K¢ÅÅ·¥RÄÊÉbKn N­R2g$VµÕó Qr#–ÓZUÏð0ÎtÙÀœz ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Δâ‘ËØ´IˆÓ°Ë‰ÞM3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z à¾] üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.ž„æ“I[ ª+·zÐÒÚ,½Ð»¶€C›7jk$๖€Ž¾ÅÙpp¶ÍþéΤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ćf× æ¢ƱqWı[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGށ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ ƈæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„ g01¬„åEM蛇Ã\6µE›‘fÙO k÷CºnÓ1`iîÒ² áÂ!ÑLÄÿ ³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#» Ç\……ßïIœÉ$¸ÎñÍ®ÔHÇ Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡ —JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ 5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*禌Éù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnݳvðÖKE¼‚ »mà ÷f®:Ë ™–4rð¡4` ܹçž~‹C=œ…¾Ïj|VDtK.ƒ"9 Ï ­–éXá³6WÒïIL-Ї Ç PK|\ #<>>lib.phpnu[. /** * This file contains the User Filter API. * * @package core_user * @category user * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->dirroot.'/user/filters/text.php'); require_once($CFG->dirroot.'/user/filters/date.php'); require_once($CFG->dirroot.'/user/filters/select.php'); require_once($CFG->dirroot.'/user/filters/simpleselect.php'); require_once($CFG->dirroot.'/user/filters/courserole.php'); require_once($CFG->dirroot.'/user/filters/globalrole.php'); require_once($CFG->dirroot.'/user/filters/profilefield.php'); require_once($CFG->dirroot.'/user/filters/yesno.php'); require_once($CFG->dirroot.'/user/filters/anycourses.php'); require_once($CFG->dirroot.'/user/filters/cohort.php'); require_once($CFG->dirroot.'/user/filters/user_filter_forms.php'); require_once($CFG->dirroot.'/user/filters/checkbox.php'); /** * User filtering wrapper class. * * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filtering { /** @var array */ public $_fields; /** @var \user_add_filter_form */ public $_addform; /** @var \user_active_filter_form */ public $_activeform; /** * Contructor * @param array $fieldnames array of visible user fields * @param string $baseurl base url used for submission/return, null if the same of current page * @param array $extraparams extra page parameters */ public function __construct($fieldnames = null, $baseurl = null, $extraparams = null) { global $SESSION; if (!isset($SESSION->user_filtering)) { $SESSION->user_filtering = array(); } if (empty($fieldnames)) { // As a start, add all fields as advanced fields (which are only available after clicking on "Show more"). $fieldnames = array('realname' => 1, 'lastname' => 1, 'firstname' => 1, 'username' => 1, 'email' => 1, 'city' => 1, 'country' => 1, 'confirmed' => 1, 'suspended' => 1, 'profile' => 1, 'courserole' => 1, 'anycourses' => 1, 'systemrole' => 1, 'cohort' => 1, 'firstaccess' => 1, 'lastaccess' => 1, 'neveraccessed' => 1, 'timecreated' => 1, 'timemodified' => 1, 'nevermodified' => 1, 'auth' => 1, 'mnethostid' => 1, 'idnumber' => 1, 'institution' => 1, 'department' => 1, 'lastip' => 1); // Get the config which filters the admin wanted to show by default. $userfiltersdefault = get_config('core', 'userfiltersdefault'); // If the admin did not enable any filter, the form will not make much sense if all fields are hidden behind // "Show more". Thus, we enable the 'realname' filter automatically. if ($userfiltersdefault == '') { $userfiltersdefault = array('realname'); // Otherwise, we split the enabled filters into an array. } else { $userfiltersdefault = explode(',', $userfiltersdefault); } // Show these fields by default which the admin has enabled in the config. foreach ($userfiltersdefault as $key) { $fieldnames[$key] = 0; } } $this->_fields = array(); foreach ($fieldnames as $fieldname => $advanced) { if ($field = $this->get_field($fieldname, $advanced)) { $this->_fields[$fieldname] = $field; } } // Fist the new filter form. $this->_addform = new user_add_filter_form($baseurl, array('fields' => $this->_fields, 'extraparams' => $extraparams)); if ($adddata = $this->_addform->get_data()) { // Clear previous filters. if (!empty($adddata->replacefilters)) { $SESSION->user_filtering = []; } // Add new filters. foreach ($this->_fields as $fname => $field) { $data = $field->check_data($adddata); if ($data === false) { continue; // Nothing new. } if (!array_key_exists($fname, $SESSION->user_filtering)) { $SESSION->user_filtering[$fname] = array(); } $SESSION->user_filtering[$fname][] = $data; } } // Now the active filters. $this->_activeform = new user_active_filter_form($baseurl, array('fields' => $this->_fields, 'extraparams' => $extraparams)); if ($activedata = $this->_activeform->get_data()) { if (!empty($activedata->removeall)) { $SESSION->user_filtering = array(); } else if (!empty($activedata->removeselected) and !empty($activedata->filter)) { foreach ($activedata->filter as $fname => $instances) { foreach ($instances as $i => $val) { if (empty($val)) { continue; } unset($SESSION->user_filtering[$fname][$i]); } if (empty($SESSION->user_filtering[$fname])) { unset($SESSION->user_filtering[$fname]); } } } } // Rebuild the forms if filters data was processed. if ($adddata || $activedata) { $_POST = []; // Reset submitted data. $this->_addform = new user_add_filter_form($baseurl, ['fields' => $this->_fields, 'extraparams' => $extraparams]); $this->_activeform = new user_active_filter_form($baseurl, ['fields' => $this->_fields, 'extraparams' => $extraparams]); } } /** * Creates known user filter if present * @param string $fieldname * @param boolean $advanced * @return object filter */ public function get_field($fieldname, $advanced) { global $USER, $CFG, $DB, $SITE; switch ($fieldname) { case 'username': return new user_filter_text('username', get_string('username'), $advanced, 'username'); case 'realname': return new user_filter_text('realname', get_string('fullnameuser'), $advanced, $DB->sql_fullname()); case 'lastname': return new user_filter_text('lastname', get_string('lastname'), $advanced, 'lastname'); case 'firstname': return new user_filter_text('firstname', get_string('firstname'), $advanced, 'firstname'); case 'email': return new user_filter_text('email', get_string('email'), $advanced, 'email'); case 'city': return new user_filter_text('city', get_string('city'), $advanced, 'city'); case 'country': return new user_filter_select('country', get_string('country'), $advanced, 'country', get_string_manager()->get_list_of_countries(), $USER->country); case 'confirmed': return new user_filter_yesno('confirmed', get_string('confirmed', 'admin'), $advanced, 'confirmed'); case 'suspended': return new user_filter_yesno('suspended', get_string('suspended', 'auth'), $advanced, 'suspended'); case 'profile': return new user_filter_profilefield('profile', get_string('profilefields', 'admin'), $advanced); case 'courserole': return new user_filter_courserole('courserole', get_string('courserole', 'filters'), $advanced); case 'anycourses': return new user_filter_anycourses('anycourses', get_string('anycourses', 'filters'), $advanced, 'user_enrolments'); case 'systemrole': return new user_filter_globalrole('systemrole', get_string('globalrole', 'role'), $advanced); case 'firstaccess': return new user_filter_date('firstaccess', get_string('firstaccess', 'filters'), $advanced, 'firstaccess'); case 'lastaccess': return new user_filter_date('lastaccess', get_string('lastaccess'), $advanced, 'lastaccess'); case 'neveraccessed': return new user_filter_checkbox('neveraccessed', get_string('neveraccessed', 'filters'), $advanced, 'firstaccess', array('lastaccess_sck', 'lastaccess_eck', 'firstaccess_eck', 'firstaccess_sck')); case 'timecreated': return new user_filter_date('timecreated', get_string('timecreated'), $advanced, 'timecreated'); case 'timemodified': return new user_filter_date('timemodified', get_string('lastmodified'), $advanced, 'timemodified'); case 'nevermodified': return new user_filter_checkbox('nevermodified', get_string('nevermodified', 'filters'), $advanced, array('timemodified', 'timecreated'), array('timemodified_sck', 'timemodified_eck')); case 'cohort': return new user_filter_cohort($advanced); case 'idnumber': return new user_filter_text('idnumber', get_string('idnumber'), $advanced, 'idnumber'); case 'institution': return new user_filter_text('institution', get_string('institution'), $advanced, 'institution'); case 'department': return new user_filter_text('department', get_string('department'), $advanced, 'department'); case 'lastip': return new user_filter_text('lastip', get_string('lastip'), $advanced, 'lastip'); case 'auth': $plugins = core_component::get_plugin_list('auth'); $choices = array(); foreach ($plugins as $auth => $unused) { $choices[$auth] = get_string('pluginname', "auth_{$auth}"); } return new user_filter_simpleselect('auth', get_string('authentication'), $advanced, 'auth', $choices); case 'mnethostid': // Include all hosts even those deleted or otherwise problematic. if (!$hosts = $DB->get_records('mnet_host', null, 'id', 'id, wwwroot, name')) { $hosts = array(); } $choices = array(); foreach ($hosts as $host) { if ($host->id == $CFG->mnet_localhost_id) { $choices[$host->id] = format_string($SITE->fullname).' ('.get_string('local').')'; } else if (empty($host->wwwroot)) { // All hosts. continue; } else { $choices[$host->id] = $host->name.' ('.$host->wwwroot.')'; } } if ($usedhosts = $DB->get_fieldset_sql("SELECT DISTINCT mnethostid FROM {user} WHERE deleted=0")) { foreach ($usedhosts as $hostid) { if (empty($hosts[$hostid])) { $choices[$hostid] = 'id: '.$hostid.' ('.get_string('error').')'; } } } if (count($choices) < 2) { return null; // Filter not needed. } return new user_filter_simpleselect('mnethostid', get_string('mnetidprovider', 'mnet'), $advanced, 'mnethostid', $choices); default: return null; } } /** * Returns sql where statement based on active user filters * @param string $extra sql * @param array $params named params (recommended prefix ex) * @return array sql string and $params */ public function get_sql_filter($extra='', ?array $params=null) { global $SESSION; $sqls = array(); if ($extra != '') { $sqls[] = $extra; } $params = (array)$params; if (!empty($SESSION->user_filtering)) { foreach ($SESSION->user_filtering as $fname => $datas) { if (!array_key_exists($fname, $this->_fields)) { continue; // Filter not used. } $field = $this->_fields[$fname]; foreach ($datas as $i => $data) { list($s, $p) = $field->get_sql_filter($data); $sqls[] = $s; $params = $params + $p; } } } if (empty($sqls)) { return array('', array()); } else { $sqls = implode(' AND ', $sqls); return array($sqls, $params); } } /** * Print the add filter form. */ public function display_add() { $this->_addform->display(); } /** * Print the active filter form. */ public function display_active() { $this->_activeform->display(); } } /** * The base user filter class. All abstract classes must be implemented. * * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_type { /** * The name of this filter instance. * @var string */ public $_name; /** * The label of this filter instance. * @var string */ public $_label; /** * Advanced form element flag * @var bool */ public $_advanced; /** * Constructor * @param string $name the name of the filter instance * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag */ public function __construct($name, $label, $advanced) { $this->_name = $name; $this->_label = $label; $this->_advanced = $advanced; } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function user_filter_type($name, $label, $advanced) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($name, $label, $advanced); } /** * Returns the condition to be used with SQL where * @param array $data filter settings * @return string the filtering condition or null if the filter is disabled */ public function get_sql_filter($data) { throw new \moodle_exception('mustbeoveride', 'debug', '', 'get_sql_filter'); } /** * Retrieves data from the form data * @param stdClass $formdata data submited with the form * @return mixed array filter data or false when filter not set */ public function check_data($formdata) { throw new \moodle_exception('mustbeoveride', 'debug', '', 'check_data'); } /** * Adds controls specific to this filter in the form. * @param moodleform $mform a MoodleForm object to setup */ public function setupForm(&$mform) { throw new \moodle_exception('mustbeoveride', 'debug', '', 'setupForm'); } /** * Returns a human friendly description of the filter used as label. * @param array $data filter settings * @return string active filter label */ public function get_label($data) { throw new \moodle_exception('mustbeoveride', 'debug', '', 'get_label'); } } PK|\څ99courserole.phpnu[. /** * Course role filter * * @package core_user * @category user * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->dirroot .'/user/filters/lib.php'); /** * User filter based on roles in a course identified by its shortname. * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_courserole extends user_filter_type { /** * Constructor * @param string $name the name of the filter instance * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag */ public function __construct($name, $label, $advanced) { parent::__construct($name, $label, $advanced); } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function user_filter_courserole($name, $label, $advanced) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($name, $label, $advanced); } /** * Returns an array of available roles * @return array of availble roles */ public function get_roles() { $context = context_system::instance(); $roles = array(0 => get_string('anyrole', 'filters')) + get_default_enrol_roles($context); return $roles; } /** * Returns an array of course categories * @return array of course categories */ public function get_course_categories() { return array(0 => get_string('anycategory', 'filters')) + core_course_category::make_categories_list(); } /** * Adds controls specific to this filter in the form. * @param moodleform $mform a MoodleForm object to setup */ public function setupForm(&$mform) { $objs = array(); $objs['role'] = $mform->createElement('select', $this->_name .'_rl', null, $this->get_roles()); $objs['role']->setLabel(get_string('courserole', 'filters')); $objs['category'] = $mform->createElement('select', $this->_name .'_ct', null, $this->get_course_categories()); $objs['category']->setLabel(get_string('coursecategory', 'filters')); $objs['value'] = $mform->createElement('text', $this->_name, null); $objs['value']->setLabel(get_string('coursevalue', 'filters')); $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false); $mform->setType($this->_name, PARAM_TEXT); if ($this->_advanced) { $mform->setAdvanced($this->_name.'_grp'); } } /** * Retrieves data from the form data * @param stdClass $formdata data submited with the form * @return mixed array filter data or false when filter not set */ public function check_data($formdata) { $field = $this->_name; $role = $field .'_rl'; $category = $field .'_ct'; if (property_exists($formdata, $field)) { if (empty($formdata->$field) and empty($formdata->$role) and empty($formdata->$category)) { // Nothing selected. return false; } return array('value' => (string)$formdata->$field, 'roleid' => (int)$formdata->$role, 'categoryid' => (int)$formdata->$category); } return false; } /** * Returns the condition to be used with SQL where * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { global $CFG, $DB; static $counter = 0; $pref = 'ex_courserole'.($counter++).'_'; $value = $data['value']; $roleid = $data['roleid']; $categoryid = $data['categoryid']; $params = array(); if (empty($value) and empty($roleid) and empty($categoryid)) { return array('', $params); } $where = "b.contextlevel=50"; if ($roleid) { $where .= " AND a.roleid = :{$pref}roleid"; $params[$pref.'roleid'] = $roleid; } if ($categoryid) { $where .= " AND c.category = :{$pref}categoryid"; $params[$pref.'categoryid'] = $categoryid; } if ($value) { $where .= " AND c.shortname = :{$pref}course"; $params[$pref.'course'] = $value; } return array("id IN (SELECT userid FROM {role_assignments} a INNER JOIN {context} b ON a.contextid=b.id INNER JOIN {course} c ON b.instanceid=c.id WHERE $where)", $params); } /** * Returns a human friendly description of the filter used as label. * @param array $data filter settings * @return string active filter label */ public function get_label($data) { global $DB; $value = $data['value']; $roleid = $data['roleid']; $categoryid = $data['categoryid']; $a = new stdClass(); $a->label = $this->_label; if ($roleid) { $role = $DB->get_record('role', array('id' => $roleid)); $a->rolename = '"'.role_get_name($role).'"'; } else { $a->rolename = get_string('anyrole', 'filters'); } if ($categoryid) { $catname = $DB->get_field('course_categories', 'name', array('id' => $categoryid)); $a->categoryname = '"'.format_string($catname).'"'; } else { $a->categoryname = get_string('anycategory', 'filters'); } if ($value) { $a->coursename = '"'.s($value).'"'; if (!$DB->record_exists('course', array('shortname' => $value))) { return ''.get_string('courserolelabelerror', 'filters', $a).''; } } else { $a->coursename = get_string('anycourse', 'filters'); } return get_string('courserolelabel', 'filters', $a); } } PK|\. /** * Profile field filter. * * @package core_user * @category user * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->dirroot.'/user/filters/lib.php'); /** * User filter based on values of custom profile fields. * * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_profilefield extends user_filter_type { /** * Constructor * @param string $name the name of the filter instance * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag */ public function __construct($name, $label, $advanced) { parent::__construct($name, $label, $advanced); } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function user_filter_profilefield($name, $label, $advanced) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($name, $label, $advanced); } /** * Returns an array of comparison operators * @return array of comparison operators */ public function get_operators() { return array(0 => get_string('contains', 'filters'), 1 => get_string('doesnotcontain', 'filters'), 2 => get_string('isequalto', 'filters'), 3 => get_string('startswith', 'filters'), 4 => get_string('endswith', 'filters'), 5 => get_string('isempty', 'filters'), 6 => get_string('isnotdefined', 'filters'), 7 => get_string('isdefined', 'filters')); } /** * Returns an array of custom profile fields * @return array of profile fields */ public function get_profile_fields() { global $CFG; require_once($CFG->dirroot . '/user/profile/lib.php'); $fieldrecords = profile_get_custom_fields(); foreach ($fieldrecords as $key => $fieldrecord) { $fieldrecords[$key]->name = format_string($fieldrecords[$key]->name, false, ['context' => context_system::instance()]); } $fields = array_combine(array_keys($fieldrecords), array_column($fieldrecords, 'name')); core_collator::asort($fields); $res = array(0 => get_string('anyfield', 'filters')); return $res + $fields; } /** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ public function setupForm(&$mform) { $profilefields = $this->get_profile_fields(); if (empty($profilefields)) { return; } $objs = array(); $objs['field'] = $mform->createElement('select', $this->_name.'_fld', null, $profilefields); $objs['op'] = $mform->createElement('select', $this->_name.'_op', null, $this->get_operators()); $objs['value'] = $mform->createElement('text', $this->_name, null); $objs['field']->setLabel(get_string('profilefilterfield', 'filters')); $objs['op']->setLabel(get_string('profilefilterlimiter', 'filters')); $objs['value']->setLabel(get_string('valuefor', 'filters', $this->_label)); $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false); $mform->setType($this->_name, PARAM_RAW); if ($this->_advanced) { $mform->setAdvanced($this->_name.'_grp'); } } /** * Retrieves data from the form data * @param object $formdata data submited with the form * @return mixed array filter data or false when filter not set */ public function check_data($formdata) { $profilefields = $this->get_profile_fields(); if (empty($profilefields)) { return false; } $field = $this->_name; $operator = $field.'_op'; $profile = $field.'_fld'; if (property_exists($formdata, $profile)) { if ($formdata->$operator < 5 and $formdata->$field === '') { return false; } return array('value' => (string)$formdata->$field, 'operator' => (int)$formdata->$operator, 'profile' => (int)$formdata->$profile); } } /** * Returns the condition to be used with SQL where * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { global $CFG, $DB; static $counter = 0; $name = 'ex_profilefield'.$counter++; $profilefields = $this->get_profile_fields(); if (empty($profilefields)) { return ''; } $profile = $data['profile']; $operator = $data['operator']; $value = $data['value']; $params = array(); if (!array_key_exists($profile, $profilefields)) { return array('', array()); } $where = ""; $op = " IN "; if ($operator < 5 and $value === '') { return ''; } switch($operator) { case 0: // Contains. $where = $DB->sql_like('data', ":$name", false, false); $params[$name] = "%$value%"; break; case 1: // Does not contain. $where = $DB->sql_like('data', ":$name", false, false, true); $params[$name] = "%$value%"; break; case 2: // Equal to. $where = $DB->sql_like('data', ":$name", false, false); $params[$name] = "$value"; break; case 3: // Starts with. $where = $DB->sql_like('data', ":$name", false, false); $params[$name] = "$value%"; break; case 4: // Ends with. $where = $DB->sql_like('data', ":$name", false, false); $params[$name] = "%$value"; break; case 5: // Empty. $where = "data = :$name"; $params[$name] = ""; break; case 6: // Is not defined. $op = " NOT IN "; break; case 7: // Is defined. break; } if ($profile) { if ($where !== '') { $where = " AND $where"; } $where = "fieldid=$profile $where"; } if ($where !== '') { $where = "WHERE $where"; } return array("id $op (SELECT userid FROM {user_info_data} $where)", $params); } /** * Returns a human friendly description of the filter used as label. * @param array $data filter settings * @return string active filter label */ public function get_label($data) { $operators = $this->get_operators(); $profilefields = $this->get_profile_fields(); if (empty($profilefields)) { return ''; } $profile = $data['profile']; $operator = $data['operator']; $value = $data['value']; if (!array_key_exists($profile, $profilefields)) { return ''; } $a = new stdClass(); $a->label = $this->_label; $a->value = $value; $a->profile = $profilefields[$profile]; $a->operator = $operators[$operator]; switch($operator) { case 0: // Contains. case 1: // Doesn't contain. case 2: // Equal to. case 3: // Starts with. case 4: // Ends with. return get_string('profilelabel', 'filters', $a); case 5: // Empty. case 6: // Is not defined. case 7: // Is defined. return get_string('profilelabelnovalue', 'filters', $a); } return ''; } } PK|\EUTL cohort.phpnu[. /** * Cohort filter. * * @package core_user * @category user * @copyright 2011 Petr Skoda * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/user/filters/lib.php'); /** * Generic filter for cohort membership. * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_cohort extends user_filter_type { /** * Constructor * @param boolean $advanced advanced form element flag */ public function __construct($advanced) { parent::__construct('cohort', get_string('idnumber', 'core_cohort'), $advanced); } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function user_filter_cohort($advanced) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($advanced); } /** * Returns an array of comparison operators * @return array of comparison operators */ public function getOperators() { return array(0 => get_string('contains', 'filters'), 1 => get_string('doesnotcontain', 'filters'), 2 => get_string('isequalto', 'filters'), 3 => get_string('startswith', 'filters'), 4 => get_string('endswith', 'filters'), 5 => get_string('isempty', 'filters')); } /** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ public function setupForm(&$mform) { $objs = array(); $objs['select'] = $mform->createElement('select', $this->_name.'_op', null, $this->getOperators()); $objs['text'] = $mform->createElement('text', $this->_name, null); $objs['select']->setLabel(get_string('limiterfor', 'filters', $this->_label)); $objs['text']->setLabel(get_string('valuefor', 'filters', $this->_label)); $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false); $mform->setType($this->_name, PARAM_RAW); $mform->disabledIf($this->_name, $this->_name.'_op', 'eq', 5); if ($this->_advanced) { $mform->setAdvanced($this->_name.'_grp'); } $mform->setDefault($this->_name.'_op', 2); } /** * Retrieves data from the form data * @param object $formdata data submited with the form * @return mixed array filter data or false when filter not set */ public function check_data($formdata) { $field = $this->_name; $operator = $field.'_op'; if (property_exists($formdata, $operator)) { if ($formdata->$operator != 5 and $formdata->$field == '') { // No data - no change except for empty filter. return false; } // If field value is set then use it, else it's null. $fieldvalue = null; if (isset($formdata->$field)) { $fieldvalue = $formdata->$field; } return array('operator' => (int)$formdata->$operator, 'value' => $fieldvalue); } return false; } /** * Returns the condition to be used with SQL where * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { global $DB; static $counter = 0; $name = 'ex_cohort'.$counter++; $operator = $data['operator']; $value = $data['value']; $params = array(); if ($value === '') { return ''; } $not = ''; switch($operator) { case 0: // Contains. $res = $DB->sql_like('idnumber', ":$name", false, false); $params[$name] = "%$value%"; break; case 1: // Does not contain. $not = 'NOT'; $res = $DB->sql_like('idnumber', ":$name", false, false); $params[$name] = "%$value%"; break; case 2: // Equal to. $res = $DB->sql_like('idnumber', ":$name", false, false); $params[$name] = "$value"; break; case 3: // Starts with. $res = $DB->sql_like('idnumber', ":$name", false, false); $params[$name] = "$value%"; break; case 4: // Ends with. $res = $DB->sql_like('idnumber', ":$name", false, false); $params[$name] = "%$value"; break; case 5: // Empty. $not = 'NOT'; $res = '(idnumber IS NOT NULL AND idnumber <> :'.$name.')'; $params[$name] = ''; break; default: return ''; } $sql = "id $not IN (SELECT userid FROM {cohort_members} JOIN {cohort} ON {cohort_members}.cohortid = {cohort}.id WHERE $res)"; return array($sql, $params); } /** * Returns a human friendly description of the filter used as label. * @param array $data filter settings * @return string active filter label */ public function get_label($data) { $operator = $data['operator']; $value = $data['value']; $operators = $this->getOperators(); $a = new stdClass(); $a->label = $this->_label; $a->value = '"'.s($value).'"'; $a->operator = $operators[$operator]; switch ($operator) { case 0: // Contains. case 1: // Doesn't contain. case 2: // Equal to. case 3: // Starts with. case 4: // Ends with. return get_string('textlabel', 'filters', $a); case 5: // Empty. return get_string('textlabelnovalue', 'filters', $a); } return ''; } } PK|\( yesno.phpnu[. /** * Yes/No (boolean) filter. * * @package core_user * @category user * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Generic yes/no filter with radio buttons for integer fields. * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_yesno extends user_filter_simpleselect { /** * Constructor * @param string $name the name of the filter instance * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag * @param string $field user table filed name */ public function __construct($name, $label, $advanced, $field) { parent::__construct($name, $label, $advanced, $field, array(0 => get_string('no'), 1 => get_string('yes'))); } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function user_filter_yesno($name, $label, $advanced, $field) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($name, $label, $advanced, $field); } /** * Returns the condition to be used with SQL * * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { static $counter = 0; $name = 'ex_yesno'.$counter++; $value = $data['value']; $field = $this->_field; if ($value == '') { return array(); } return array("$field=:$name", array($name => $value)); } } PK|\\fsimpleselect.phpnu[. /** * Simple value select filter. * * @package core_user * @category user * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->dirroot.'/user/filters/lib.php'); /** * Generic filter based on a list of values. * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_simpleselect extends user_filter_type { /** * options for the list values * @var array */ public $_options; /** * @var string */ public $_field; /** * Constructor * @param string $name the name of the filter instance * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag * @param string $field user table filed name * @param array $options select options */ public function __construct($name, $label, $advanced, $field, $options) { parent::__construct($name, $label, $advanced); $this->_field = $field; $this->_options = $options; } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function user_filter_simpleselect($name, $label, $advanced, $field, $options) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($name, $label, $advanced, $field, $options); } /** * Adds controls specific to this filter in the form. * @param moodleform $mform a MoodleForm object to setup */ public function setupForm(&$mform) { $choices = array('' => get_string('anyvalue', 'filters')) + $this->_options; $mform->addElement('select', $this->_name, $this->_label, $choices); if ($this->_advanced) { $mform->setAdvanced($this->_name); } } /** * Retrieves data from the form data * @param object $formdata data submited with the form * @return mixed array filter data or false when filter not set */ public function check_data($formdata) { $field = $this->_name; if (property_exists($formdata, $field) and $formdata->$field !== '') { return array('value' => (string)$formdata->$field); } return false; } /** * Returns the condition to be used with SQL where * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { static $counter = 0; $name = 'ex_simpleselect'.$counter++; $value = $data['value']; $params = array(); $field = $this->_field; if ($value == '') { return ''; } return array("$field=:$name", array($name => $value)); } /** * Returns a human friendly description of the filter used as label. * @param array $data filter settings * @return string active filter label */ public function get_label($data) { $value = $data['value']; $a = new stdClass(); $a->label = $this->_label; $a->value = '"'.s($this->_options[$value]).'"'; $a->operator = get_string('isequalto', 'filters'); return get_string('selectlabel', 'filters', $a); } } PK|\ ktext.phpnu[. /** * Text field filter * * @package core_user * @category user * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->dirroot.'/user/filters/lib.php'); /** * Generic filter for text fields. * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_text extends user_filter_type { /** @var string */ public $_field; /** * Constructor * @param string $name the name of the filter instance * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag * @param string $field user table filed name */ public function __construct($name, $label, $advanced, $field) { parent::__construct($name, $label, $advanced); $this->_field = $field; } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function user_filter_text($name, $label, $advanced, $field) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($name, $label, $advanced, $field); } /** * Returns an array of comparison operators * @return array of comparison operators */ public function getOperators() { return array(0 => get_string('contains', 'filters'), 1 => get_string('doesnotcontain', 'filters'), 2 => get_string('isequalto', 'filters'), 3 => get_string('startswith', 'filters'), 4 => get_string('endswith', 'filters'), 5 => get_string('isempty', 'filters')); } /** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ public function setupForm(&$mform) { $objs = array(); $objs['select'] = $mform->createElement('select', $this->_name.'_op', null, $this->getOperators()); $objs['text'] = $mform->createElement('text', $this->_name, null); $objs['select']->setLabel(get_string('limiterfor', 'filters', $this->_label)); $objs['text']->setLabel(get_string('valuefor', 'filters', $this->_label)); $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false); $mform->setType($this->_name, PARAM_RAW); $mform->disabledIf($this->_name, $this->_name.'_op', 'eq', 5); if ($this->_advanced) { $mform->setAdvanced($this->_name.'_grp'); } } /** * Retrieves data from the form data * @param object $formdata data submited with the form * @return mixed array filter data or false when filter not set */ public function check_data($formdata) { $field = $this->_name; $operator = $field.'_op'; if (property_exists($formdata, $operator)) { if ($formdata->$operator != 5 and $formdata->$field == '') { // No data - no change except for empty filter. return false; } // If field value is set then use it, else it's null. $fieldvalue = null; if (isset($formdata->$field)) { $fieldvalue = $formdata->$field; // If we aren't doing a whitespace comparison, an exact match, trim will give us a better result set. $trimmed = trim($fieldvalue); if ($trimmed !== '' && $formdata->$operator != 2) { $fieldvalue = $trimmed; } } return array('operator' => (int)$formdata->$operator, 'value' => $fieldvalue); } return false; } /** * Returns the condition to be used with SQL where * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { global $DB; static $counter = 0; $name = 'ex_text'.$counter++; $operator = $data['operator']; $value = $data['value']; $field = $this->_field; $params = array(); if ($operator != 5 and $value === '') { return ''; } switch($operator) { case 0: // Contains. $res = $DB->sql_like($field, ":$name", false, false); $params[$name] = "%$value%"; break; case 1: // Does not contain. $res = $DB->sql_like($field, ":$name", false, false, true); $params[$name] = "%$value%"; break; case 2: // Equal to. $res = $DB->sql_like($field, ":$name", false, false); $params[$name] = "$value"; break; case 3: // Starts with. $res = $DB->sql_like($field, ":$name", false, false); $params[$name] = "$value%"; break; case 4: // Ends with. $res = $DB->sql_like($field, ":$name", false, false); $params[$name] = "%$value"; break; case 5: // Empty. $res = "$field = :$name"; $params[$name] = ''; break; default: return ''; } return array($res, $params); } /** * Returns a human friendly description of the filter used as label. * @param array $data filter settings * @return string active filter label */ public function get_label($data) { $operator = $data['operator']; $value = $data['value']; $operators = $this->getOperators(); $a = new stdClass(); $a->label = $this->_label; $a->value = '"'.s($value).'"'; $a->operator = $operators[$operator]; switch ($operator) { case 0: // Contains. case 1: // Doesn't contain. case 2: // Equal to. case 3: // Starts with. case 4: // Ends with. return get_string('textlabel', 'filters', $a); case 5: // Empty. return get_string('textlabelnovalue', 'filters', $a); } return ''; } } PK|\eYYanycourses.phpnu[. /** * This is filter is used to see which students are enroled on any courses * * @package core_user * @copyright 2014 Krister Viirsaar * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * User filter to distinguish users with no or any enroled courses. * @copyright 2014 Krister Viirsaar * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_anycourses extends user_filter_yesno { /** * Returns the condition to be used with SQL * * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { $value = $data['value']; $not = $value ? '' : 'NOT'; return array("EXISTS ( SELECT userid FROM {user_enrolments} ) AND " . " id $not IN ( SELECT userid FROM {user_enrolments} )", array()); } } PK|\ңdate.phpnu[. /** * Date filter * * @package core_user * @category user * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->dirroot.'/user/filters/lib.php'); /** * Generic filter based on a date. * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_date extends user_filter_type { /** * the fields available for comparisson * @var string */ public $_field; /** * Constructor * @param string $name the name of the filter instance * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag * @param string $field user table filed name */ public function __construct($name, $label, $advanced, $field) { parent::__construct($name, $label, $advanced); $this->_field = $field; } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function user_filter_date($name, $label, $advanced, $field) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($name, $label, $advanced, $field); } /** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ public function setupForm(&$mform) { $objs = array(); $objs[] = $mform->createElement('static', $this->_name.'_s1', null, html_writer::start_tag('div', array('class' => 'w-100 d-flex align-items-center'))); $objs[] = $mform->createElement('static', $this->_name.'_s2', null, html_writer::tag('div', get_string('isafter', 'filters'), array('class' => 'me-2'))); $objs[] = $mform->createElement('date_selector', $this->_name.'_sdt', null, array('optional' => true)); $objs[] = $mform->createElement('static', $this->_name.'_s3', null, html_writer::end_tag('div')); $objs[] = $mform->createElement('static', $this->_name.'_s4', null, html_writer::start_tag('div', array('class' => 'w-100 d-flex align-items-center'))); $objs[] = $mform->createElement('static', $this->_name.'_s5', null, html_writer::tag('div', get_string('isbefore', 'filters'), array('class' => 'me-2'))); $objs[] = $mform->createElement('date_selector', $this->_name.'_edt', null, array('optional' => true)); $objs[] = $mform->createElement('static', $this->_name.'_s6', null, html_writer::end_tag('div')); $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false); if ($this->_advanced) { $mform->setAdvanced($this->_name.'_grp'); } } /** * Retrieves data from the form data * @param object $formdata data submited with the form * @return mixed array filter data or false when filter not set */ public function check_data($formdata) { $sdt = $this->_name.'_sdt'; $edt = $this->_name.'_edt'; if (!$formdata->$sdt and !$formdata->$edt) { return false; } $data = array(); $data['after'] = $formdata->$sdt; $data['before'] = $formdata->$edt; return $data; } /** * Returns the condition to be used with SQL where * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { $after = (int)$data['after']; $before = (int)$data['before']; $field = $this->_field; if (empty($after) and empty($before)) { return array('', array()); } $res = " $field >= 0 "; if ($after) { $res .= " AND $field >= $after"; } if ($before) { $res .= " AND $field <= $before"; } return array($res, array()); } /** * Returns a human friendly description of the filter used as label. * @param array $data filter settings * @return string active filter label */ public function get_label($data) { $after = $data['after']; $before = $data['before']; $field = $this->_field; $a = new stdClass(); $a->label = $this->_label; $a->after = userdate($after); $a->before = userdate($before); if ($after and $before) { return get_string('datelabelisbetween', 'filters', $a); } else if ($after) { return get_string('datelabelisafter', 'filters', $a); } else if ($before) { return get_string('datelabelisbefore', 'filters', $a); } return ''; } } PK|\ٲYSS select.phpnu[. /** * Value select filter. * * @package core_user * @category user * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->dirroot.'/user/filters/lib.php'); /** * Generic filter based on a list of values. * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_select extends user_filter_type { /** * options for the list values * @var array */ public $_options; /** @var string */ public $_field; /** @var mixed|null */ public $_default; /** * Constructor * @param string $name the name of the filter instance * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag * @param string $field user table filed name * @param array $options select options * @param mixed $default option */ public function __construct($name, $label, $advanced, $field, $options, $default=null) { parent::__construct($name, $label, $advanced); $this->_field = $field; $this->_options = $options; $this->_default = $default; } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function user_filter_select($name, $label, $advanced, $field, $options, $default=null) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($name, $label, $advanced, $field, $options, $default=null); } /** * Returns an array of comparison operators * @return array of comparison operators */ public function get_operators() { return array(0 => get_string('isanyvalue', 'filters'), 1 => get_string('isequalto', 'filters'), 2 => get_string('isnotequalto', 'filters')); } /** * Adds controls specific to this filter in the form. * @param moodleform $mform a MoodleForm object to setup */ public function setupForm(&$mform) { $objs = array(); $objs['limiter'] = $mform->createElement('select', $this->_name.'_op', null, $this->get_operators()); $objs['limiter']->setLabel(get_string('limiterfor', 'filters', $this->_label)); $objs['country'] = $mform->createElement('select', $this->_name, null, $this->_options); $objs['country']->setLabel(get_string('valuefor', 'filters', $this->_label)); $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false); $mform->disabledIf($this->_name, $this->_name.'_op', 'eq', 0); if (!is_null($this->_default)) { $mform->setDefault($this->_name, $this->_default); } if ($this->_advanced) { $mform->setAdvanced($this->_name.'_grp'); } } /** * Retrieves data from the form data * @param stdClass $formdata data submited with the form * @return mixed array filter data or false when filter not set */ public function check_data($formdata) { $field = $this->_name; $operator = $field.'_op'; if (property_exists($formdata, $field) and !empty($formdata->$operator)) { return array('operator' => (int)$formdata->$operator, 'value' => (string)$formdata->$field); } return false; } /** * Returns the condition to be used with SQL where * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { static $counter = 0; $name = 'ex_select'.$counter++; $operator = $data['operator']; $value = $data['value']; $field = $this->_field; $params = array(); switch($operator) { case 1: // Equal to. $res = "=:$name"; $params[$name] = $value; break; case 2: // Not equal to. $res = "<>:$name"; $params[$name] = $value; break; default: return array('', array()); } return array($field.$res, $params); } /** * Returns a human friendly description of the filter used as label. * @param array $data filter settings * @return string active filter label */ public function get_label($data) { $operators = $this->get_operators(); $operator = $data['operator']; $value = $data['value']; if (empty($operator)) { return ''; } $a = new stdClass(); $a->label = $this->_label; $a->value = '"'.s($this->_options[$value]).'"'; $a->operator = $operators[$operator]; return get_string('selectlabel', 'filters', $a); } } PK|\{globalrole.phpnu[. /** * Global role filter * * @package core_user * @category user * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->dirroot.'/user/filters/lib.php'); /** * User filter based on global roles. * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_globalrole extends user_filter_type { /** * Constructor * @param string $name the name of the filter instance * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag */ public function __construct($name, $label, $advanced) { parent::__construct($name, $label, $advanced); } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function user_filter_globalrole($name, $label, $advanced) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($name, $label, $advanced); } /** * Returns an array of available roles * @return array of availble roles */ public function get_roles() { $context = context_system::instance(); $roles = array(0 => get_string('anyrole', 'filters')) + get_assignable_roles($context); return $roles; } /** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ public function setupForm(&$mform) { $obj =& $mform->addElement('select', $this->_name, $this->_label, $this->get_roles()); $mform->setDefault($this->_name, 0); if ($this->_advanced) { $mform->setAdvanced($this->_name); } } /** * Retrieves data from the form data * @param object $formdata data submited with the form * @return mixed array filter data or false when filter not set */ public function check_data($formdata) { $field = $this->_name; if (property_exists($formdata, $field) and !empty($formdata->$field)) { return array('value' => (int)$formdata->$field); } return false; } /** * Returns the condition to be used with SQL where * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { global $CFG; $value = (int)$data['value']; $timenow = round(time(), 100); $sql = "id IN (SELECT userid FROM {role_assignments} a WHERE a.contextid=".SYSCONTEXTID." AND a.roleid=$value)"; return array($sql, array()); } /** * Returns a human friendly description of the filter used as label. * @param array $data filter settings * @return string active filter label */ public function get_label($data) { global $DB; $role = $DB->get_record('role', array('id' => $data['value'])); $a = new stdClass(); $a->label = $this->_label; $a->value = '"'.role_get_name($role).'"'; return get_string('globalrolelabel', 'filters', $a); } } PK|\mK##user_filter_forms.phpnu[. /** * This file contains forms used to filter user. * * @package core_user * @category user * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->libdir.'/formslib.php'); /** * Class user_add_filter_form * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_add_filter_form extends moodleform { /** * Form definition. */ public function definition() { global $SESSION; $mform =& $this->_form; $fields = $this->_customdata['fields']; $extraparams = $this->_customdata['extraparams']; $mform->addElement('header', 'newfilter', get_string('newfilter', 'filters')); foreach ($fields as $ft) { $ft->setupForm($mform); } // In case we wasnt to track some page params. if ($extraparams) { foreach ($extraparams as $key => $value) { $mform->addElement('hidden', $key, $value); $mform->setType($key, PARAM_RAW); } } // Add buttons. $replacefiltersbutton = $mform->createElement('submit', 'replacefilters', get_string('replacefilters', 'filters')); $addfilterbutton = $mform->createElement('submit', 'addfilter', get_string('addfilter', 'filters')); $buttons = array_filter([ empty($SESSION->user_filtering) ? null : $replacefiltersbutton, $addfilterbutton, ]); $mform->addGroup($buttons); } } /** * Class user_active_filter_form * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_active_filter_form extends moodleform { /** * Form definition. */ public function definition() { global $SESSION; // This is very hacky :-(. $mform =& $this->_form; $fields = $this->_customdata['fields']; $extraparams = $this->_customdata['extraparams']; if (!empty($SESSION->user_filtering)) { // Add controls for each active filter in the active filters group. $mform->addElement('header', 'actfilterhdr', get_string('actfilterhdr', 'filters')); foreach ($SESSION->user_filtering as $fname => $datas) { if (!array_key_exists($fname, $fields)) { continue; // Filter not used. } $field = $fields[$fname]; foreach ($datas as $i => $data) { $description = $field->get_label($data); $mform->addElement('checkbox', 'filter['.$fname.']['.$i.']', null, $description); } } if ($extraparams) { foreach ($extraparams as $key => $value) { $mform->addElement('hidden', $key, $value); $mform->setType($key, PARAM_RAW); } } $objs = array(); $objs[] = &$mform->createElement('submit', 'removeselected', get_string('removeselected', 'filters')); $objs[] = &$mform->createElement('submit', 'removeall', get_string('removeall', 'filters')); $mform->addElement('group', 'actfiltergrp', '', $objs, ' ', false); } } } PK|\ى checkbox.phpnu[. /** * Generic checkbox filter. * * This will create generic filter with checkbox option and can be used for * disabling other elements for specific condition. * * @package core_user * @category user * @copyright 2011 Rajesh Taneja * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/user/filters/lib.php'); /** * Generic filter based for checkbox and can be used for disabling items * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_checkbox extends user_filter_type { /** * list of all the fields which needs to be disabled, if checkbox is checked * @var array */ protected $disableelements = array(); /** * name of user table field/fields on which data needs to be compared * @var mixed */ protected $field; /** * Constructor, initalize user_filter_type and sets $disableelements array * with list of elements to be diabled by checkbox. * * @param string $name the name of the filter instance * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag * @param mixed $field user table field/fields name for comparison * @param array $disableelements name of fields which should be disabled if this checkbox is checked. */ public function __construct($name, $label, $advanced, $field, $disableelements=null) { parent::__construct($name, $label, $advanced); $this->field = $field; if (!empty($disableelements)) { if (!is_array($disableelements)) { $this->disableelements = array($disableelements); } else { $this->disableelements = $disableelements; } } } /** * Adds controls specific to this filter in the form. * * @param moodleform $mform a MoodleQuickForm object in which element will be added */ public function setupForm(&$mform) { $mform->addElement('checkbox', $this->_name, $this->_label, ''); if ($this->_advanced) { $mform->setAdvanced($this->_name); } // Check if disable if options are set. if yes then set rules. if (!empty($this->disableelements) && is_array($this->disableelements)) { foreach ($this->disableelements as $disableelement) { $mform->disabledIf($disableelement, $this->_name, 'checked'); } } } /** * Retrieves data from the form data * * @param object $formdata data submited with the form * @return mixed array filter data or false when filter not set */ public function check_data($formdata) { $field = $this->_name; // Check if disable if options are set. if yes then don't add this.. if (!empty($this->disableelements) && is_array($this->disableelements)) { foreach ($this->disableelements as $disableelement) { if (property_exists($formdata, $disableelement)) { return false; } } } if (property_exists($formdata, $field) and $formdata->$field !== '') { return array('value' => (string)$formdata->$field); } return false; } /** * Returns the condition to be used with SQL where * * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { $field = $this->field; if (is_array($field)) { $res = " {$field[0]} = {$field[1]} "; } else { $res = " {$field} = 0 "; } return array($res, array()); } /** * Returns a human friendly description of the filter used as label. * * @param array $data filter settings * @return string active filter label */ public function get_label($data) { return $this->_label; } } PK|\ #<>>lib.phpnu[PK|\څ99M>courserole.phpnu[PK|\