bump version.
[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 defined('MOODLE_INTERNAL') || die();
18
19 global $CFG;
20 require_once($CFG->libdir.'/formslib.php');
21
22 class tempmerge_form extends moodleform {
23
24 public function definition() {
25 global $COURSE;
26
27 $context = context_course::instance($COURSE->id);
28 $namefields = get_all_user_name_fields(true, 'u');
29 $students = get_enrolled_users($context, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields.',u.email',
30 'u.lastname, u.firstname', 0, 0, true);
31 $partarray = array();
32 foreach ($students as $student) {
33 $partarray[$student->id] = fullname($student).' ('.$student->email.')';
34 }
35
36 $mform = $this->_form;
37 $description = $this->_customdata['description'];
38
39 $mform->addElement('hidden', 'id', 0);
40 $mform->setType('id', PARAM_INT);
41 $mform->addElement('hidden', 'userid', 0);
42 $mform->setType('userid', PARAM_INT);
43
44 $mform->addElement('header', 'attheader', get_string('tempusermerge', 'attendance'));
45 $mform->addElement('static', 'description', get_string('tempuser', 'attendance'), $description);
46
47 $mform->addElement('select', 'participant', get_string('participant', 'attendance'), $partarray);
48
49 $mform->addElement('static', 'requiredentries', '', get_string('requiredentries', 'attendance'));
50 $mform->addHelpButton('requiredentries', 'requiredentry', 'attendance');
51
52 $this->add_action_buttons(true, get_string('mergeuser', 'attendance'));
53 }
54 }