From 3a2bddeea47c9b031367fe0566ed55e821fe4b95 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 19 Feb 2018 15:05:58 +0400 Subject: The search function is expanded --- lib.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib.php b/lib.php index 2f6a020..9c82e2c 100644 --- a/lib.php +++ b/lib.php @@ -47,16 +47,24 @@ function local_webhooks_change_status($serviceid) { /** * Search for services that contain the specified event. * - * @param string $eventname + * @param string $eventname + * @param boolean $active * @return array */ -function local_webhooks_search_services_by_event($eventname) { +function local_webhooks_search_services_by_event($eventname, $active = false) { $recordlist = local_webhooks_get_list_records(); + $active = boolval($active); $result = array(); foreach ($recordlist as $record) { - if (boolval($record->enable) && !empty($record->events[$eventname])) { - $result[] = $record; + if (!empty($record->events[$eventname])) { + if ($active && boolval($record->enable)) { + $result[] = $record; + } + + if (!$active) { + $result[] = $record; + } } } -- cgit v1.2.3