aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib.php30
1 files changed, 14 insertions, 16 deletions
diff --git a/lib.php b/lib.php
index 9bc8389..ba27486 100644
--- a/lib.php
+++ b/lib.php
@@ -47,27 +47,25 @@ function local_webhooks_change_status($serviceid) {
/**
* Search for services that contain the specified event.
*
- * @param string $eventname
- * @param boolean $active
+ * @param string $eventname
+ * @param number $limitfrom
+ * @param number $limitnum
* @return array
*/
-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 (!empty($record->events[$eventname])) {
- if ($active && boolval($record->enable)) {
- $result[] = $record;
- }
-
- if (!$active) {
- $result[] = $record;
- }
+function local_webhooks_search_record($eventname, $limitfrom = 0, $limitnum = 0) {
+ global $DB;
+
+ $rs = $DB->get_recordset(LOCAL_WEBHOOKS_TABLE_EVENTS, array("name" => $eventname, "status" => true), "id", "*", $limitfrom, $limitnum);
+ $result = array();
+
+ foreach ($rs as $event) {
+ if ($record = $DB->get_record(LOCAL_WEBHOOKS_TABLE_SERVICES, array("id" => $event->serviceid, "status" => true), "*", IGNORE_MISSING)) {
+ $result[] = $record;
}
}
+ $rs->close();
+
return $result;
}