Implement data privacy provider.
[moodle-mod_attendance.git] / password_ajax.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 * Displays help via AJAX call or in a new page
19 *
20 * Use {@link core_renderer::help_icon()} or {@link addHelpButton()} to display
21 * the help icon.
22 *
23 * @copyright 2017 Dan Marsden
24 * @package mod_attendance
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 */
27 define('AJAX_SCRIPT', true);
28 require_once(dirname(__FILE__).'/../../config.php');
29
30 $session = required_param('session', PARAM_INT);
31 $session = $DB->get_record('attendance_sessions', array('id' => $session), '*', MUST_EXIST);
32
33 $cm = get_coursemodule_from_instance('attendance', $session->attendanceid);
34 require_login($cm->course, $cm);
35
36 $context = context_module::instance($cm->id);
37 $capabilities = array('mod/attendance:manageattendances', 'mod/attendance:takeattendances', 'mod/attendance:changeattendances');
38 if (!has_any_capability($capabilities, $context)) {
39 exit;
40 }
41
42 $PAGE->set_url('/mod/attendance/password.php');
43 $PAGE->set_pagelayout('popup');
44
45 $PAGE->set_context(context_system::instance());
46
47 $data->heading = '';
48 $data->text = html_writer::span($session->studentpassword, 'student-password');
49
50 echo json_encode($data);