[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/message/output/airnotifier/ -> requestaccesskey.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   * Request access key to AirNotifier
  19   *
  20   * @package    message_airnotifier
  21   * @copyright  2012 Jerome Mouneyrac
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  require('../../../config.php');
  26  require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
  27  
  28  define('AIRNOTIFIER_PUBLICURL', 'https://messages.moodle.net');
  29  
  30  $PAGE->set_url(new moodle_url('/message/output/airnotifier/requestaccesskey.php'));
  31  $PAGE->set_context(context_system::instance());
  32  
  33  require_login();
  34  require_sesskey();
  35  require_capability('moodle/site:config', context_system::instance());
  36  
  37  $strheading = get_string('requestaccesskey', 'message_airnotifier');
  38  $PAGE->navbar->add(get_string('administrationsite'));
  39  $PAGE->navbar->add(get_string('plugins', 'admin'));
  40  $PAGE->navbar->add(get_string('messageoutputs', 'message'));
  41  $returl = new moodle_url('/admin/settings.php', array('section' => 'messagesettingairnotifier'));
  42  $PAGE->navbar->add(get_string('pluginname', 'message_airnotifier'), $returl);
  43  $PAGE->navbar->add($strheading);
  44  
  45  $PAGE->set_heading($strheading);
  46  $PAGE->set_title($strheading);
  47  
  48  $msg = "";
  49  
  50  // If we are requesting a key to the official message system, verify first that this site is registered.
  51  // This check is also done in Airnotifier.
  52  if (strpos($CFG->airnotifierurl, AIRNOTIFIER_PUBLICURL) !== false ) {
  53      $registrationmanager = new registration_manager();
  54      if (!$registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL)) {
  55          $msg = get_string('sitemustberegistered', 'message_airnotifier');
  56          $msg .= $OUTPUT->continue_button($returl);
  57  
  58          echo $OUTPUT->header();
  59          echo $OUTPUT->box($msg, 'generalbox');
  60          echo $OUTPUT->footer();
  61          die;
  62      }
  63  }
  64  
  65  $manager = new message_airnotifier_manager();
  66  
  67  if ($key = $manager->request_accesskey()) {
  68      set_config('airnotifieraccesskey', $key);
  69      $msg = get_string('keyretrievedsuccessfully', 'message_airnotifier');
  70  } else {
  71      $msg = get_string('errorretrievingkey', 'message_airnotifier');
  72  }
  73  
  74  $msg .= $OUTPUT->continue_button($returl);
  75  
  76  echo $OUTPUT->header();
  77  echo $OUTPUT->box($msg, 'generalbox ');
  78  echo $OUTPUT->footer();


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