[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/user/ -> policy.php (source)

   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   * This file is part of the User section Moodle
  19   *
  20   * @copyright 1999 Martin Dougiamas  http://dougiamas.com
  21   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   * @package core_user
  23   */
  24  
  25  require_once('../config.php');
  26  require_once($CFG->libdir.'/filelib.php');
  27  require_once($CFG->libdir.'/resourcelib.php');
  28  
  29  $agree = optional_param('agree', 0, PARAM_BOOL);
  30  
  31  $PAGE->set_url('/user/policy.php');
  32  $PAGE->set_popup_notification_allowed(false);
  33  
  34  if (!isloggedin()) {
  35      require_login();
  36  }
  37  
  38  if (isguestuser()) {
  39      $sitepolicy = $CFG->sitepolicyguest;
  40  } else {
  41      $sitepolicy = $CFG->sitepolicy;
  42  }
  43  
  44  if (!empty($SESSION->wantsurl)) {
  45      $return = $SESSION->wantsurl;
  46  } else {
  47      $return = $CFG->wwwroot.'/';
  48  }
  49  
  50  if (empty($sitepolicy)) {
  51      // Nothing to agree to, sorry, hopefully we will not get to infinite loop.
  52      redirect($return);
  53  }
  54  
  55  if ($agree and confirm_sesskey()) {    // User has agreed.
  56      if (!isguestuser()) {              // Don't remember guests.
  57          $DB->set_field('user', 'policyagreed', 1, array('id' => $USER->id));
  58      }
  59      $USER->policyagreed = 1;
  60      unset($SESSION->wantsurl);
  61      redirect($return);
  62  }
  63  
  64  $strpolicyagree = get_string('policyagree');
  65  $strpolicyagreement = get_string('policyagreement');
  66  $strpolicyagreementclick = get_string('policyagreementclick');
  67  
  68  $PAGE->set_context(context_system::instance());
  69  $PAGE->set_title($strpolicyagreement);
  70  $PAGE->set_heading($SITE->fullname);
  71  $PAGE->navbar->add($strpolicyagreement);
  72  
  73  echo $OUTPUT->header();
  74  echo $OUTPUT->heading($strpolicyagreement);
  75  
  76  $mimetype = mimeinfo('type', $sitepolicy);
  77  if ($mimetype == 'document/unknown') {
  78      // Fallback for missing index.php, index.html.
  79      $mimetype = 'text/html';
  80  }
  81  
  82  // We can not use our popups here, because the url may be arbitrary, see MDL-9823.
  83  $clicktoopen = '<a href="'.$sitepolicy.'" onclick="this.target=\'_blank\'">'.$strpolicyagreementclick.'</a>';
  84  
  85  echo '<div class="noticebox">';
  86  echo resourcelib_embed_general($sitepolicy, $strpolicyagreement, $clicktoopen, $mimetype);
  87  echo '</div>';
  88  
  89  $formcontinue = new single_button(new moodle_url('policy.php', array('agree' => 1)), get_string('yes'));
  90  $formcancel = new single_button(new moodle_url($CFG->wwwroot.'/login/logout.php', array('agree' => 0)), get_string('no'));
  91  echo $OUTPUT->confirm($strpolicyagree, $formcontinue, $formcancel);
  92  
  93  echo $OUTPUT->footer();
  94  


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1