MDL-29807 Fixed invalid add_record_snapshot references and also inexistent check of empty short names

This commit is contained in:
Juan Leyva 2014-03-17 12:35:20 +01:00
parent 0a8ab74728
commit eb625bcf64
2 changed files with 6 additions and 5 deletions

View File

@ -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);
}
}
}

View File

@ -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();
}