Implement data privacy provider.
[moodle-mod_attendance.git] / tempmerge_form.php
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 * Temp merge form class.
19 *
20 * @package mod_attendance
21 * @copyright 2013 Davo Smith, Synergy Learning
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25 defined('MOODLE_INTERNAL') || die();
26
27 global $CFG;
28 require_once($CFG->libdir.'/formslib.php');
29
30 /**
31 * Temp merge form class.
32 *
33 * @package mod_attendance
34 * @copyright 2013 Davo Smith, Synergy Learning
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 */
37 class tempmerge_form extends moodleform {
38 /**
39 * Called to define this moodle form
40 *
41 * @return void
42 */
43 public function definition() {
44 global $COURSE;
45
46 $context = context_course::instance($COURSE->id);
47 $namefields = get_all_user_name_fields(true, 'u');
48 $students = get_enrolled_users($context, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields.',u.email',
49 'u.lastname, u.firstname', 0, 0, true);
50 $partarray = array();
51 foreach ($students as $student) {
52 $partarray[$student->id] = fullname($student).' ('.$student->email.')';
53 }
54
55 $mform = $this->_form;
56 $description = $this->_customdata['description'];
57
58 $mform->addElement('hidden', 'id', 0);
59 $mform->setType('id', PARAM_INT);
60 $mform->addElement('hidden', 'userid', 0);
61 $mform->setType('userid', PARAM_INT);
62
63 $mform->addElement('header', 'attheader', get_string('tempusermerge', 'attendance'));
64 $mform->addElement('static', 'description', get_string('tempuser', 'attendance'), $description);
65
66 $mform->addElement('select', 'participant', get_string('participant', 'attendance'), $partarray);
67
68 $mform->addElement('static', 'requiredentries', '', get_string('requiredentries', 'attendance'));
69 $mform->addHelpButton('requiredentries', 'requiredentry', 'attendance');
70
71 $this->add_action_buttons(true, get_string('mergeuser', 'attendance'));
72 }
73 }