summaryrefslogtreecommitdiff
path: root/editservice.php
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2018-11-02 01:03:17 +0300
committerValentin Popov <info@valentineus.link>2018-11-02 01:03:17 +0300
commit849d7126d8674faac056b941038f5fd59811e34f (patch)
tree3c14a0e5d67d733d58a1fda23ae77ab6c2b15234 /editservice.php
parentd8f3a9f3edf66fad0af84a703e39e45911f37d85 (diff)
downloadlocal_webhooks-849d7126d8674faac056b941038f5fd59811e34f.tar.xz
local_webhooks-849d7126d8674faac056b941038f5fd59811e34f.zip
Correction of work with event names
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'editservice.php')
-rw-r--r--editservice.php25
1 files changed, 25 insertions, 0 deletions
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);