mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
Merged branch 'MLD-27551' of git://github.com/mouneyrac/moodle.git with changes
This commit is contained in:
commit
96e0194c05
11 changed files with 239 additions and 3 deletions
|
@ -904,6 +904,7 @@ function external_update_descriptions($component) {
|
|||
$service['enabled'] = empty($service['enabled']) ? 0 : $service['enabled'];
|
||||
$service['requiredcapability'] = empty($service['requiredcapability']) ? null : $service['requiredcapability'];
|
||||
$service['restrictedusers'] = !isset($service['restrictedusers']) ? 1 : $service['restrictedusers'];
|
||||
$service['shortname'] = !isset($service['shortname']) ? null : $service['shortname'];
|
||||
|
||||
$update = false;
|
||||
if ($dbservice->enabled != $service['enabled']) {
|
||||
|
@ -918,6 +919,23 @@ function external_update_descriptions($component) {
|
|||
$dbservice->restrictedusers = $service['restrictedusers'];
|
||||
$update = true;
|
||||
}
|
||||
//if shortname is not a PARAM_ALPHANUMEXT, fail (tested here for service update and creation)
|
||||
if (isset($service['shortname']) and
|
||||
(clean_param($service['shortname'], PARAM_ALPHANUMEXT) != $service['shortname'])) {
|
||||
throw new moodle_exception('installserviceshortnameerror', 'webservice', '', $service['shortname']);
|
||||
}
|
||||
if ($dbservice->shortname != $service['shortname']) {
|
||||
//check that shortname is unique
|
||||
if (isset($service['shortname'])) { //we currently accepts multiple shortname == null
|
||||
$existingservice = $DB->get_record('external_services',
|
||||
array('shortname' => $service['shortname']));
|
||||
if (!empty($existingservice)) {
|
||||
throw new moodle_exception('installexistingserviceshortnameerror', 'webservice', '', $service['shortname']);
|
||||
}
|
||||
}
|
||||
$dbservice->shortname = $service['shortname'];
|
||||
$update = true;
|
||||
}
|
||||
if ($update) {
|
||||
$DB->update_record('external_services', $dbservice);
|
||||
}
|
||||
|
@ -940,11 +958,21 @@ function external_update_descriptions($component) {
|
|||
unset($functions);
|
||||
}
|
||||
foreach ($services as $name => $service) {
|
||||
//check that shortname is unique
|
||||
if (isset($service['shortname'])) { //we currently accepts multiple shortname == null
|
||||
$existingservice = $DB->get_record('external_services',
|
||||
array('shortname' => $service['shortname']));
|
||||
if (!empty($existingservice)) {
|
||||
throw new moodle_exception('installserviceshortnameerror', 'webservice');
|
||||
}
|
||||
}
|
||||
|
||||
$dbservice = new stdClass();
|
||||
$dbservice->name = $name;
|
||||
$dbservice->enabled = empty($service['enabled']) ? 0 : $service['enabled'];
|
||||
$dbservice->requiredcapability = empty($service['requiredcapability']) ? null : $service['requiredcapability'];
|
||||
$dbservice->restrictedusers = !isset($service['restrictedusers']) ? 1 : $service['restrictedusers'];
|
||||
$dbservice->shortname = !isset($service['shortname']) ? null : $service['shortname'];
|
||||
$dbservice->component = $component;
|
||||
$dbservice->timecreated = time();
|
||||
$dbservice->id = $DB->insert_record('external_services', $dbservice);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue