summaryrefslogtreecommitdiff
path: root/classes/forms.php
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2017-10-26 05:25:48 +0300
committerValentin Popov <info@valentineus.link>2017-10-26 05:25:48 +0300
commitbae23caa877e592e33f02fe17c93f7931257b796 (patch)
treee2d19a7103a3f5c807971f1519d438c1f02e2d55 /classes/forms.php
parent0d8cb8688d1aedf5498b08863f271ce8f77f8912 (diff)
downloadlocal_webhooks-bae23caa877e592e33f02fe17c93f7931257b796.tar.xz
local_webhooks-bae23caa877e592e33f02fe17c93f7931257b796.zip
The generator of the list of registered events
Diffstat (limited to 'classes/forms.php')
-rw-r--r--classes/forms.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/classes/forms.php b/classes/forms.php
index 2fbd8cc..d6402cc 100644
--- a/classes/forms.php
+++ b/classes/forms.php
@@ -47,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() {
@@ -83,14 +93,18 @@ class service_edit_form extends moodleform {
/* 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) {
- $eventname = $event["eventname"];
- $mform->addElement("advcheckbox", "events[$eventname]",
- $eventname, $event["component"],
- array("group" => "events"));
- $mform->setType($eventname, PARAM_BOOL);
+ $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);
}
- $this->add_checkbox_controller("events", null, null, 1);
/* Control Panel */
$this->add_action_buttons(true);