diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/events.php | 26 | ||||
-rw-r--r-- | classes/forms.php | 30 |
2 files changed, 50 insertions, 6 deletions
diff --git a/classes/events.php b/classes/events.php index 5dfb0cf..33e278b 100644 --- a/classes/events.php +++ b/classes/events.php @@ -59,7 +59,7 @@ class events { if ($callbacks->valid()) { foreach ($callbacks as $callback) { - self::send($data, $callback); + self::handler_callback($data, $callback); } } @@ -67,20 +67,34 @@ class events { } /** - * Sending data to the node. + * Processes each callback. * * @param array $data * @param object $callback */ - private static function send($data, $callback) { + private static function handler_callback($data, $callback) { if ($callback->enable) { - $curl = new curl(); - $package = self::packup($data); - $curl::request($callback->url, $package); + $events = unserialize(gzuncompress(base64_decode($callback->events))); + + if (boolval($events[$data["eventname"]])) { + self::send($data, $callback); + } } } /** + * Sending data to the node. + * + * @param array $data + * @param object $callback + */ + private static function send($data, $callback) { + $curl = new curl(); + $package = self::packup($data); + $curl::request($callback->url, $package); + } + + /** * Packs the data for transmission. * * @param array $data diff --git a/classes/forms.php b/classes/forms.php index c95b280..d6402cc 100644 --- a/classes/forms.php +++ b/classes/forms.php @@ -28,6 +28,7 @@ defined("MOODLE_INTERNAL") || die(); require_once($CFG->libdir . "/formslib.php"); +use report_eventlist_list_generator; use lang_string; use moodleform; @@ -46,6 +47,16 @@ class service_edit_form extends moodleform { } /** + * Unpacks data for display. + * + * @param object $record + */ + public function set_data($record) { + $record->events = unserialize(gzuncompress(base64_decode($record->events))); + return parent::set_data($record); + } + + /** * Defines the standard structure of the form. */ protected function definition() { @@ -76,6 +87,25 @@ class service_edit_form extends moodleform { $mform->setDefault("enable", 1); $mform->setAdvanced("enable"); + /* Form heading */ + $mform->addElement("header", "editserviceheaderevent", + new lang_string("edulevel", "moodle")); + + /* List of events */ + $eventlist = report_eventlist_list_generator::get_all_events_list(true); + $events = array(); + + /* Formation of the list of elements */ + foreach ($eventlist as $event) { + $events[$event["component"]][] =& + $mform->createElement("advcheckbox", $event["eventname"], $event["eventname"]); + } + + /* Displays groups of items */ + foreach ($events as $key => $event) { + $mform->addGroup($event, "events", $key, "<br />", true); + } + /* Control Panel */ $this->add_action_buttons(true); } |