From 79fe101e1b7fc311146914026c0369958e4b68c5 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 13 Mar 2018 00:08:18 +0400 Subject: Added function 'local_webhooks_get_list_events_for_service' Signed-off-by: Valentin Popov --- locallib.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/locallib.php b/locallib.php index 4fae651..392d01d 100644 --- a/locallib.php +++ b/locallib.php @@ -71,6 +71,27 @@ function local_webhooks_cache_reset() { return $cache->purge(); } +/** + * Forms a list of events for the specified service. + * + * @param number $serviceid + * @return array + */ +function local_webhooks_get_list_events_for_service($serviceid) { + global $DB; + + $rs = $DB->get_recordset(LOCAL_WEBHOOKS_TABLE_EVENTS, array("serviceid" => $serviceid), "id", "*", 0, 0); + $events = array(); + + foreach ($rs as $record) { + $events[$record->name] = $record->status; + } + + $rs->close(); + + return $events; +} + /** * Adds all events to the database. * -- cgit v1.2.3