Implement data privacy provider.
[moodle-mod_attendance.git] / mod_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 * Forms for updating/adding attendance
19 *
20 * @package mod_attendance
21 * @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25 defined('MOODLE_INTERNAL') || die();
26 require_once($CFG->dirroot.'/course/moodleform_mod.php');
27
28 /**
29 * class for displaying add/update form.
30 *
31 * @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33 */
34 class mod_attendance_mod_form extends moodleform_mod {
35
36 /**
37 * Called to define this moodle form
38 *
39 * @return void
40 */
41 public function definition() {
42 $attendanceconfig = get_config('attendance');
43 if (!isset($attendanceconfig->subnet)) {
44 $attendanceconfig->subnet = '';
45 }
46 $mform =& $this->_form;
47
48 $mform->addElement('header', 'general', get_string('general', 'form'));
49
50 $mform->addElement('text', 'name', get_string('name'), array('size' => '64'));
51 $mform->setType('name', PARAM_TEXT);
52 $mform->addRule('name', null, 'required', null, 'client');
53 $mform->setDefault('name', get_string('modulename', 'attendance'));
54
55 $this->standard_intro_elements();
56
57 // Grade settings.
58 $this->standard_grading_coursemodule_elements();
59
60 $this->standard_coursemodule_elements(true);
61
62 // IP address.
63 if (get_config('attendance', 'subnetactivitylevel')) {
64 $mform->addElement('header', 'security', get_string('extrarestrictions', 'attendance'));
65 $mform->addElement('text', 'subnet', get_string('defaultsubnet', 'attendance'), array('size' => '164'));
66 $mform->setType('subnet', PARAM_TEXT);
67 $mform->addHelpButton('subnet', 'defaultsubnet', 'attendance');
68 $mform->setDefault('subnet', $attendanceconfig->subnet);
69 } else {
70 $mform->addElement('hidden', 'subnet', '');
71 $mform->setType('subnet', PARAM_TEXT);
72 }
73
74 $this->add_action_buttons();
75 }
76 }