|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00026 require_once('../config.php'); 00027 require_once($CFG->libdir.'/filelib.php'); 00028 require_once($CFG->libdir.'/resourcelib.php'); 00029 00030 $agree = optional_param('agree', 0, PARAM_BOOL); 00031 00032 $PAGE->set_url('/user/policy.php'); 00033 $PAGE->set_popup_notification_allowed(false); 00034 00035 if (!isloggedin()) { 00036 require_login(); 00037 } 00038 00039 if (isguestuser()) { 00040 $sitepolicy = $CFG->sitepolicyguest; 00041 } else { 00042 $sitepolicy = $CFG->sitepolicy; 00043 } 00044 00045 if (!empty($SESSION->wantsurl)) { 00046 $return = $SESSION->wantsurl; 00047 } else { 00048 $return = $CFG->wwwroot.'/'; 00049 } 00050 00051 if (empty($sitepolicy)) { 00052 // nothing to agree to, sorry, hopefully we will not get to infinite loop 00053 redirect($return); 00054 } 00055 00056 if ($agree and confirm_sesskey()) { // User has agreed 00057 if (!isguestuser()) { // Don't remember guests 00058 $DB->set_field('user', 'policyagreed', 1, array('id'=>$USER->id)); 00059 } 00060 $USER->policyagreed = 1; 00061 unset($SESSION->wantsurl); 00062 redirect($return); 00063 } 00064 00065 $strpolicyagree = get_string('policyagree'); 00066 $strpolicyagreement = get_string('policyagreement'); 00067 $strpolicyagreementclick = get_string('policyagreementclick'); 00068 00069 $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); 00070 $PAGE->set_title($strpolicyagreement); 00071 $PAGE->set_heading($SITE->fullname); 00072 $PAGE->navbar->add($strpolicyagreement); 00073 00074 echo $OUTPUT->header(); 00075 echo $OUTPUT->heading($strpolicyagreement); 00076 00077 $mimetype = mimeinfo('type', $sitepolicy); 00078 if ($mimetype == 'document/unknown') { 00079 //fallback for missing index.php, index.html 00080 $mimetype = 'text/html'; 00081 } 00082 00083 // we can not use our popups here, because the url may be arbitrary, see MDL-9823 00084 $clicktoopen = '<a href="'.$sitepolicy.'" onclick="this.target=\'_blank\'">'.$strpolicyagreementclick.'</a>'; 00085 00086 echo '<div class="noticebox">'; 00087 echo resourcelib_embed_general($sitepolicy, $strpolicyagreement, $clicktoopen, $mimetype); 00088 echo '</div>'; 00089 00090 $formcontinue = new single_button(new moodle_url('policy.php', array('agree'=>1)), get_string('yes')); 00091 $formcancel = new single_button(new moodle_url($CFG->wwwroot.'/login/logout.php', array('agree'=>0)), get_string('no')); 00092 echo $OUTPUT->confirm($strpolicyagree, $formcontinue, $formcancel); 00093 00094 echo $OUTPUT->footer(); 00095