From 2eaa622161720d95ac3f627b4adec97e3a22ac7c Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 27 Dec 2017 19:51:34 +0400 Subject: Added external function display a list of events --- externallib.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/externallib.php b/externallib.php index 8acd3af..aa807a7 100644 --- a/externallib.php +++ b/externallib.php @@ -227,6 +227,50 @@ class local_webhooks_external extends external_api { ); } + /** + * Returns description of method parameters. + * + * @return external_function_parameters + * @since Moodle 2.9 Options available + * @since Moodle 2.2 + */ + public static function get_list_events_parameters() { + return new external_function_parameters(array()); + } + + /** + * Get a list of all system events. + * + * @return array + * @since Moodle 2.9 Options available + * @since Moodle 2.2 + */ + public static function get_list_events() { + $context = context_system::instance(); + self::validate_context($context); + + $result = array(); + if ($eventlist = local_webhooks_get_list_events()) { + foreach ($eventlist as $item) { + $result[] = $item["eventname"]; + } + } + + return $result; + } + + /** + * Returns description of method result value. + * + * @return external_description + * @since Moodle 2.2 + */ + public static function get_list_events_returns() { + return new external_multiple_structure( + new external_value(PARAM_TEXT, "Event name.") + ); + } + /** * Returns description of method parameters. * -- cgit v1.2.3