Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/webservice/service.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00025 require_once('../../config.php');
00026 require_once($CFG->libdir . '/adminlib.php');
00027 require_once('forms.php');
00028 require_once($CFG->dirroot . '/webservice/lib.php');
00029 
00030 admin_externalpage_setup('externalservice');
00031 
00032 //define nav bar
00033 $node = $PAGE->settingsnav->find('externalservice', navigation_node::TYPE_SETTING);
00034 $newnode = $PAGE->settingsnav->find('externalservices', navigation_node::TYPE_SETTING);
00035 if ($node && $newnode) {
00036     $node->display = false;
00037     $newnode->make_active();
00038 }
00039 $PAGE->navbar->add(get_string('externalservice', 'webservice'));
00040 
00041 //Retrieve few general parameters
00042 $id = required_param('id', PARAM_INT);
00043 $action = optional_param('action', '', PARAM_ACTION);
00044 $confirm = optional_param('confirm', 0, PARAM_BOOL);
00045 $webservicemanager = new webservice;
00046 $renderer = $PAGE->get_renderer('core', 'webservice');
00047 $returnurl = $CFG->wwwroot . "/" . $CFG->admin . "/settings.php?section=externalservices";
00048 $service = $id ? $webservicemanager->get_external_service_by_id($id, MUST_EXIST) : null;
00049 
00051 if ($action == 'delete' and confirm_sesskey() and $service and empty($service->component)) {
00052     //Display confirmation Page
00053     if (!$confirm) {
00054         echo $OUTPUT->header();
00055         echo $renderer->admin_remove_service_confirmation($service);
00056         echo $OUTPUT->footer();
00057         die;
00058     }
00059     //The user has confirmed the deletion, delete and redirect
00060     $webservicemanager->delete_service($service->id);
00061     add_to_log(SITEID, 'webservice', 'delete', $returnurl, get_string('deleteservice', 'webservice', $service));
00062     redirect($returnurl);
00063 }
00064 
00066 $mform = new external_service_form(null, $service);
00067 if ($mform->is_cancelled()) {
00068     redirect($returnurl);
00069 } else if ($servicedata = $mform->get_data()) {
00070     $servicedata = (object) $servicedata;
00071     if (!empty($servicedata->requiredcapability) && $servicedata->requiredcapability == "norequiredcapability") {
00072         $servicedata->requiredcapability = "";
00073     }
00074 
00075     //create operation
00076     if (empty($servicedata->id)) {
00077         $servicedata->id = $webservicemanager->add_external_service($servicedata);
00078         add_to_log(SITEID, 'webservice', 'add', $returnurl, get_string('addservice', 'webservice', $servicedata));
00079 
00080         //redirect to the 'add functions to service' page
00081         $addfunctionpage = new moodle_url(
00082                         $CFG->wwwroot . '/' . $CFG->admin . '/webservice/service_functions.php',
00083                         array('id' => $servicedata->id));
00084         $returnurl = $addfunctionpage->out(false);
00085     } else {
00086         //update operation
00087         $webservicemanager->update_external_service($servicedata);
00088         add_to_log(SITEID, 'webservice', 'edit', $returnurl, get_string('editservice', 'webservice', $servicedata));
00089     }
00090 
00091     redirect($returnurl);
00092 }
00093 
00094 //OUTPUT edit/create form
00095 echo $OUTPUT->header();
00096 $mform->display();
00097 echo $OUTPUT->footer();
00098 
 All Data Structures Namespaces Files Functions Variables Enumerations