Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * View user acceptances to the policies
19
 *
20
 * @package     tool_policy
21
 * @copyright   2018 Marina Glancy
22
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require(__DIR__.'/../../../config.php');
26
require_once($CFG->dirroot.'/user/editlib.php');
27
 
28
$userid = optional_param('userid', null, PARAM_INT);
29
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
30
 
31
require_login();
32
$userid = $userid ?: $USER->id;
33
if (isguestuser() || isguestuser($userid)) {
34
    throw new \moodle_exception('noguest');
35
}
36
$context = context_user::instance($userid);
37
if ($userid != $USER->id) {
38
    // Check capability to view acceptances. No capability is needed to view your own acceptances.
39
    if (!has_capability('tool/policy:acceptbehalf', $context)) {
40
        require_capability('tool/policy:viewacceptances', $context);
41
    }
42
 
43
    $user = core_user::get_user($userid);
44
    $PAGE->navigation->extend_for_user($user);
45
}
46
 
47
$title = get_string('policiesagreements', 'tool_policy');
48
 
49
$PAGE->set_context($context);
50
$PAGE->set_pagelayout('standard');
51
$PAGE->set_url(new moodle_url('/admin/tool/policy/user.php', ['userid' => $userid]));
52
$PAGE->set_title($title);
53
 
54
if ($userid == $USER->id &&
55
        ($profilenode = $PAGE->settingsnav->find('myprofile', null))) {
56
 
57
    $profilenode->make_active();
58
}
59
 
60
$PAGE->navbar->add($title);
61
 
62
$output = $PAGE->get_renderer('tool_policy');
63
echo $output->header();
64
echo $output->heading($title);
65
$acceptances = new \tool_policy\output\acceptances($userid, $returnurl);
66
echo $output->render($acceptances);
67
$PAGE->requires->js_call_amd('tool_policy/acceptmodal', 'getInstance', [context_system::instance()->id]);
68
echo $output->footer();