summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2017-11-18 04:41:28 +0300
committerValentin Popov <info@valentineus.link>2017-11-18 04:41:28 +0300
commitbf2cef3ea035f4487e4b41e3033c60b1f1f0ead3 (patch)
treec743e2ee1406f6ebff7a2bbe06deb1106c95e669
parent7b56375c057d6d7cdbe0948837cbc9d53c7880e9 (diff)
downloadlocal_webhooks-bf2cef3ea035f4487e4b41e3033c60b1f1f0ead3.tar.xz
local_webhooks-bf2cef3ea035f4487e4b41e3033c60b1f1f0ead3.zip
Recovery algorithm
-rw-r--r--restorebackup.php15
1 files changed, 14 insertions, 1 deletions
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");