diff options
author | Valentin Popov <info@valentineus.link> | 2018-03-12 22:48:00 +0300 |
---|---|---|
committer | Valentin Popov <info@valentineus.link> | 2018-03-12 22:48:00 +0300 |
commit | 57a870f56f3505dbb323cb6461286b03b522bacc (patch) | |
tree | 1f2a8d43051206267bf2fdbd559bb0c1938dcd55 | |
parent | 639276c33d42ee72fe71278cc7209231c31a060a (diff) | |
download | local_webhooks-57a870f56f3505dbb323cb6461286b03b522bacc.tar.xz local_webhooks-57a870f56f3505dbb323cb6461286b03b522bacc.zip |
Update function 'local_webhooks_create_record'
Signed-off-by: Valentin Popov <info@valentineus.link>
-rw-r--r-- | lib.php | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -144,20 +144,14 @@ function local_webhooks_get_total_count() { function local_webhooks_create_record($record) { global $DB; - $transaction = $DB->start_delegated_transaction(); - $serviceid = $DB->insert_record(LOCAL_WEBHOOKS_TABLE_SERVICES, $record, true, false); - - if (!empty($record->events)) { - foreach ($record->events as $eventname => $eventstatus) { - $event = new stdClass(); - $event->name = $eventname; - $event->serviceid = $serviceid; - $event->status = $record->status; - - $DB->insert_record(LOCAL_WEBHOOKS_TABLE_EVENTS, $event, false, false); - } + if (empty($record->events)) { + $record->events = array(); } + /* Adding entries */ + $transaction = $DB->start_delegated_transaction(); + $serviceid = $DB->insert_record(LOCAL_WEBHOOKS_TABLE_SERVICES, $record, true, false); + local_webhooks_insert_events($serviceid, $record->events); $transaction->allow_commit(); /* Clear the plugin cache */ |