From be91a4c9b4e5d35f74208c45950ce70de659371b Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 22 Oct 2017 13:45:49 +0400 Subject: Forming the settings page --- lang/en/local_webhooks.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lang/en/local_webhooks.php') diff --git a/lang/en/local_webhooks.php b/lang/en/local_webhooks.php index 05def67..b230a69 100644 --- a/lang/en/local_webhooks.php +++ b/lang/en/local_webhooks.php @@ -15,16 +15,15 @@ // along with Moodle. If not, see . /** - * Strings for component 'local_webhooks', language 'en'. + * Strings for component "local_webhooks", language "en". * * @package local_webhooks * @copyright 2017 "Valentin Popov" * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['local_webhooksdescription'] = ''; -$string['pluginname'] = 'WebHook\'s'; -$string['enabled'] = 'Enabled'; -$string['enabled_help'] = 'Enable event tracking.'; -$string['url'] = 'URL'; -$string['url_help'] = 'Web address of the remote service.'; \ No newline at end of file +$string["enableservice"] = "Enabled"; +$string["enableservice_help"] = "Enable the Event Tracking service."; +$string["linkmanagerservice"] = "Service management manager"; +$string["local_webhooksdescription"] = ""; +$string["pluginname"] = "Moodle WebHooks"; \ No newline at end of file -- cgit v1.2.3 From 706b948be01d11e30675aabe7b2b6d62fb3434b6 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 22 Oct 2017 14:10:07 +0400 Subject: Manager page template --- lang/en/local_webhooks.php | 5 +++- lang/ru/local_webhooks.php | 5 +++- managerservice.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 managerservice.php (limited to 'lang/en/local_webhooks.php') diff --git a/lang/en/local_webhooks.php b/lang/en/local_webhooks.php index b230a69..d2f33bd 100644 --- a/lang/en/local_webhooks.php +++ b/lang/en/local_webhooks.php @@ -26,4 +26,7 @@ $string["enableservice"] = "Enabled"; $string["enableservice_help"] = "Enable the Event Tracking service."; $string["linkmanagerservice"] = "Service management manager"; $string["local_webhooksdescription"] = ""; -$string["pluginname"] = "Moodle WebHooks"; \ No newline at end of file +$string["managementmanager"] = "Service Management Manager"; +$string["managementmanageradd"] = "Add a service"; +$string["pluginname"] = "Moodle WebHooks"; +$string["servicedeleted"] = "Service has been removed"; \ No newline at end of file diff --git a/lang/ru/local_webhooks.php b/lang/ru/local_webhooks.php index 8a2807a..2c8f0b7 100644 --- a/lang/ru/local_webhooks.php +++ b/lang/ru/local_webhooks.php @@ -26,4 +26,7 @@ $string["enableservice"] = "Включить"; $string["enableservice_help"] = "Включение службы отслеживания событий."; $string["linkmanagerservice"] = "Менеджер управления службами"; $string["local_webhooksdescription"] = ""; -$string["pluginname"] = "Moodle WebHooks"; \ No newline at end of file +$string["managementmanager"] = "Менеджер управления службами"; +$string["managementmanageradd"] = "Добавить службу"; +$string["pluginname"] = "Moodle WebHooks"; +$string["servicedeleted"] = "Служба была удалена"; \ No newline at end of file diff --git a/managerservice.php b/managerservice.php new file mode 100644 index 0000000..7f71a3a --- /dev/null +++ b/managerservice.php @@ -0,0 +1,64 @@ +. + +/** + * Service Management Manager. + * + * @package local_webhooks + * @copyright 2017 "Valentin Popov" + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +require_once(__DIR__ . "/../../config.php"); +$deleteservice = optional_param("deleteservice", 0, PARAM_INT); + +require_login(); +$baseurl = new moodle_url("/local/webhooks/managerservice.php"); +$PAGE->set_url($baseurl); + +$context = context_system::instance(); +$PAGE->set_context($context); + +/* Delete the service */ +if ($deleteservice && confirm_sesskey()) { + $DB->delete_records("local_webhooks_service", array("id" => $deleterssid)); + redirect($PAGE->url, new lang_string("servicedeleted", "local_webhooks")); +} + +/* Retrieving a list of services */ +$select = null; +$callbacks = $DB->get_records_select("local_webhooks_service", $select, null, $DB->sql_order_by_text("title")); + +/* Page template */ +$titlepage = new lang_string("managementmanager", "local_webhooks"); +$PAGE->set_pagelayout("standard"); +$PAGE->set_title($titlepage); +$PAGE->set_heading($titlepage); + +/* The page title */ +$PAGE->navbar->add(new lang_string("local")); +$PAGE->navbar->add(new lang_string("pluginname", "local_webhooks")); +$PAGE->navbar->add($titlepage, $baseurl); +echo $OUTPUT->header(); + +/* @todo: Place the formation table */ + +/* Add service button */ +$addurl = new moodle_url("/local/webhooks/editservice.php"); +$addurltext = new lang_string("managementmanageradd", "local_webhooks"); +echo "
" . $OUTPUT->single_button($addurl, $addurltext, "get") . "
"; + +echo $OUTPUT->footer(); \ No newline at end of file -- cgit v1.2.3 From 54b20f13354b74dd7266645069961a5d8e215ee9 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 22 Oct 2017 16:45:08 +0400 Subject: Adding a title --- lang/en/local_webhooks.php | 1 + lang/ru/local_webhooks.php | 1 + settings.php | 7 +++++++ 3 files changed, 9 insertions(+) (limited to 'lang/en/local_webhooks.php') diff --git a/lang/en/local_webhooks.php b/lang/en/local_webhooks.php index d2f33bd..9a3993a 100644 --- a/lang/en/local_webhooks.php +++ b/lang/en/local_webhooks.php @@ -28,5 +28,6 @@ $string["linkmanagerservice"] = "Service management manager"; $string["local_webhooksdescription"] = ""; $string["managementmanager"] = "Service Management Manager"; $string["managementmanageradd"] = "Add a service"; +$string["managementmanagerdescription"] = ""; $string["pluginname"] = "Moodle WebHooks"; $string["servicedeleted"] = "Service has been removed"; \ No newline at end of file diff --git a/lang/ru/local_webhooks.php b/lang/ru/local_webhooks.php index 2c8f0b7..30a5843 100644 --- a/lang/ru/local_webhooks.php +++ b/lang/ru/local_webhooks.php @@ -28,5 +28,6 @@ $string["linkmanagerservice"] = "Менеджер управления служ $string["local_webhooksdescription"] = ""; $string["managementmanager"] = "Менеджер управления службами"; $string["managementmanageradd"] = "Добавить службу"; +$string["managementmanagerdescription"] = ""; $string["pluginname"] = "Moodle WebHooks"; $string["servicedeleted"] = "Служба была удалена"; \ No newline at end of file diff --git a/settings.php b/settings.php index ceb603a..d893b98 100644 --- a/settings.php +++ b/settings.php @@ -40,6 +40,13 @@ if ($hassiteconfig) { false )); + /* Title Manager */ + $settings->add(new admin_setting_heading( + "defaultsettings", + new lang_string("linkmanagerservice", "local_webhooks"), + new lang_string("managementmanagerdescription", "local_webhooks") + )); + /* Link to the service manager */ $linktext = new lang_string("linkmanagerservice", "local_webhooks"); $link = "wwwroot . "/local/webhooks/managerservice.php\">" . $linktext . ""; -- cgit v1.2.3 From b6659da190d3885f9bfba4b4620da87611a28480 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sun, 22 Oct 2017 18:50:30 +0400 Subject: Added page template editor --- editservice.php | 69 ++++++++++++++++++++++++++++++++++++++++++++++ lang/en/local_webhooks.php | 2 ++ lang/ru/local_webhooks.php | 2 ++ 3 files changed, 73 insertions(+) create mode 100644 editservice.php (limited to 'lang/en/local_webhooks.php') diff --git a/editservice.php b/editservice.php new file mode 100644 index 0000000..a8bda17 --- /dev/null +++ b/editservice.php @@ -0,0 +1,69 @@ +. + +/** + * Service editor. + * + * @package local_webhooks + * @copyright 2017 "Valentin Popov" + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +require_once(__DIR__ . "/../../config.php"); +require_once(__DIR__ . "/classes/form.php"); + +$idservice = optional_param("idservice", 0, PARAM_INT); + +require_login(); + +$managerservice = new moodle_url("/local/webhooks/managerservice.php"); +$baseurl = new moodle_url("/local/webhooks/editservice.php"); +$PAGE->set_url($baseurl); + +$context = context_system::instance(); +$PAGE->set_context($context); + +/* Preparing a template for data */ +$titlepage = new lang_string("editserviceadds", "local_webhooks"); +$servicerecord = new stdClass; + +if (boolval($idservice)) { + $titlepage = new lang_string("editserviceedits", "local_webhooks"); + $servicerecord = $DB->get_record( + "local_webhooks_service", + array("id" => $idservice), + "*", MUST_EXIST); +} + +/* Page template */ +$PAGE->set_pagelayout("admin"); +$PAGE->set_title($titlepage); +$PAGE->set_heading($titlepage); + +/* Create an editing form */ +$mform = new \local_webhooks\service_edit_form(); + +/* The page title */ +$PAGE->navbar->add(new lang_string("local")); +$PAGE->navbar->add(new lang_string("pluginname", "local_webhooks")); +$PAGE->navbar->add(new lang_string("managementmanager", "local_webhooks"), $managerservice); +$PAGE->navbar->add($titlepage); +echo $OUTPUT->header(); + +/* Displays the form */ +$mform->display(); + +echo $OUTPUT->footer(); \ No newline at end of file diff --git a/lang/en/local_webhooks.php b/lang/en/local_webhooks.php index 9a3993a..81b7a10 100644 --- a/lang/en/local_webhooks.php +++ b/lang/en/local_webhooks.php @@ -22,6 +22,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +$string["editserviceadds"] = "Create a service"; +$string["editserviceedits"] = "Edit the service"; $string["enableservice"] = "Enabled"; $string["enableservice_help"] = "Enable the Event Tracking service."; $string["linkmanagerservice"] = "Service management manager"; diff --git a/lang/ru/local_webhooks.php b/lang/ru/local_webhooks.php index 30a5843..390d14a 100644 --- a/lang/ru/local_webhooks.php +++ b/lang/ru/local_webhooks.php @@ -22,6 +22,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +$string["editserviceadds"] = "Создание службы"; +$string["editserviceedits"] = "Редактирование службы"; $string["enableservice"] = "Включить"; $string["enableservice_help"] = "Включение службы отслеживания событий."; $string["linkmanagerservice"] = "Менеджер управления службами"; -- cgit v1.2.3 From ea1c9f7322202a10ab13526cb9734917ac323a00 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 23 Oct 2017 08:31:09 +0400 Subject: Added a class to work with the form --- classes/forms.php | 81 ++++++++++++++++++++++++++++++++++++++++++++++ lang/en/local_webhooks.php | 4 +++ lang/ru/local_webhooks.php | 4 +++ 3 files changed, 89 insertions(+) create mode 100644 classes/forms.php (limited to 'lang/en/local_webhooks.php') diff --git a/classes/forms.php b/classes/forms.php new file mode 100644 index 0000000..e3c962f --- /dev/null +++ b/classes/forms.php @@ -0,0 +1,81 @@ +. + +/** + * 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 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); + } + + /** + * Defines the standard structure of the form. + */ + protected function definition() { + $mform =& $this->_form; + + /* Form heading */ + $mform->addElement("header", "editserviceheader", + new lang_string("editserviceheader", "local_webhooks")); + + /* Name of the service */ + $mform->addElement("text", "title", + new lang_string("editservicetitle", "local_webhooks"), + array("size" => 60)); + $mform->setType("title", PARAM_NOTAGS); + $mform->addRule("title", null, "required"); + + /* Callback address */ + $mform->addElement("text", "url", + new lang_string("editserviceurl", "local_webhooks"), + array("size" => 60)); + $mform->setType("url", PARAM_URL); + $mform->addRule("url", null, "required"); + + /* Enabling the service */ + $mform->addElement("checkbox", "enable", + new lang_string("editserviceenable", "local_webhooks")); + $mform->setType("enable", PARAM_BOOL); + $mform->setDefault("enable", 1); + $mform->setAdvanced("enable"); + + /* Control Panel */ + $this->add_action_buttons(true); + } +} \ No newline at end of file diff --git a/lang/en/local_webhooks.php b/lang/en/local_webhooks.php index 81b7a10..a5dd0d2 100644 --- a/lang/en/local_webhooks.php +++ b/lang/en/local_webhooks.php @@ -24,6 +24,10 @@ $string["editserviceadds"] = "Create a service"; $string["editserviceedits"] = "Edit the service"; +$string["editserviceenable"] = "Activate the service"; +$string["editserviceheader"] = "Service"; +$string["editservicetitle"] = "Name of the service"; +$string["editserviceurl"] = "URL of the service"; $string["enableservice"] = "Enabled"; $string["enableservice_help"] = "Enable the Event Tracking service."; $string["linkmanagerservice"] = "Service management manager"; diff --git a/lang/ru/local_webhooks.php b/lang/ru/local_webhooks.php index 390d14a..0cd9c5f 100644 --- a/lang/ru/local_webhooks.php +++ b/lang/ru/local_webhooks.php @@ -24,6 +24,10 @@ $string["editserviceadds"] = "Создание службы"; $string["editserviceedits"] = "Редактирование службы"; +$string["editserviceenable"] = "Активировать службу"; +$string["editserviceheader"] = "Служба"; +$string["editservicetitle"] = "Название службы"; +$string["editserviceurl"] = "URL-адрес службы"; $string["enableservice"] = "Включить"; $string["enableservice_help"] = "Включение службы отслеживания событий."; $string["linkmanagerservice"] = "Менеджер управления службами"; -- cgit v1.2.3 From 876803b844b66fb766ee0e7350a49c2bf323ce19 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 24 Oct 2017 04:02:30 +0400 Subject: Rethinking the translation --- lang/en/local_webhooks.php | 17 ++--------------- lang/ru/local_webhooks.php | 17 ++--------------- 2 files changed, 4 insertions(+), 30 deletions(-) (limited to 'lang/en/local_webhooks.php') diff --git a/lang/en/local_webhooks.php b/lang/en/local_webhooks.php index a5dd0d2..041233f 100644 --- a/lang/en/local_webhooks.php +++ b/lang/en/local_webhooks.php @@ -22,18 +22,5 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string["editserviceadds"] = "Create a service"; -$string["editserviceedits"] = "Edit the service"; -$string["editserviceenable"] = "Activate the service"; -$string["editserviceheader"] = "Service"; -$string["editservicetitle"] = "Name of the service"; -$string["editserviceurl"] = "URL of the service"; -$string["enableservice"] = "Enabled"; -$string["enableservice_help"] = "Enable the Event Tracking service."; -$string["linkmanagerservice"] = "Service management manager"; -$string["local_webhooksdescription"] = ""; -$string["managementmanager"] = "Service Management Manager"; -$string["managementmanageradd"] = "Add a service"; -$string["managementmanagerdescription"] = ""; -$string["pluginname"] = "Moodle WebHooks"; -$string["servicedeleted"] = "Service has been removed"; \ No newline at end of file +$string["managerservice"] = "Service management manager"; +$string["pluginname"] = "WebHooks"; \ No newline at end of file diff --git a/lang/ru/local_webhooks.php b/lang/ru/local_webhooks.php index 0cd9c5f..73db595 100644 --- a/lang/ru/local_webhooks.php +++ b/lang/ru/local_webhooks.php @@ -22,18 +22,5 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string["editserviceadds"] = "Создание службы"; -$string["editserviceedits"] = "Редактирование службы"; -$string["editserviceenable"] = "Активировать службу"; -$string["editserviceheader"] = "Служба"; -$string["editservicetitle"] = "Название службы"; -$string["editserviceurl"] = "URL-адрес службы"; -$string["enableservice"] = "Включить"; -$string["enableservice_help"] = "Включение службы отслеживания событий."; -$string["linkmanagerservice"] = "Менеджер управления службами"; -$string["local_webhooksdescription"] = ""; -$string["managementmanager"] = "Менеджер управления службами"; -$string["managementmanageradd"] = "Добавить службу"; -$string["managementmanagerdescription"] = ""; -$string["pluginname"] = "Moodle WebHooks"; -$string["servicedeleted"] = "Служба была удалена"; \ No newline at end of file +$string["managerservice"] = "Менеджер управления службами"; +$string["pluginname"] = "WebHooks"; \ No newline at end of file -- cgit v1.2.3