From bf2cef3ea035f4487e4b41e3033c60b1f1f0ead3 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Nov 2017 05:41:28 +0400 Subject: Recovery algorithm --- restorebackup.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'restorebackup.php') diff --git a/restorebackup.php b/restorebackup.php index 82d8a38..ee6f48a 100644 --- a/restorebackup.php +++ b/restorebackup.php @@ -27,7 +27,6 @@ require_once(__DIR__ . "/classes/editform.php"); require_once($CFG->libdir . "/adminlib.php"); admin_externalpage_setup("pluginsoverview"); - require_login(); /* Link generation */ @@ -47,6 +46,20 @@ if ($mform->is_cancelled()) { redirect($managerservice); } +/* Processing the received file */ +$data = $mform->get_data(); +if (boolval($data) && confirm_sesskey()) { + $content = $mform->get_file_content("backupfile"); + $callbacks = unserialize(gzuncompress(base64_decode($content))); + + $DB->delete_records("local_webhooks_service"); + foreach ($callbacks as $callback) { + $DB->insert_record("local_webhooks_service", $callback); + } + + redirect($managerservice, new lang_string("restorefinished", "moodle")); +} + /* Page template */ $titlepage = new lang_string("backup", "moodle"); $PAGE->set_pagelayout("admin"); -- cgit v1.2.3