Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/webservice/wsdoc.php
Go to the documentation of this file.
00001 <?php
00002 
00004 //                                                                       //
00005 // This file is part of Moodle - http://moodle.org/                      //
00006 // Moodle - Modular Object-Oriented Dynamic Learning Environment         //
00007 //                                                                       //
00008 // Moodle is free software: you can redistribute it and/or modify        //
00009 // it under the terms of the GNU General Public License as published by  //
00010 // the Free Software Foundation, either version 3 of the License, or     //
00011 // (at your option) any later version.                                   //
00012 //                                                                       //
00013 // Moodle is distributed in the hope that it will be useful,             //
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of        //
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
00016 // GNU General Public License for more details.                          //
00017 //                                                                       //
00018 // You should have received a copy of the GNU General Public License     //
00019 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.       //
00020 //                                                                       //
00022 
00023 require_once('../config.php');
00024 require($CFG->dirroot . '/webservice/lib.php');
00025 
00026 require_login();
00027 require_sesskey();
00028 
00029 $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
00030 $tokenid = required_param('id', PARAM_INT);
00031 
00032 //PAGE settings
00033 $PAGE->set_context($usercontext);
00034 $PAGE->set_url('/user/wsdoc.php');
00035 $PAGE->set_title(get_string('documentation', 'webservice'));
00036 $PAGE->set_heading(get_string('documentation', 'webservice'));
00037 $PAGE->set_pagelayout('standard');
00038 
00039 //nav bar
00040 $PAGE->navbar->ignore_active(true);
00041 $PAGE->navbar->add(get_string('usercurrentsettings'));
00042 $PAGE->navbar->add(get_string('securitykeys', 'webservice'),
00043         new moodle_url('/user/managetoken.php', 
00044                 array('id' => $tokenid, 'sesskey' => sesskey())));
00045 $PAGE->navbar->add(get_string('documentation', 'webservice'));
00046 
00047 //check web service are enabled
00048 if (empty($CFG->enablewsdocumentation)) {
00049     echo get_string('wsdocumentationdisable', 'webservice');
00050     die;
00051 }
00052 
00053 //check that the current user is the token user
00054 $webservice = new webservice();
00055 $token = $webservice->get_token_by_id($tokenid);
00056 if (empty($token) or empty($token->userid) or empty($USER->id)
00057         or ($token->userid != $USER->id)) {
00058     throw new moodle_exception('docaccessrefused', 'webservice');
00059 }
00060 
00061 // get the list of all functions related to the token
00062 $functions = $webservice->get_external_functions(array($token->externalserviceid));
00063 
00064 // get all the function descriptions
00065 $functiondescs = array();
00066 foreach ($functions as $function) {
00067     $functiondescs[$function->name] = external_function_info($function);
00068 }
00069 
00070 //get activated protocol
00071 $activatedprotocol = array();
00072 $activatedprotocol['rest'] = webservice_protocol_is_enabled('rest');
00073 $activatedprotocol['xmlrpc'] = webservice_protocol_is_enabled('xmlrpc');
00074 
00076 $printableformat = optional_param('print', false, PARAM_BOOL);
00077 
00079 echo $OUTPUT->header();
00080 
00081 $renderer = $PAGE->get_renderer('core', 'webservice');
00082 echo $renderer->documentation_html($functiondescs,
00083         $printableformat, $activatedprotocol, array('id' => $tokenid));
00084 
00086 if (!empty($printableformat)) {
00087     $PAGE->requires->js_function_call('window.print', array());
00088 }
00089 
00090 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations