Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 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 admin 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 ('forms.php'); 28 require_once($CFG->dirroot . '/webservice/lib.php'); 29 30 admin_externalpage_setup('externalservice'); 31 32 //define nav bar 33 $node = $PAGE->settingsnav->find('externalservice', navigation_node::TYPE_SETTING); 34 $newnode = $PAGE->settingsnav->find('externalservices', navigation_node::TYPE_SETTING); 35 if ($node && $newnode) { 36 $node->display = false; 37 $newnode->make_active(); 38 } 39 $PAGE->navbar->add(get_string('externalservices', 'webservice'), 40 new moodle_url('/admin/settings.php', ['section' => 'externalservices'])); 41 42 $PAGE->set_primary_active_tab('siteadminnode'); 43 44 45 //Retrieve few general parameters 46 $id = required_param('id', PARAM_INT); 47 $action = optional_param('action', '', PARAM_ALPHANUMEXT); 48 $confirm = optional_param('confirm', 0, PARAM_BOOL); 49 $webservicemanager = new webservice; 50 $renderer = $PAGE->get_renderer('core', 'webservice'); 51 $returnurl = $CFG->wwwroot . "/" . $CFG->admin . "/settings.php?section=externalservices"; 52 $service = $id ? $webservicemanager->get_external_service_by_id($id, MUST_EXIST) : null; 53 54 /// DELETE operation 55 if ($action == 'delete' and confirm_sesskey() and $service and empty($service->component)) { 56 //Display confirmation Page 57 if (!$confirm) { 58 echo $OUTPUT->header(); 59 echo $renderer->admin_remove_service_confirmation($service); 60 echo $OUTPUT->footer(); 61 die; 62 } 63 //The user has confirmed the deletion, delete and redirect 64 $webservicemanager->delete_service($service->id); 65 $params = array( 66 'objectid' => $service->id 67 ); 68 $event = \core\event\webservice_service_deleted::create($params); 69 $event->add_record_snapshot('external_services', $service); 70 $event->trigger(); 71 redirect($returnurl); 72 } 73 74 /// EDIT/CREATE/CANCEL operations => at the end redirect to add function page / main service page 75 $mform = new external_service_form(null, $service); 76 if ($mform->is_cancelled()) { 77 redirect($returnurl); 78 } else if ($servicedata = $mform->get_data()) { 79 $servicedata = (object) $servicedata; 80 if (!empty($servicedata->requiredcapability) && $servicedata->requiredcapability == "norequiredcapability") { 81 $servicedata->requiredcapability = ""; 82 } 83 84 //create operation 85 if (empty($servicedata->id)) { 86 $servicedata->id = $webservicemanager->add_external_service($servicedata); 87 $params = array( 88 'objectid' => $servicedata->id 89 ); 90 $event = \core\event\webservice_service_created::create($params); 91 $event->trigger(); 92 93 //redirect to the 'add functions to service' page 94 $addfunctionpage = new moodle_url( 95 $CFG->wwwroot . '/' . $CFG->admin . '/webservice/service_functions.php', 96 array('id' => $servicedata->id)); 97 $returnurl = $addfunctionpage->out(false); 98 } else { 99 //update operation 100 $webservicemanager->update_external_service($servicedata); 101 $params = array( 102 'objectid' => $servicedata->id 103 ); 104 $event = \core\event\webservice_service_updated::create($params); 105 $event->trigger(); 106 } 107 108 redirect($returnurl); 109 } 110 111 if ($id == 0) { 112 $PAGE->navbar->add(get_string('addexternalservice', 'webservice'), $PAGE->url); 113 } else { 114 $PAGE->navbar->add(get_string('editexternalservice', 'webservice'), $PAGE->url); 115 } 116 117 //OUTPUT edit/create form 118 echo $OUTPUT->header(); 119 $mform->display(); 120 echo $OUTPUT->footer(); 121
title
Description
Body
title
Description
Body
title
Description
Body
title
Body