From 0d9fe62ec617d946737bcfab79d7b6ebe825d7ec Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 12 Mar 2018 23:38:14 +0400 Subject: The function 'local_webhooks_insert_event' is replaced by the function 'local_webhooks_insert_events' Signed-off-by: Valentin Popov --- locallib.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'locallib.php') 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); } /** -- cgit v1.2.3