mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
webservice MDL-12886 web service administration
This commit is contained in:
parent
5afb01e899
commit
9baf682518
@ -13,16 +13,22 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
// "web service" settingpage
|
||||
$temp = new admin_settingpage('webservices', get_string('webservices', 'admin'));
|
||||
$temp->add(new admin_setting_heading('webserviceprotocols', get_string('webserviceprotocols', 'admin'), ''));
|
||||
$temp->add(new admin_setting_heading('webserviceprotocols', get_string('protocols', 'webservice'), ''));
|
||||
$temp->add(new admin_setting_managewsprotocols());
|
||||
$url = $CFG->wwwroot.'/'.$CFG->admin.'/wsprotocols.php';
|
||||
$ADMIN->add('security', new admin_externalpage('managews',
|
||||
get_string('managews', 'admin'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
$temp->add(new admin_setting_heading('webservicesystemsettings', get_string('webservicesystemsettings', 'admin'), ''));
|
||||
$temp->add(new admin_setting_heading('webservicesystemsettings', get_string('systemsettings', 'webservice'), ''));
|
||||
$temp->add(new admin_setting_configiplist('ipwhitelist', get_string('ipwhitelist', 'admin'),'', ''));
|
||||
$temp->add(new admin_setting_heading('webserviceusersettings', get_string('webserviceusersettings', 'admin'), ''));
|
||||
$temp->add(new admin_setting_heading('webserviceusersettings', get_string('usersettings', 'webservice'), ''));
|
||||
$temp->add(new admin_setting_managewsusersettings());
|
||||
$temp->add(new admin_setting_heading('webserviceservicelist', get_string('servicelist', 'webservice'), ''));
|
||||
$temp->add(new admin_setting_managewsservicelist());
|
||||
$url = $CFG->wwwroot.'/'.$CFG->admin.'/webservices.php';
|
||||
$ADMIN->add('security', new admin_externalpage('webservicessettings',
|
||||
get_string('webservicessettings', 'admin'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
$ADMIN->add('security', $temp);
|
||||
|
||||
// "sitepolicies" settingpage
|
||||
|
107
admin/webservices.php
Normal file
107
admin/webservices.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/webservice/lib.php');
|
||||
|
||||
|
||||
$serviceid = optional_param('serviceid', '', PARAM_FORMAT);
|
||||
|
||||
$pagename = 'webservicessettings';
|
||||
|
||||
|
||||
admin_externalpage_setup($pagename);
|
||||
require_login(SITEID, false);
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$sesskeyurl = "$CFG->wwwroot/$CFG->admin/webservices.php?sesskey=" . sesskey();
|
||||
$baseurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=webservices";
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', '', $baseurl);
|
||||
}
|
||||
|
||||
if (!empty($serviceid)) {
|
||||
admin_externalpage_print_header();
|
||||
|
||||
//cannot use moodle form in order to display complex list of functions
|
||||
$form = new html_form();
|
||||
$service = $DB->get_record('external_services',array('id' => $serviceid));
|
||||
$formhtml = get_string('servicename', 'webservice').': '.get_string($service->name, 'webservice') ;
|
||||
$formhtml .= "<br/><br/>";
|
||||
//display function selector
|
||||
if (empty($serviceid)) {
|
||||
|
||||
}
|
||||
|
||||
//display service functions
|
||||
$servicesfunctions = $DB->get_records_sql("SELECT fs.id as id, f.component as component, fs.enabled as enabled, s.name as servicename, s.id as serviceid, f.name as functionname, f.id as functionid
|
||||
FROM {external_services} s, {external_functions} f, {external_services_functions} fs
|
||||
WHERE fs.externalserviceid = s.id AND fs.externalfunctionid = f.id AND s.id = ?", array($serviceid));
|
||||
|
||||
//save the administrator changes
|
||||
$saved = optional_param('saved', 0, PARAM_NUMBER);
|
||||
|
||||
if ($saved) {
|
||||
foreach($servicesfunctions as &$servicefunction) { //need to be a refence cause we're going to update the form value too
|
||||
$enabled = optional_param($servicefunction->functionname, '', PARAM_ALPHANUMEXT);
|
||||
if ($enabled) {
|
||||
$servicefunction->enabled = 1; //update the form "enabled" value
|
||||
} else {
|
||||
$servicefunction->enabled = 0; //update the form "enabled" value
|
||||
}
|
||||
$wsservicefunction = new object();
|
||||
$wsservicefunction->id = $servicefunction->id;
|
||||
$wsservicefunction->enabled = $servicefunction->enabled;
|
||||
$DB->update_record('external_services_functions',$wsservicefunction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data = array();
|
||||
reset($servicesfunctions);
|
||||
foreach($servicesfunctions as $function) {
|
||||
$checkbox = html_select_option::make_checkbox($function->functionid, $function->enabled, 'functionenabled');
|
||||
$checkbox->label->add_class('accesshide');
|
||||
$data[] = array($function->functionname, $function->component, $OUTPUT->checkbox($checkbox, $function->functionname));
|
||||
}
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('functionname', 'webservice'), get_string('component', 'webservice'), get_string('enabled', 'webservice'));
|
||||
$table->size = array('40%', '40%', '20%');
|
||||
$table->align = array('left', 'left', 'left');
|
||||
//$table->width = '30%';
|
||||
$table->data = $data;
|
||||
$table->tablealign = 'center';
|
||||
$formhtml .= $OUTPUT->table($table);
|
||||
|
||||
$form->button->text = get_string('save', 'webservice');
|
||||
$form->button->title = get_string('save', 'webservice');
|
||||
$form->button->id = 'save';
|
||||
$form->url = new moodle_url('webservices.php', array('serviceid' => $serviceid, 'saved' => 1));
|
||||
//$form->add_class($class);
|
||||
$formhtml .= "<br/><br/>";
|
||||
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter centerpara');
|
||||
echo $OUTPUT->form($form, $formhtml);
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -16,10 +16,12 @@ require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$baseurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=webservices";
|
||||
|
||||
if (!empty($hide)) {
|
||||
if (!confirm_sesskey()) {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', '', $baseurl);
|
||||
}
|
||||
|
||||
if (!empty($hide)) {
|
||||
|
||||
set_config("enable", !get_config($hide, "enable"), $hide);
|
||||
$return = true;
|
||||
} else if (!empty($username)) {
|
||||
|
@ -928,9 +928,6 @@ $string['warningcurrentsetting'] = 'Invalid current value: $a';
|
||||
$string['webproxy'] = 'Web proxy';
|
||||
$string['webproxyinfo'] = 'Fill in following options if your Moodle server can not access internet directly. Internet access is required for download of environment data, language packs, RSS feeds, timezones, etc.<br /><em>PHP cURL extension is highly recommended.</em>';
|
||||
$string['webservices'] = 'Web services';
|
||||
$string['webserviceprotocols'] = 'Web service servers';
|
||||
$string['webservicesystemsettings'] = 'common settings';
|
||||
$string['webserviceusersettings'] = 'Web service users settings';
|
||||
$string['xmlrpcrecommended'] = 'Installing the optional xmlrpc extension is useful for Moodle Networking functionality.';
|
||||
$string['xmlstrictheaders'] = 'XML strict headers';
|
||||
$string['useblogassociations'] = 'Enable associations';
|
||||
|
@ -478,6 +478,7 @@ $string['wrongcontextid'] = 'Context ID was incorrect (cannot find it)';
|
||||
$string['wrongdestpath'] = 'Wrong destination path';
|
||||
$string['wrongroleid'] = 'Incorrect role ID!';
|
||||
$string['wrongsourcebase'] = 'Wrong source URL base';
|
||||
$string['wrongusernamepassword'] = 'Wrong user/password';
|
||||
$string['wrongzipfilename'] = 'Wrong ZIP file name';
|
||||
$string['wscouldnotaddgroupmembernopermission'] = 'WS - Could not add group member - No permission';
|
||||
$string['wscouldnotcreateecoursenopermission'] = 'WS - Could not create course - No permission';
|
||||
@ -493,6 +494,8 @@ $string['wscouldnotupdatenoexistinguser'] = 'WS - Could not update a user - User
|
||||
$string['wscouldnotupdateuserindb'] = 'WS - Could not update a user';
|
||||
$string['wscouldnotupdateusernopermission'] = 'WS - Could not update a user - No permission';
|
||||
$string['wscouldnotvieweusernopermission'] = 'WS - Could not view a user - No permission';
|
||||
$string['wsdescriptionserviceisempty'] = 'Error during web service discovery process: \'<b>$a->functionname()</b>\' function of \'<b>$a->classname</b>\' class doesn\'t specify any \'service\' into its description';
|
||||
$string['wsdoesntextendbaseclass'] = 'Error during web service discovery process: \'<b>$a</b>\' class does not extend from moodle_external class';
|
||||
$string['wwwrootmismatch'] = 'Incorrect access detected, this server may be accessed only through \"$a\" address, sorry.<br />Please notify server administrator.';
|
||||
$string['wwwrootslash'] = 'Detected incorrect \$CFG->wwwroot in config.php, it must not contain trailing slash.<br />Please notify server administrator.';
|
||||
$string['xmldberror'] = 'XMLDB error!';
|
||||
|
@ -1,4 +1,24 @@
|
||||
<?php // $Id$
|
||||
$string['activated'] = 'Activated';
|
||||
$string['activatedfunctions'] = 'Activated functions';
|
||||
$string['amfdebug'] = 'AMF server debug mode';
|
||||
$string['clicktoactivate'] = 'Click to activate';
|
||||
$string['clicktodeactivate'] = 'Click to deactivate';
|
||||
$string['component'] = 'Component';
|
||||
$string['createservicelabel'] = 'Create a custom service';
|
||||
$string['custom'] = 'Custom';
|
||||
$string['debugdisplayon'] = '\"Display debug messages\" is set On. The XMLRPC server will not work. The other web service servers could also return some problems. <br/>Alert the Moodle administrator to set it Off.';
|
||||
$string['enabled'] = 'Enabled';
|
||||
$string['fail'] = 'FAIL';
|
||||
$string['functionlist'] = 'list of web service functions';
|
||||
$string['functionname'] = 'Function name';
|
||||
$string['moodlepath'] = 'Moodle path';
|
||||
$string['ok'] = 'OK';
|
||||
$string['protocolenable'] = '$a[0] protocol enable';
|
||||
$string['protocols'] = 'Protocols';
|
||||
$string['save'] = 'Save';
|
||||
$string['servicelist'] = 'Services';
|
||||
$string['servicename'] = 'Service name';
|
||||
$string['soapdocumentation'] = '<H2>SOAP Manual</H2>
|
||||
<b>1.</b> Call the method <b>get_token</b> on \"<i>http://remotemoodle/webservice/soap/server.php?wsdl</i>\"<br>
|
||||
The function parameter is an array: in PHP it would be array(\"username\" => \"wsuser\", \"password\" => \"wspassword\")<br>
|
||||
@ -13,6 +33,13 @@ $string['soapdocumentation'] = '<H2>SOAP Manual</H2>
|
||||
You will call something like:<br>
|
||||
your_client->tmp_delete_user(array(\"username\" => \"username_to_delete\",\"mnethostid\" => 1))<br><br>
|
||||
';
|
||||
$string['systemsettings'] = 'Common settings';
|
||||
$string['usersettings'] = 'Users with web service permissions';
|
||||
$string['webservicesenable'] = 'Web services enable';
|
||||
$string['wsdeletefunction'] = '<b>$a->functionname</b> function has been deleted from the <b>$a->servicename</b> service.';
|
||||
$string['wsinsertfunction'] = '<b>$a->functionname</b> function has been inserted into the <b>$a->servicename</b> service.';
|
||||
$string['wspagetitle'] = 'Web services documentation';
|
||||
$string['wsuserreminder'] = 'Reminder: the Moodle administrator of this site needs to give you moodle/site:usewebservices capability.';
|
||||
$string['xmlrpcdocumentation'] = '<H2>XMLRPC Manual</H2>
|
||||
<b>1.</b> Call the method <b>authentication.get_token</b> on \"<i>http://remotemoodle/webservice/xmlrpc/server.php</i>\"<br>
|
||||
The function parameter is an array: in PHP it would be array(\"username\" => \"wsuser\", \"password\" => \"wspassword\")<br>
|
||||
@ -28,15 +55,7 @@ $string['xmlrpcdocumentation'] = '<H2>XMLRPC Manual</H2>
|
||||
your_client->call(\"user.tmp_delete_user\", array(array(\"username\" => \"username_to_delete\",\"mnethostid\" => 1)))<br>
|
||||
|
||||
';
|
||||
$string['functionlist'] = 'list of web service functions';
|
||||
$string['moodlepath'] = 'Moodle path';
|
||||
$string['wspagetitle'] = 'Web services documentation';
|
||||
$string['webservicesenable'] = 'Web services enable';
|
||||
$string['protocolenable'] = '$a[0] protocol enable';
|
||||
$string['ok'] = 'OK';
|
||||
$string['fail'] = 'FAIL';
|
||||
$string['wsuserreminder'] = 'Reminder: the Moodle administrator of this site needs to give you moodle/site:usewebservices capability.';
|
||||
$string['debugdisplayon'] = '\"Display debug messages\" is set On. The XMLRPC server will not work. The other web service servers could also return some problems. <br/>Alert the Moodle administrator to set it Off.';
|
||||
$string['amfdebug'] = 'AMF server debug mode';
|
||||
|
||||
?>
|
||||
//service names
|
||||
$string['user'] = "User";
|
||||
|
||||
|
1404
lib/adminlib.php
1404
lib/adminlib.php
File diff suppressed because it is too large
Load Diff
@ -2249,7 +2249,7 @@
|
||||
<INDEX NAME="mdl1_blogexte_use_ix" UNIQUE="false" FIELDS="userid"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="comments" COMMENT="moodle comments module" PREVIOUS="blog_external">
|
||||
<TABLE NAME="comments" COMMENT="moodle comments module" PREVIOUS="blog_external" NEXT="external_functions">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="contextid"/>
|
||||
<FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="commentarea"/>
|
||||
@ -2264,5 +2264,40 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="external_functions" COMMENT="Each of these is a function" PREVIOUS="comments" NEXT="external_services">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="component"/>
|
||||
<FIELD NAME="component" TYPE="char" LENGTH="100" NOTNULL="true" PREVIOUS="id" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="150" NOTNULL="true" SEQUENCE="false" PREVIOUS="component" NEXT="phpfile"/>
|
||||
<FIELD NAME="phpfile" TYPE="char" LENGTH="255" NOTNULL="false" PREVIOUS="name" NEXT="contextrestriction"/>
|
||||
<FIELD NAME="contextrestriction" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" PREVIOUS="phpfile"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="external_services" COMMENT="Each of these is a service" PREVIOUS="external_functions" NEXT="external_services_functions">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="150" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="enabled"/>
|
||||
<FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" SEQUENCE="false" PREVIOUS="name" NEXT="custom"/>
|
||||
<FIELD NAME="custom" TYPE="int" LENGTH="1" NOTNULL="true" PREVIOUS="enabled" NEXT="customname"/>
|
||||
<FIELD NAME="customname" TYPE="char" LENGTH="150" NOTNULL="false" PREVIOUS="custom"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="external_services_functions" COMMENT="Each of these is a link service/function" PREVIOUS="external_services">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="externalserviceid"/>
|
||||
<FIELD NAME="externalserviceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" PREVIOUS="id" NEXT="externalfunctionid"/>
|
||||
<FIELD NAME="externalfunctionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" PREVIOUS="externalserviceid" NEXT="enabled"/>
|
||||
<FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" SEQUENCE="false" PREVIOUS="externalfunctionid"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
@ -125,6 +125,8 @@ final class webservice_lib {
|
||||
$externalfiles = array();
|
||||
webservice_lib::setListApiFiles($externalfiles, $CFG->dirroot);
|
||||
|
||||
$wsnotification = array();
|
||||
|
||||
//retrieve all saved services
|
||||
$services = $DB->get_records('external_services', array('custom' => 0)); //we only retrieve not custom service
|
||||
$dbservices = array();
|
||||
@ -136,7 +138,7 @@ final class webservice_lib {
|
||||
//retrieve all saved servicefunction association including their function name,
|
||||
//service name, function id and service id
|
||||
|
||||
$servicesfunctions = $DB->get_records_sql("SELECT fs.id as id, s.name as servicename, s.id as serviceid, f.name as functionname, f.id as functionid
|
||||
$servicesfunctions = $DB->get_records_sql("SELECT fs.id as id, fs.enabled as enabled, s.name as servicename, s.id as serviceid, f.name as functionname, f.id as functionid
|
||||
FROM {external_services} s, {external_functions} f, {external_services_functions} fs
|
||||
WHERE fs.externalserviceid = s.id AND fs.externalfunctionid = f.id AND s.custom = 0");
|
||||
$dbservicesfunctions = array();
|
||||
@ -171,24 +173,24 @@ final class webservice_lib {
|
||||
}
|
||||
|
||||
foreach ($descriptions as $functionname => $functiondescription) {
|
||||
|
||||
|
||||
|
||||
//only create the one not already saved into the database
|
||||
if (!array_key_exists($functionname, $dbfunctions)) {
|
||||
$newfunction = new object();
|
||||
$newfunction->component = $classpath;
|
||||
$newfunction->name = $functionname;
|
||||
$newfunction->enabled = 0;
|
||||
$DB->insert_record('external_functions', $newfunction);
|
||||
}
|
||||
|
||||
//check if the service is into the database
|
||||
if (array_key_exists('service', $functiondescription) && !empty($functiondescription['service'])) { //check that the service has been set in the description
|
||||
//only create the one not already saved into the database
|
||||
if (!array_key_exists($functionname, $dbfunctions)) {
|
||||
$newfunction = new object();
|
||||
$newfunction->component = $classpath;
|
||||
$newfunction->name = $functionname;
|
||||
$DB->insert_record('external_functions', $newfunction);
|
||||
$notifparams = new object();
|
||||
$notifparams->functionname = $functionname;
|
||||
$notifparams->servicename = $functiondescription['service'];
|
||||
$wsnotification[] = get_string('wsinsertfunction','webservice', $notifparams);
|
||||
}
|
||||
|
||||
//check if the service is into the database
|
||||
if (!array_key_exists($functiondescription['service'], $dbservices)) {
|
||||
$newservice = new object();
|
||||
$newservice->name = $functiondescription['service'];
|
||||
$newservice->enable = 0;
|
||||
$newservice->enabled = 0;
|
||||
$newservice->custom = 0;
|
||||
$DB->insert_record('external_services', $newservice);
|
||||
}
|
||||
@ -200,21 +202,18 @@ final class webservice_lib {
|
||||
$errors->classname = $classname;
|
||||
$errors->functionname = $functionname;
|
||||
throw new moodle_exception("wsdescriptionserviceisempty",'','', $errors);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//check if the couple service/function is into the database
|
||||
if (!array_key_exists($functiondescription['service'], $dbservicesfunctions) || !array_key_exists($functionname, $dbservicesfunctions[$functiondescription['service']])) {
|
||||
$newassociation = new object();
|
||||
$newassociation->externalserviceid = $DB->get_field('external_services','id',array('name' => $functiondescription['service']));
|
||||
$newassociation->externalfunctionid = $DB->get_field('external_functions','id',array('name' => $functionname, 'component' => $classpath));
|
||||
$newassociation->enabled = 0;
|
||||
$DB->insert_record('external_services_functions', $newassociation);
|
||||
}
|
||||
$dbservicesfunctions[$functiondescription['service']][$functionname]['notobsolete'] = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
throw new moodle_exception("wsdoesntextendbaseclass",'','', $classname);
|
||||
@ -233,9 +232,15 @@ final class webservice_lib {
|
||||
foreach ($servicefunctions as $functioname => $servicefunction) {
|
||||
if (!$servicefunction['notobsolete']) {
|
||||
$DB->delete_records('external_services_functions', array('id' => $servicefunction['id']));
|
||||
$notifparams = new object();
|
||||
$notifparams->functionname = $functionname;
|
||||
$notifparams->servicename = $servicename;
|
||||
$wsnotification[] = get_string('wsdeletefunction','webservice', $notifparams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $wsnotification;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -422,4 +427,54 @@ final class wssettings_form extends moodleform {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form for web service server settings (administration)
|
||||
*/
|
||||
final class wsservicesettings_form extends moodleform {
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* Definition of the moodleform
|
||||
*/
|
||||
public function definition() {
|
||||
global $DB,$CFG;
|
||||
$serviceid = $this->_customdata['serviceid'];
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mform->addElement('hidden', 'serviceid', $serviceid);
|
||||
$param = new stdClass();
|
||||
|
||||
// require_once($CFG->dirroot . '/webservice/'. $settings . '/lib.php');
|
||||
// $servername = $settings.'_server';
|
||||
// $server = new $servername();
|
||||
// $server->settings_form($mform);
|
||||
|
||||
// set the data if we have some.
|
||||
// $data = array();
|
||||
// $option_names = $server->get_setting_names();
|
||||
// foreach ($option_names as $config) {
|
||||
// $data[$config] = get_config($settings, $config);
|
||||
// }
|
||||
// $this->set_data($data);
|
||||
$service = $DB->get_record('external_services',array('id' => $serviceid));
|
||||
|
||||
$mform->addElement('text', 'servicename', get_string('servicename', 'webservice'));
|
||||
$mform->setDefault('servicename',get_string($service->name, 'webservice'));
|
||||
if (!empty($serviceid)) {
|
||||
$mform->disabledIf('servicename', 'serviceid', 'eq', $serviceid);
|
||||
}
|
||||
|
||||
if (empty($serviceid)) {
|
||||
//display list of functions to select
|
||||
}
|
||||
|
||||
//display list of functions associated to the service
|
||||
|
||||
|
||||
|
||||
$this->add_action_buttons(true, get_string('savechanges','admin'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user