aboutsummaryrefslogtreecommitdiff
path: root/lib.php
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2018-03-12 22:45:35 +0300
committerValentin Popov <info@valentineus.link>2018-03-12 22:45:35 +0300
commit639276c33d42ee72fe71278cc7209231c31a060a (patch)
treecd768af56ad4ebcfb5e414783274943e243e6ed6 /lib.php
parent0d9fe62ec617d946737bcfab79d7b6ebe825d7ec (diff)
downloadlocal_webhooks-639276c33d42ee72fe71278cc7209231c31a060a.tar.xz
local_webhooks-639276c33d42ee72fe71278cc7209231c31a060a.zip
Added function 'local_webhooks_update_record'
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'lib.php')
-rw-r--r--lib.php11
1 files changed, 9 insertions, 2 deletions
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();