MDL-10724 Added the help buttons to the item edit form
[moodle-pu.git] / user / policy.php
blobbe339d7506df4856ce89962a48d999b99a2960d6
1 <?php // $Id$
3 require_once('../config.php');
4 require_once($CFG->libdir.'/filelib.php');
6 $agree = optional_param('agree', 0, PARAM_BOOL);
8 define('MESSAGE_WINDOW', true); // This prevents the message window coming up
10 if (!isloggedin()) {
11 require_login();
14 if ($agree and confirm_sesskey()) { // User has agreed
15 if (!isguestuser()) { // Don't remember guests
16 if (!set_field('user', 'policyagreed', 1, 'id', $USER->id)) {
17 error('Could not save your agreement');
20 $USER->policyagreed = 1;
22 if (!empty($SESSION->wantsurl)) {
23 $wantsurl = $SESSION->wantsurl;
24 unset($SESSION->wantsurl);
25 redirect($wantsurl);
26 } else {
27 redirect($CFG->wwwroot.'/');
29 exit;
32 $strpolicyagree = get_string('policyagree');
33 $strpolicyagreement = get_string('policyagreement');
34 $strpolicyagreementclick = get_string('policyagreementclick');
36 print_header($strpolicyagreement, $SITE->fullname, $strpolicyagreement);
38 print_heading($strpolicyagreement);
40 $mimetype = mimeinfo('type', $CFG->sitepolicy);
41 if ($mimetype == 'document/unknown') {
42 //fallback for missing index.php, index.html
43 $mimetype = 'text/html';
46 echo '<div class="noticebox">';
47 echo '<object id="policyframe" data="'.$CFG->sitepolicy.'" type="'.$mimetype.'">';
48 // we can not use our popups here, because the url may be arbitrary, see MDL-9823
49 echo '<a href="'.$CFG->sitepolicy.'" onclick="this.target=\'_blank\'">'.$strpolicyagreementclick.'</a>';
50 echo '</object></div>';
52 $linkyes = 'policy.php';
53 $optionsyes = array('agree'=>1, 'sesskey'=>sesskey());
54 $linkno = $CFG->wwwroot.'/login/logout.php';
55 $optionsno = array('sesskey'=>sesskey());
56 notice_yesno($strpolicyagree, $linkyes, $linkno, $optionsyes, $optionsno);
58 print_footer();