From 9e4c2dcbaef31a2de6d13bf8056a76999d7fbb04 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 27 Oct 2017 10:57:40 +0400 Subject: Rename a class --- classes/editform.php | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++ classes/forms.php | 115 --------------------------------------------------- editservice.php | 2 +- 3 files changed, 116 insertions(+), 116 deletions(-) create mode 100644 classes/editform.php delete mode 100644 classes/forms.php diff --git a/classes/editform.php b/classes/editform.php new file mode 100644 index 0000000..5e75050 --- /dev/null +++ b/classes/editform.php @@ -0,0 +1,115 @@ +. + +/** + * Defines the form of editing the service. + * + * @package local_webhooks + * @copyright 2017 "Valentin Popov" + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace local_webhooks; + +defined("MOODLE_INTERNAL") || die(); + +require_once($CFG->libdir . "/formslib.php"); + +use report_eventlist_list_generator; +use lang_string; +use moodleform; + +/** + * Description editing form definition. + * + * @copyright 2017 "Valentin Popov" + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class service_edit_form extends moodleform { + /** + * @param string $baseurl + */ + public function __construct($baseurl) { + parent::__construct($baseurl); + } + + /** + * Unpacks data for display. + * + * @param object $record + */ + public function set_data($record) { + if (!empty($record->events)) { + $record->events = unserialize(gzuncompress(base64_decode($record->events))); + } + + return parent::set_data($record); + } + + /** + * Defines the standard structure of the form. + */ + protected function definition() { + $mform =& $this->_form; + + /* Form heading */ + $mform->addElement("header", "editserviceheader", new lang_string("service", "webservice")); + + /* Name of the service */ + $mform->addElement("text", "title", new lang_string("name", "moodle"), array("size" => 60)); + $mform->addRule("title", null, "required"); + $mform->setType("title", PARAM_NOTAGS); + + /* Callback address */ + $mform->addElement("text", "url", new lang_string("url", "moodle"), array("size" => 60)); + $mform->addRule("url", null, "required"); + $mform->setType("url", PARAM_URL); + + /* Enabling the service */ + $mform->addElement("advcheckbox", "enable", new lang_string("enable", "moodle")); + $mform->setType("enable", PARAM_BOOL); + $mform->setDefault("enable", 1); + $mform->setAdvanced("enable"); + + /* Token */ + $mform->addElement("text", "token", new lang_string("token", "webservice"), array("size" => 60)); + $mform->setType("token", PARAM_NOTAGS); + + /* Content type */ + $mform->addElement("select", "type", "Content type", array("json" => "application/json", "x-www-form-urlencoded" => "application/x-www-form-urlencoded")); + $mform->setAdvanced("type"); + + /* 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("checkbox", $event["eventname"], $event["eventname"]); + } + + /* Displays groups of items */ + foreach ($events as $key => $event) { + $mform->addGroup($event, "events", $key, "
", true); + } + + /* Control Panel */ + $this->add_action_buttons(true); + } +} \ No newline at end of file diff --git a/classes/forms.php b/classes/forms.php deleted file mode 100644 index 5e75050..0000000 --- a/classes/forms.php +++ /dev/null @@ -1,115 +0,0 @@ -. - -/** - * Defines the form of editing the service. - * - * @package local_webhooks - * @copyright 2017 "Valentin Popov" - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace local_webhooks; - -defined("MOODLE_INTERNAL") || die(); - -require_once($CFG->libdir . "/formslib.php"); - -use report_eventlist_list_generator; -use lang_string; -use moodleform; - -/** - * Description editing form definition. - * - * @copyright 2017 "Valentin Popov" - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class service_edit_form extends moodleform { - /** - * @param string $baseurl - */ - public function __construct($baseurl) { - parent::__construct($baseurl); - } - - /** - * Unpacks data for display. - * - * @param object $record - */ - public function set_data($record) { - if (!empty($record->events)) { - $record->events = unserialize(gzuncompress(base64_decode($record->events))); - } - - return parent::set_data($record); - } - - /** - * Defines the standard structure of the form. - */ - protected function definition() { - $mform =& $this->_form; - - /* Form heading */ - $mform->addElement("header", "editserviceheader", new lang_string("service", "webservice")); - - /* Name of the service */ - $mform->addElement("text", "title", new lang_string("name", "moodle"), array("size" => 60)); - $mform->addRule("title", null, "required"); - $mform->setType("title", PARAM_NOTAGS); - - /* Callback address */ - $mform->addElement("text", "url", new lang_string("url", "moodle"), array("size" => 60)); - $mform->addRule("url", null, "required"); - $mform->setType("url", PARAM_URL); - - /* Enabling the service */ - $mform->addElement("advcheckbox", "enable", new lang_string("enable", "moodle")); - $mform->setType("enable", PARAM_BOOL); - $mform->setDefault("enable", 1); - $mform->setAdvanced("enable"); - - /* Token */ - $mform->addElement("text", "token", new lang_string("token", "webservice"), array("size" => 60)); - $mform->setType("token", PARAM_NOTAGS); - - /* Content type */ - $mform->addElement("select", "type", "Content type", array("json" => "application/json", "x-www-form-urlencoded" => "application/x-www-form-urlencoded")); - $mform->setAdvanced("type"); - - /* 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("checkbox", $event["eventname"], $event["eventname"]); - } - - /* Displays groups of items */ - foreach ($events as $key => $event) { - $mform->addGroup($event, "events", $key, "
", true); - } - - /* Control Panel */ - $this->add_action_buttons(true); - } -} \ No newline at end of file diff --git a/editservice.php b/editservice.php index 986ce9a..40bab9e 100644 --- a/editservice.php +++ b/editservice.php @@ -23,8 +23,8 @@ */ require_once(__DIR__ . "/../../config.php"); +require_once(__DIR__ . "/classes/editform.php"); require_once($CFG->libdir . "/adminlib.php"); -require_once(__DIR__ . "/classes/forms.php"); admin_externalpage_setup("managelocalplugins"); -- cgit v1.2.3