summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2017-11-17 17:24:59 +0300
committerValentin Popov <info@valentineus.link>2017-11-17 17:24:59 +0300
commit688448b350e3137e14e56c30fd5d547884acddbc (patch)
tree1cb7d7010014ec8bca70b28712ebc327c5d6473a
parent35358ea7cc11a80f285cca6dca3e3ec668e0fb97 (diff)
downloadlocal_webhooks-688448b350e3137e14e56c30fd5d547884acddbc.tar.xz
local_webhooks-688448b350e3137e14e56c30fd5d547884acddbc.zip
Added backup function
-rw-r--r--managerservice.php16
1 files changed, 14 insertions, 2 deletions
diff --git a/managerservice.php b/managerservice.php
index 1377e91..6fa2ed3 100644
--- a/managerservice.php
+++ b/managerservice.php
@@ -28,8 +28,9 @@ require_once($CFG->libdir . "/adminlib.php");
admin_externalpage_setup("pluginsoverview");
-$hideshowid = optional_param("hideshowid", 0, PARAM_INT);
+$backupservices = optional_param("backup", 0, PARAM_BOOL);
$deleteid = optional_param("deleteid", 0, PARAM_INT);
+$hideshowid = optional_param("hideshowid", 0, PARAM_INT);
require_login();
@@ -52,6 +53,13 @@ if (boolval($deleteid) && confirm_sesskey()) {
/* Retrieving a list of services */
$callbacks = $DB->get_records_select("local_webhooks_service", null, null, $DB->sql_order_by_text("id"));
+/* Upload settings as a file */
+if (boolval($backupservices)) {
+ $filecontent = serialize($callbacks);
+ $filename = "webhooks_" . date("U") . ".backup";
+ send_file($filecontent, $filename, 0, 0, true, true);
+}
+
/* Switching the status of the service */
if (boolval($hideshowid) && confirm_sesskey()) {
$callback = $callbacks[$hideshowid];
@@ -115,7 +123,11 @@ foreach ($callbacks as $callback) {
$table->print_html();
/* Add service button */
-$addurl = new moodle_url("/local/webhooks/editservice.php");
+$addurl = new moodle_url($editservice);
echo $OUTPUT->single_button($addurl, new lang_string("addaservice", "webservice"), "get");
+/* Button to get a backup */
+$backupurl = new moodle_url($managerservice, array("backup" => true));
+echo $OUTPUT->single_button($backupurl, new lang_string("backup", "moodle"), "get");
+
echo $OUTPUT->footer(); \ No newline at end of file