Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * This file contains forms used to filter user. 19 * 20 * @package core_user 21 * @category user 22 * @copyright 1999 Martin Dougiamas http://dougiamas.com 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 require_once($CFG->libdir.'/formslib.php'); 27 28 /** 29 * Class user_add_filter_form 30 * @copyright 1999 Martin Dougiamas http://dougiamas.com 31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 32 */ 33 class user_add_filter_form extends moodleform { 34 35 /** 36 * Form definition. 37 */ 38 public function definition() { 39 $mform =& $this->_form; 40 $fields = $this->_customdata['fields']; 41 $extraparams = $this->_customdata['extraparams']; 42 43 $mform->addElement('header', 'newfilter', get_string('newfilter', 'filters')); 44 45 foreach ($fields as $ft) { 46 $ft->setupForm($mform); 47 } 48 49 // In case we wasnt to track some page params. 50 if ($extraparams) { 51 foreach ($extraparams as $key => $value) { 52 $mform->addElement('hidden', $key, $value); 53 $mform->setType($key, PARAM_RAW); 54 } 55 } 56 57 // Add button. 58 $mform->addElement('submit', 'addfilter', get_string('addfilter', 'filters')); 59 } 60 } 61 62 /** 63 * Class user_active_filter_form 64 * @copyright 1999 Martin Dougiamas http://dougiamas.com 65 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 66 */ 67 class user_active_filter_form extends moodleform { 68 69 /** 70 * Form definition. 71 */ 72 public function definition() { 73 global $SESSION; // This is very hacky :-(. 74 75 $mform =& $this->_form; 76 $fields = $this->_customdata['fields']; 77 $extraparams = $this->_customdata['extraparams']; 78 79 if (!empty($SESSION->user_filtering)) { 80 // Add controls for each active filter in the active filters group. 81 $mform->addElement('header', 'actfilterhdr', get_string('actfilterhdr', 'filters')); 82 83 foreach ($SESSION->user_filtering as $fname => $datas) { 84 if (!array_key_exists($fname, $fields)) { 85 continue; // Filter not used. 86 } 87 $field = $fields[$fname]; 88 foreach ($datas as $i => $data) { 89 $description = $field->get_label($data); 90 $mform->addElement('checkbox', 'filter['.$fname.']['.$i.']', null, $description); 91 } 92 } 93 94 if ($extraparams) { 95 foreach ($extraparams as $key => $value) { 96 $mform->addElement('hidden', $key, $value); 97 $mform->setType($key, PARAM_RAW); 98 } 99 } 100 101 $objs = array(); 102 $objs[] = &$mform->createElement('submit', 'removeselected', get_string('removeselected', 'filters')); 103 $objs[] = &$mform->createElement('submit', 'removeall', get_string('removeall', 'filters')); 104 $mform->addElement('group', 'actfiltergrp', '', $objs, ' ', false); 105 } 106 } 107 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body