aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2018-03-13 00:17:22 +0300
committerValentin Popov <info@valentineus.link>2018-03-13 00:17:22 +0300
commit6a83be960ec751eb42628e92e90b237efcb62a36 (patch)
tree02424b1fe58105312528159f5103144904b6ff61
parent82842e5ed85cc51d5024c2abb28b20b1d48ef021 (diff)
downloadlocal_webhooks-6a83be960ec751eb42628e92e90b237efcb62a36.tar.xz
local_webhooks-6a83be960ec751eb42628e92e90b237efcb62a36.zip
Update function 'local_webhooks_search_record'
Signed-off-by: Valentin Popov <info@valentineus.link>
-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;
}