summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/service_form.php4
-rw-r--r--editservice.php25
2 files changed, 28 insertions, 1 deletions
diff --git a/classes/service_form.php b/classes/service_form.php
index eac7bb7..eef6e5c 100644
--- a/classes/service_form.php
+++ b/classes/service_form.php
@@ -91,7 +91,9 @@ class service_edit_form extends moodleform {
/* Formation of the list of elements */
foreach ($eventlist as $event) {
- $events[$event['component']][] =& $mform->createElement('checkbox', $event['eventname'], $event['eventname']);
+ /* Escaping event names */
+ $eventname = base64_encode($event['eventname']);
+ $events[$event['component']][] =& $mform->createElement('checkbox', $eventname, $event['eventname']);
}
/* Displays groups of items */
diff --git a/editservice.php b/editservice.php
index 821e0cc..de99556 100644
--- a/editservice.php
+++ b/editservice.php
@@ -52,11 +52,36 @@ if ($mform->is_cancelled()) {
$servicerecord = new stdClass();
if ($editing = (bool) $serviceid) {
$servicerecord = local_webhooks_get_record($serviceid);
+
+ if (is_array($servicerecord->events)) {
+ $events = array();
+
+ /* Escaping event names */
+ foreach ($servicerecord->events as $eventname => $eventstatus) {
+ $eventname = base64_encode($eventname);
+ $events[$eventname] = $eventstatus;
+ }
+
+ $servicerecord->events = $events;
+ }
+
$mform->set_data($servicerecord);
}
/* Processing of received data */
if ($data = $mform->get_data()) {
+ if (is_array($data->events)) {
+ $events = array();
+
+ /* Deciphering event names */
+ foreach ($data->events as $eventname => $eventstatus) {
+ $eventname = (string) base64_decode($eventname);
+ $events[$eventname] = $eventstatus;
+ }
+
+ $data->events = $events;
+ }
+
if ($editing) {
$data->id = $serviceid;
local_webhooks_update_record($data, false);