The search function is expanded

This commit is contained in:
Valentin Popov 2018-02-19 15:05:58 +04:00
parent a41dbbb950
commit 3a2bddeea4

12
lib.php
View File

@ -48,16 +48,24 @@ function local_webhooks_change_status($serviceid) {
* Search for services that contain the specified event. * Search for services that contain the specified event.
* *
* @param string $eventname * @param string $eventname
* @param boolean $active
* @return array * @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(); $recordlist = local_webhooks_get_list_records();
$active = boolval($active);
$result = array(); $result = array();
foreach ($recordlist as $record) { foreach ($recordlist as $record) {
if (boolval($record->enable) && !empty($record->events[$eventname])) { if (!empty($record->events[$eventname])) {
if ($active && boolval($record->enable)) {
$result[] = $record; $result[] = $record;
} }
if (!$active) {
$result[] = $record;
}
}
} }
return $result; return $result;