MDL-28955 theme_nimble: added css rules to display horizontal/vertical-menu-submenu...
[moodle.git] / user / policy.php
blob46a2f2bb20fb31cff8fdcc8975c25afd62ef0f01
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * This file is part of the User section Moodle
21 * @copyright 1999 Martin Dougiamas http://dougiamas.com
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 * @package user
26 require_once('../config.php');
27 require_once($CFG->libdir.'/filelib.php');
28 require_once($CFG->libdir.'/resourcelib.php');
30 $agree = optional_param('agree', 0, PARAM_BOOL);
32 $PAGE->set_url('/user/policy.php');
33 $PAGE->set_popup_notification_allowed(false);
35 if (!isloggedin()) {
36 require_login();
39 if (isguestuser()) {
40 $sitepolicy = $CFG->sitepolicyguest;
41 } else {
42 $sitepolicy = $CFG->sitepolicy;
45 if (!empty($SESSION->wantsurl)) {
46 $return = $SESSION->wantsurl;
47 } else {
48 $return = $CFG->wwwroot.'/';
51 if (empty($sitepolicy)) {
52 // nothing to agree to, sorry, hopefully we will not get to infinite loop
53 redirect($return);
56 if ($agree and confirm_sesskey()) { // User has agreed
57 if (!isguestuser()) { // Don't remember guests
58 $DB->set_field('user', 'policyagreed', 1, array('id'=>$USER->id));
60 $USER->policyagreed = 1;
61 unset($SESSION->wantsurl);
62 redirect($return);
65 $strpolicyagree = get_string('policyagree');
66 $strpolicyagreement = get_string('policyagreement');
67 $strpolicyagreementclick = get_string('policyagreementclick');
69 $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
70 $PAGE->set_title($strpolicyagreement);
71 $PAGE->set_heading($SITE->fullname);
72 $PAGE->navbar->add($strpolicyagreement);
74 echo $OUTPUT->header();
75 echo $OUTPUT->heading($strpolicyagreement);
77 $mimetype = mimeinfo('type', $sitepolicy);
78 if ($mimetype == 'document/unknown') {
79 //fallback for missing index.php, index.html
80 $mimetype = 'text/html';
83 // we can not use our popups here, because the url may be arbitrary, see MDL-9823
84 $clicktoopen = '<a href="'.$sitepolicy.'" onclick="this.target=\'_blank\'">'.$strpolicyagreementclick.'</a>';
86 echo '<div class="noticebox">';
87 echo resourcelib_embed_general($sitepolicy, $strpolicyagreement, $clicktoopen, $mimetype);
88 echo '</div>';
90 $formcontinue = new single_button(new moodle_url('policy.php', array('agree'=>1)), get_string('yes'));
91 $formcancel = new single_button(new moodle_url($CFG->wwwroot.'/login/logout.php', array('agree'=>0)), get_string('no'));
92 echo $OUTPUT->confirm($strpolicyagree, $formcontinue, $formcancel);
94 echo $OUTPUT->footer();