From 29bdbc745614b8ac19259229a028efa03d8d4ddb Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 18 Feb 2018 21:37:43 +0400 Subject: Added a service search function that contains the specified event --- lib.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib.php') diff --git a/lib.php b/lib.php index b6321e4..e3f034e 100644 --- a/lib.php +++ b/lib.php @@ -44,6 +44,25 @@ function local_webhooks_change_status($serviceid) { return $result; } +/** + * Search for services that contain the specified event. + * + * @param string $eventname + * @return array + */ +function local_webhooks_search_services_by_event($eventname) { + $recordlist = local_webhooks_get_list_records(); + $result = array(); + + foreach ($recordlist as $record) { + if (boolval($record->enable) && !empty($record->events[$eventname])) { + $result[] = $record; + } + } + + return $result; +} + /** * Get the record from the database. * -- cgit v1.2.3