diff options
author | Valentin Popov <info@valentineus.link> | 2018-03-12 22:38:14 +0300 |
---|---|---|
committer | Valentin Popov <info@valentineus.link> | 2018-03-12 22:38:14 +0300 |
commit | 0d9fe62ec617d946737bcfab79d7b6ebe825d7ec (patch) | |
tree | 11f5bad8374dc158da16deb5ee61e1d69705d5c0 | |
parent | 2b7e419f8faa7b8fd55b5bf7c9867f794e36e774 (diff) | |
download | local_webhooks-0d9fe62ec617d946737bcfab79d7b6ebe825d7ec.tar.xz local_webhooks-0d9fe62ec617d946737bcfab79d7b6ebe825d7ec.zip |
The function 'local_webhooks_insert_event' is replaced by the function 'local_webhooks_insert_events'
Signed-off-by: Valentin Popov <info@valentineus.link>
-rw-r--r-- | locallib.php | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/locallib.php b/locallib.php index 43eddae..0a776b0 100644 --- a/locallib.php +++ b/locallib.php @@ -72,14 +72,25 @@ function local_webhooks_cache_reset() { } /** - * Adding an event to the database. + * Adds all events to the database. * - * @param object $event + * @param number $serviceid + * @param array $events * @return boolean */ -function local_webhooks_insert_event($event) { - global $DB; - return $DB->insert_record(LOCAL_WEBHOOKS_TABLE_EVENTS, $event, true, false); +function local_webhooks_insert_events($serviceid, $events) { + $records = array(); + + foreach ($events as $eventname => $eventstatus) { + $event = new stdClass(); + $event->name = $eventname; + $event->status = $eventstatus; + $event->serviceid = $serviceid; + $records[] = $event; + } + + local_webhooks_delete_events($serviceid); + return $DB->insert_records(LOCAL_WEBHOOKS_TABLE_EVENTS, $records); } /** |