From 639276c33d42ee72fe71278cc7209231c31a060a Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 12 Mar 2018 23:45:35 +0400 Subject: Added function 'local_webhooks_update_record' Signed-off-by: Valentin Popov --- lib.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib.php') diff --git a/lib.php b/lib.php index c57baeb..af8fba5 100644 --- a/lib.php +++ b/lib.php @@ -172,7 +172,7 @@ function local_webhooks_create_record($record) { /** * Update the record in the database. * - * @param object $data + * @param object $record * @return boolean */ function local_webhooks_update_record($record) { @@ -182,8 +182,15 @@ function local_webhooks_update_record($record) { print_error("missingparam", "error", null, "id"); } - $record->events = !empty($record->events) ? local_webhooks_serialization_data($record->events) : null; + if (empty($record->events)) { + $record->events = array(); + } + + /* Update records */ + $transaction = $DB->start_delegated_transaction(); $result = $DB->update_record(LOCAL_WEBHOOKS_TABLE_SERVICES, $record, false); + local_webhooks_insert_events($record->id, $record->events); + $transaction->allow_commit(); /* Clear the plugin cache */ local_webhooks_cache_reset(); -- cgit v1.2.3