From bae23caa877e592e33f02fe17c93f7931257b796 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Oct 2017 06:25:48 +0400 Subject: The generator of the list of registered events --- classes/forms.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'classes/forms.php') diff --git a/classes/forms.php b/classes/forms.php index 2fbd8cc..d6402cc 100644 --- a/classes/forms.php +++ b/classes/forms.php @@ -46,6 +46,16 @@ class service_edit_form extends moodleform { parent::__construct($baseurl); } + /** + * 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. */ @@ -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, "
", true); } - $this->add_checkbox_controller("events", null, null, 1); /* Control Panel */ $this->add_action_buttons(true); -- cgit v1.2.3