Differences Between: [Versions 310 and 400] [Versions 39 and 400]
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 global $SESSION; 40 41 $mform =& $this->_form; 42 $fields = $this->_customdata['fields']; 43 $extraparams = $this->_customdata['extraparams']; 44 45 $mform->addElement('header', 'newfilter', get_string('newfilter', 'filters')); 46 47 foreach ($fields as $ft) { 48 $ft->setupForm($mform); 49 } 50 51 // In case we wasnt to track some page params. 52 if ($extraparams) { 53 foreach ($extraparams as $key => $value) { 54 $mform->addElement('hidden', $key, $value); 55 $mform->setType($key, PARAM_RAW); 56 } 57 } 58 59 // Add buttons. 60 $replacefiltersbutton = $mform->createElement('submit', 'replacefilters', get_string('replacefilters', 'filters')); 61 $addfilterbutton = $mform->createElement('submit', 'addfilter', get_string('addfilter', 'filters')); 62 $buttons = array_filter([ 63 empty($SESSION->user_filtering) ? null : $replacefiltersbutton, 64 $addfilterbutton, 65 ]); 66 67 $mform->addGroup($buttons); 68 } 69 } 70 71 /** 72 * Class user_active_filter_form 73 * @copyright 1999 Martin Dougiamas http://dougiamas.com 74 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 75 */ 76 class user_active_filter_form extends moodleform { 77 78 /** 79 * Form definition. 80 */ 81 public function definition() { 82 global $SESSION; // This is very hacky :-(. 83 84 $mform =& $this->_form; 85 $fields = $this->_customdata['fields']; 86 $extraparams = $this->_customdata['extraparams']; 87 88 if (!empty($SESSION->user_filtering)) { 89 // Add controls for each active filter in the active filters group. 90 $mform->addElement('header', 'actfilterhdr', get_string('actfilterhdr', 'filters')); 91 92 foreach ($SESSION->user_filtering as $fname => $datas) { 93 if (!array_key_exists($fname, $fields)) { 94 continue; // Filter not used. 95 } 96 $field = $fields[$fname]; 97 foreach ($datas as $i => $data) { 98 $description = $field->get_label($data); 99 $mform->addElement('checkbox', 'filter['.$fname.']['.$i.']', null, $description); 100 } 101 } 102 103 if ($extraparams) { 104 foreach ($extraparams as $key => $value) { 105 $mform->addElement('hidden', $key, $value); 106 $mform->setType($key, PARAM_RAW); 107 } 108 } 109 110 $objs = array(); 111 $objs[] = &$mform->createElement('submit', 'removeselected', get_string('removeselected', 'filters')); 112 $objs[] = &$mform->createElement('submit', 'removeall', get_string('removeall', 'filters')); 113 $mform->addElement('group', 'actfiltergrp', '', $objs, ' ', false); 114 } 115 } 116 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body