aboutsummaryrefslogtreecommitdiff
path: root/lib.php
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2018-09-09 03:38:27 +0300
committerValentin Popov <info@valentineus.link>2018-09-09 03:38:27 +0300
commit17b9cfde78bd49ac9fe7c2406945a851400a69bb (patch)
tree5446ad5e401666294b2cedcb0eeb392e391763d5 /lib.php
parent270c04a603ffba79fd8c916b1b548c987b780682 (diff)
downloadlocal_webhooks-17b9cfde78bd49ac9fe7c2406945a851400a69bb.tar.xz
local_webhooks-17b9cfde78bd49ac9fe7c2406945a851400a69bb.zip
Service search function on the event
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'lib.php')
-rw-r--r--lib.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib.php b/lib.php
index 3abd756..3f0865c 100644
--- a/lib.php
+++ b/lib.php
@@ -86,6 +86,29 @@ class local_webhooks_api {
}
/**
+ * Get the list of services subscribed to the event.
+ *
+ * @param string $eventName
+ * @return array
+ */
+ public static function get_services_by_event( $eventName = "" ) {
+ global $DB;
+
+ if ( !is_string( $eventName ) || empty( $eventName ) ) {
+ print_error( "unknowparamtype", "error", null, "eventName" );
+ }
+
+ $events = $DB->get_records( LW_TABLE_EVENTS, array( "name" => $eventName ), "", "*", 0, 0 );
+
+ $services = array();
+ foreach ( $events as $event ) {
+ $services[] = local_webhooks_api::get_service( $event->serviceid );
+ }
+
+ return $services;
+ }
+
+ /**
* Create service data in the database.
*
* @param array $service