Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/webservice/protocols.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 
00026 require_once('../../config.php');
00027 require_once($CFG->libdir.'/adminlib.php');
00028 require_once($CFG->libdir.'/tablelib.php');
00029 
00030 $PAGE->set_url('/' . $CFG->admin . '/webservice/protocols.php');
00031 //TODO: disable the blocks here or better make the page layout default to no blocks!
00032 
00033 require_login();
00034 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
00035 
00036 $returnurl = $CFG->wwwroot . "/" . $CFG->admin . "/settings.php?section=webserviceprotocols";
00037 
00038 $action     = optional_param('action', '', PARAM_ACTION);
00039 $webservice = optional_param('webservice', '', PARAM_SAFEDIR);
00040 $confirm    = optional_param('confirm', 0, PARAM_BOOL);
00041 
00042 // get currently installed and enabled auth plugins
00043 $available_webservices = get_plugin_list('webservice');
00044 if (!empty($webservice) and empty($available_webservices[$webservice])) {
00045     redirect($returnurl);
00046 }
00047 
00048 $active_webservices = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
00049 foreach ($active_webservices as $key=>$active) {
00050     if (empty($available_webservices[$active])) {
00051         unset($active_webservices[$key]);
00052     }
00053 }
00054 
00056 // process actions
00057 
00058 if (!confirm_sesskey()) {
00059     redirect($returnurl);
00060 }
00061 
00062 switch ($action) {
00063     case 'uninstall':
00064         die('TODO: not implemented yet');
00065         break;
00066 
00067     case 'disable':
00068         // remove from enabled list
00069         $key = array_search($webservice, $active_webservices);
00070         unset($active_webservices[$key]);
00071         break;
00072 
00073     case 'enable':
00074         // add to enabled list
00075         if (!in_array($webservice, $active_webservices)) {
00076             $active_webservices[] = $webservice;
00077             $active_webservices = array_unique($active_webservices);
00078         }
00079         break;
00080 
00081     default:
00082         break;
00083 }
00084 
00085 set_config('webserviceprotocols', implode(',', $active_webservices));
00086 
00087 redirect($returnurl);
 All Data Structures Namespaces Files Functions Variables Enumerations