MDL-29807 Fixed invalid add_record_snapshot references and also inexistent check...
authorJuan Leyva <juanleyvadelgado@gmail.com>
Mon, 17 Mar 2014 11:35:20 +0000 (12:35 +0100)
committerJuan Leyva <juanleyvadelgado@gmail.com>
Mon, 17 Mar 2014 11:35:20 +0000 (12:35 +0100)
admin/webservice/forms.php
admin/webservice/service.php

index 785e115..41c15c2 100644 (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);
+                }
             }
         }
 
index 0abf9d0..d99bf58 100644 (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();
     }