[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/ajax/ -> getsiteadminbranch.php (source)

   1  <?php
   2  
   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.
  14  //
  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/>.
  17  
  18  /**
  19   * This file is used to deliver a branch from the site administration
  20   * in XML format back to a page from an AJAX call
  21   *
  22   * @since Moodle 2.6
  23   * @package core
  24   * @copyright 2013 Rajesh Taneja <[email protected]>
  25   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26   */
  27  
  28  define('AJAX_SCRIPT', true);
  29  require_once(dirname(__FILE__) . '/../../config.php');
  30  
  31  // This should be accessed by only valid logged in user.
  32  if (!isloggedin() or isguestuser()) {
  33      die('Invalid access.');
  34  }
  35  
  36  // This identifies the type of the branch we want to get. Make sure it's SITE_ADMIN.
  37  $branchtype = required_param('type', PARAM_INT);
  38  if ($branchtype !== navigation_node::TYPE_SITE_ADMIN) {
  39      die('Wrong node type passed.');
  40  }
  41  
  42  // Start capturing output in case of broken plugins.
  43  ajax_capture_output();
  44  
  45  $PAGE->set_context(context_system::instance());
  46  $PAGE->set_url('/lib/ajax/getsiteadminbranch.php', array('type'=>$branchtype));
  47  
  48  $sitenavigation = new settings_navigation_ajax($PAGE);
  49  
  50  // Convert and output the branch as JSON.
  51  $converter = new navigation_json();
  52  $branch = $sitenavigation->get('root');
  53  
  54  ajax_check_captured_output();
  55  echo $converter->convert($branch);


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1