[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/webservice/ -> wsdoc.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  /**
  19   * Web services auto-generated documentation
  20   *
  21   * @package    core_webservice
  22   * @copyright  2009 Jerome Mouneyrac <jerome@moodle.com>
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  require_once('../config.php');
  27  require($CFG->dirroot . '/webservice/lib.php');
  28  
  29  require_login();
  30  require_sesskey();
  31  
  32  $usercontext = context_user::instance($USER->id);
  33  $tokenid = required_param('id', PARAM_INT);
  34  
  35  // PAGE settings
  36  $PAGE->set_context($usercontext);
  37  $PAGE->set_url('/user/wsdoc.php');
  38  $PAGE->set_title(get_string('documentation', 'webservice'));
  39  $PAGE->set_heading(get_string('documentation', 'webservice'));
  40  $PAGE->set_pagelayout('standard');
  41  
  42  // nav bar
  43  $PAGE->navbar->ignore_active(true);
  44  $PAGE->navbar->add(get_string('usercurrentsettings'));
  45  $PAGE->navbar->add(get_string('securitykeys', 'webservice'),
  46          new moodle_url('/user/managetoken.php', 
  47                  array('id' => $tokenid, 'sesskey' => sesskey())));
  48  $PAGE->navbar->add(get_string('documentation', 'webservice'));
  49  
  50  // check web service are enabled
  51  if (empty($CFG->enablewsdocumentation)) {
  52      echo get_string('wsdocumentationdisable', 'webservice');
  53      die;
  54  }
  55  
  56  // check that the current user is the token user
  57  $webservice = new webservice();
  58  $token = $webservice->get_token_by_id($tokenid);
  59  if (empty($token) or empty($token->userid) or empty($USER->id)
  60          or ($token->userid != $USER->id)) {
  61      throw new moodle_exception('docaccessrefused', 'webservice');
  62  }
  63  
  64  // get the list of all functions related to the token
  65  $functions = $webservice->get_external_functions(array($token->externalserviceid));
  66  
  67  // get all the function descriptions
  68  $functiondescs = array();
  69  foreach ($functions as $function) {
  70      $functiondescs[$function->name] = external_api::external_function_info($function);
  71  }
  72  
  73  // get activated protocol
  74  $activatedprotocol = array();
  75  $activatedprotocol['rest'] = webservice_protocol_is_enabled('rest');
  76  $activatedprotocol['xmlrpc'] = webservice_protocol_is_enabled('xmlrpc');
  77  
  78  // Check if we are in printable mode
  79  $printableformat = optional_param('print', false, PARAM_BOOL);
  80  
  81  // OUTPUT
  82  echo $OUTPUT->header();
  83  
  84  $renderer = $PAGE->get_renderer('core', 'webservice');
  85  echo $renderer->documentation_html($functiondescs,
  86          $printableformat, $activatedprotocol, array('id' => $tokenid));
  87  
  88  // trigger browser print operation
  89  if (!empty($printableformat)) {
  90      $PAGE->requires->js_function_call('window.print', array());
  91  }
  92  
  93  echo $OUTPUT->footer();


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