From f8045246050b7748399a5e79eb9b85991808fb93 Mon Sep 17 00:00:00 2001 From: Botond Hegedus Date: Sun, 15 Feb 2015 12:33:37 +0000 Subject: [PATCH] MDL-49198 core_webservice: Fix error when using existing service name --- admin/webservice/forms.php | 7 +++++++ lang/en/webservice.php | 1 + 2 files changed, 8 insertions(+) diff --git a/admin/webservice/forms.php b/admin/webservice/forms.php index 9465bf416ea..3060292604b 100644 --- a/admin/webservice/forms.php +++ b/admin/webservice/forms.php @@ -157,6 +157,13 @@ class external_service_form extends moodleform { $errors = parent::validation($data, $files); + // Add field validation check for duplicate name. + if (!empty($data['name'])) { + if ($DB->record_exists('external_services', array('name' => $data['name']))) { + $errors['name'] = get_string('nameexists', 'webservice'); + } + } + // Add field validation check for duplicate shortname. // Allow duplicated "empty" shortnames. if (!empty($data['shortname'])) { diff --git a/lang/en/webservice.php b/lang/en/webservice.php index 76172161db1..b05912728ff 100644 --- a/lang/en/webservice.php +++ b/lang/en/webservice.php @@ -126,6 +126,7 @@ $string['missingusername'] = 'Missing username'; $string['missingversionfile'] = 'Coding error: version.php file is missing for the component {$a}'; $string['mobilewsdisabled'] = 'Disabled'; $string['mobilewsenabled'] = 'Enabled'; +$string['nameexists'] = 'This name is already in use by another service'; $string['nocapabilitytouseparameter'] = 'The user does not have the required capability to use the parameter {$a}'; $string['nofunctions'] = 'This service has no functions.'; $string['norequiredcapability'] = 'No required capability';