See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]
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 * Web services function UI 20 * 21 * @package webservice 22 * @copyright 2009 Moodle Pty Ltd (http://moodle.com) 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 require_once('../../config.php'); 26 require_once($CFG->libdir . '/adminlib.php'); 27 require_once($CFG->libdir . '/externallib.php'); 28 require_once($CFG->dirroot . '/webservice/lib.php'); 29 require_once ('forms.php'); 30 31 $serviceid = required_param('id', PARAM_INT); 32 $functionid = optional_param('fid', 0, PARAM_INT); 33 $action = optional_param('action', '', PARAM_ALPHANUMEXT); 34 $confirm = optional_param('confirm', 0, PARAM_BOOL); 35 36 admin_externalpage_setup('externalservicefunctions'); 37 38 //define nav bar 39 $PAGE->set_url('/' . $CFG->admin . '/webservice/service_functions.php', array('id' => $serviceid)); 40 $node = $PAGE->settingsnav->find('externalservices', navigation_node::TYPE_SETTING); 41 if ($node) { 42 $node->make_active(); 43 } 44 $PAGE->set_primary_active_tab('siteadminnode'); 45 $PAGE->navbar->add(get_string('externalservices', 'webservice'), 46 new moodle_url('/admin/settings.php', ['section' => 'externalservices'])); 47 $PAGE->navbar->add(get_string('functions', 'webservice'), 48 new moodle_url('/' . $CFG->admin . '/webservice/service_functions.php', array('id' => $serviceid))); 49 50 $service = $DB->get_record('external_services', array('id' => $serviceid), '*', MUST_EXIST); 51 $webservicemanager = new webservice(); 52 $renderer = $PAGE->get_renderer('core', 'webservice'); 53 $functionlisturl = new moodle_url('/' . $CFG->admin . '/webservice/service_functions.php', 54 array('id' => $serviceid)); 55 56 // Add or Delete operations 57 switch ($action) { 58 case 'add': 59 $PAGE->navbar->add(get_string('addfunctions', 'webservice')); 60 /// Add function operation 61 if (confirm_sesskey() and $service and empty($service->component)) { 62 $mform = new external_service_functions_form(null, 63 array('action' => 'add', 'id' => $service->id)); 64 65 //cancelled add operation, redirect to function list page 66 if ($mform->is_cancelled()) { 67 redirect($functionlisturl); 68 } 69 70 //add the function to the service then redirect to function list page 71 if ($data = $mform->get_data()) { 72 ignore_user_abort(true); // no interruption here! 73 foreach ($data->fids as $fid) { 74 $function = $webservicemanager->get_external_function_by_id( 75 $fid, MUST_EXIST); 76 // make sure the function is not there yet 77 if (!$webservicemanager->service_function_exists($function->name, 78 $service->id)) { 79 $webservicemanager->add_external_function_to_service( 80 $function->name, $service->id); 81 } 82 } 83 redirect($functionlisturl); 84 } 85 86 //Add function operation page output 87 echo $OUTPUT->header(); 88 echo $OUTPUT->heading($service->name); 89 $mform->display(); 90 echo $OUTPUT->footer(); 91 die; 92 } 93 94 break; 95 96 case 'delete': 97 $PAGE->navbar->add(get_string('removefunction', 'webservice')); 98 /// Delete function operation 99 if (confirm_sesskey() and $service and empty($service->component)) { 100 //check that the function to remove exists 101 $function = $webservicemanager->get_external_function_by_id( 102 $functionid, MUST_EXIST); 103 104 //display confirmation page 105 if (!$confirm) { 106 echo $OUTPUT->header(); 107 echo $renderer->admin_remove_service_function_confirmation($function, $service); 108 echo $OUTPUT->footer(); 109 die; 110 } 111 112 //or remove the function from the service, then redirect to the function list 113 $webservicemanager->remove_external_function_from_service($function->name, 114 $service->id); 115 redirect($functionlisturl); 116 } 117 break; 118 } 119 120 /// OUTPUT function list page 121 echo $OUTPUT->header(); 122 echo $OUTPUT->heading(get_string('addservicefunction', 'webservice', $service->name)); 123 $functions = $webservicemanager->get_external_functions(array($service->id)); 124 echo $renderer->admin_service_function_list($functions, $service); 125 echo $OUTPUT->footer(); 126
title
Description
Body
title
Description
Body
title
Description
Body
title
Body