diff options
-rw-r--r-- | editservice.php | 4 | ||||
-rw-r--r-- | index.php (renamed from managerservice.php) | 29 | ||||
-rw-r--r-- | settings.php | 2 |
3 files changed, 11 insertions, 24 deletions
diff --git a/editservice.php b/editservice.php index 0a8aec5..2e43e33 100644 --- a/editservice.php +++ b/editservice.php @@ -33,15 +33,15 @@ $serviceid = optional_param("serviceid", 0, PARAM_INT); /* Link generation */ $urlparameters = array("serviceid" => $serviceid); -$managerservice = new moodle_url("/local/webhooks/managerservice.php", $urlparameters); $baseurl = new moodle_url("/local/webhooks/editservice.php", $urlparameters); +$managerservice = new moodle_url("/local/webhooks/index.php", $urlparameters); /* Configure the context of the page */ admin_externalpage_setup("local_webhooks", "", null, $baseurl, array()); $context = context_system::instance(); /* Create an editing form */ -$mform = new local_webhooks\service_edit_form($PAGE->url); +$mform = new service_edit_form($PAGE->url); /* Cancel processing */ if ($mform->is_cancelled()) { diff --git a/managerservice.php b/index.php index a27db1d..6d0ef10 100644 --- a/managerservice.php +++ b/index.php @@ -23,8 +23,10 @@ */ require_once(__DIR__ . "/../../config.php"); -require_once($CFG->libdir . "/tablelib.php"); +require_once(__DIR__ . "/lib.php"); + require_once($CFG->libdir . "/adminlib.php"); +require_once($CFG->libdir . "/tablelib.php"); /* Optional parameters */ $backupservices = optional_param("getbackup", 0, PARAM_BOOL); @@ -33,7 +35,7 @@ $hideshowid = optional_param("hideshowid", 0, PARAM_INT); /* Link generation */ $editservice = "/local/webhooks/editservice.php"; -$managerservice = "/local/webhooks/managerservice.php"; +$managerservice = "/local/webhooks/index.php"; $restorebackup = "/local/webhooks/restorebackup.php"; $baseurl = new moodle_url($managerservice); @@ -43,27 +45,17 @@ $context = context_system::instance(); /* Delete the service */ if (boolval($deleteid)) { - $DB->delete_records("local_webhooks_service", array("id" => $deleteid)); - - /* Run the event */ - $event = \local_webhooks\event\service_deleted::create(array("context" => $context, "objectid" => $deleteid)); - $event->trigger(); - + local_webhooks_remove_record($deleteid); redirect($PAGE->url, new lang_string("eventwebserviceservicedeleted", "webservice")); } /* Retrieving a list of services */ -$callbacks = $DB->get_records_select("local_webhooks_service", null, null, $DB->sql_order_by_text("id")); +$callbacks = local_webhooks_list_records(); /* Upload settings as a file */ if (boolval($backupservices)) { - $filecontent = base64_encode(gzcompress(serialize($callbacks), 9)); + $filecontent = local_webhooks_archiving_data($callbacks); $filename = "webhooks_" . date("U") . ".backup"; - - /* Run the event */ - $event = \local_webhooks\event\backup_performed::create(array("context" => $context, "objectid" => 0)); - $event->trigger(); - send_file($filecontent, $filename, 0, 0, true, true); } @@ -73,12 +65,7 @@ if (boolval($hideshowid)) { if (!empty($callback)) { $callback->enable = !boolval($callback->enable); - $DB->update_record("local_webhooks_service", $callback); - - /* Run the event */ - $event = \local_webhooks\event\service_updated::create(array("context" => $context, "objectid" => $hideshowid)); - $event->trigger(); - + local_webhooks_update_record($callback, false); redirect($PAGE->url, new lang_string("eventwebserviceserviceupdated", "webservice")); } } diff --git a/settings.php b/settings.php index b36c594..25e5ffd 100644 --- a/settings.php +++ b/settings.php @@ -27,6 +27,6 @@ defined("MOODLE_INTERNAL") || die(); if ($hassiteconfig) { $ADMIN->add("server", new admin_externalpage("local_webhooks", new lang_string("pluginname", "local_webhooks"), - new moodle_url("/local/webhooks/managerservice.php") + new moodle_url("/local/webhooks/index.php") )); }
\ No newline at end of file |