mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-29807 Fixed invalid add_record_snapshot references and also inexistent check of empty short names
This commit is contained in:
parent
0a8ab74728
commit
eb625bcf64
@ -158,9 +158,12 @@ class external_service_form extends moodleform {
|
||||
$errors = parent::validation($data, $files);
|
||||
|
||||
// Add field validation check for duplicate shortname.
|
||||
if ($service = $DB->get_record('external_services', array('shortname' => $data['shortname']), '*', IGNORE_MULTIPLE)) {
|
||||
if (empty($data['id']) || $service->id != $data['id']) {
|
||||
$errors['shortname'] = get_string('shortnametaken', 'webservice', $service->name);
|
||||
// Allow duplicated "empty" shortnames.
|
||||
if (!empty($data['shortname'])) {
|
||||
if ($service = $DB->get_record('external_services', array('shortname' => $data['shortname']), '*', IGNORE_MULTIPLE)) {
|
||||
if (empty($data['id']) || $service->id != $data['id']) {
|
||||
$errors['shortname'] = get_string('shortnametaken', 'webservice', $service->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,6 @@ if ($mform->is_cancelled()) {
|
||||
'objectid' => $servicedata->id
|
||||
);
|
||||
$event = \core\event\webservice_service_created::create($params);
|
||||
$event->add_record_snapshot('external_services', $servicedata);
|
||||
$event->trigger();
|
||||
|
||||
//redirect to the 'add functions to service' page
|
||||
@ -99,7 +98,6 @@ if ($mform->is_cancelled()) {
|
||||
'objectid' => $servicedata->id
|
||||
);
|
||||
$event = \core\event\webservice_service_updated::create($params);
|
||||
$event->add_record_snapshot('external_services', $servicedata);
|
||||
$event->trigger();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user