summaryrefslogtreecommitdiff
path: root/editservice.php
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2017-10-26 16:25:30 +0300
committerValentin Popov <info@valentineus.link>2017-10-26 16:25:30 +0300
commitfdaa591882e4df99696e6e90bb6f89f8cdc14e57 (patch)
tree9e4445daf8d42529d3f38b154c5b4eec5000773a /editservice.php
parent6b5c96a383df673ec1b41c56bdb7cc83e5ecd5c8 (diff)
downloadlocal_webhooks-fdaa591882e4df99696e6e90bb6f89f8cdc14e57.tar.xz
local_webhooks-fdaa591882e4df99696e6e90bb6f89f8cdc14e57.zip
Refactoring the editor code
Diffstat (limited to 'editservice.php')
-rw-r--r--editservice.php17
1 files changed, 8 insertions, 9 deletions
diff --git a/editservice.php b/editservice.php
index e9f2918..958a174 100644
--- a/editservice.php
+++ b/editservice.php
@@ -25,12 +25,12 @@
require_once(__DIR__ . "/../../config.php");
require_once(__DIR__ . "/classes/forms.php");
-$idservice = optional_param("idservice", 0, PARAM_INT);
+$serviceid = optional_param("serviceid", 0, PARAM_INT);
require_login();
/* Link generation */
-$urlparameters = array("idservice" => $idservice);
+$urlparameters = array("serviceid" => $serviceid);
$managerservice = new moodle_url("/local/webhooks/managerservice.php", $urlparameters);
$baseurl = new moodle_url("/local/webhooks/editservice.php", $urlparameters);
$PAGE->set_url($baseurl, $urlparameters);
@@ -52,26 +52,25 @@ if ($mform->is_cancelled()) {
}
/* Getting the data */
-if ($idediting = boolval($idservice)) {
- $servicerecord = $DB->get_record("local_webhooks_service", array("id" => $idservice), "*", MUST_EXIST);
+if ($idediting = boolval($serviceid)) {
+ $servicerecord = $DB->get_record("local_webhooks_service", array("id" => $serviceid), "*", MUST_EXIST);
$mform->set_data($servicerecord);
}
/* Processing of received data */
if ($data = $mform->get_data()) {
- /* Packing of data */
if (!empty($data->events)) {
$data->events = base64_encode(gzcompress(serialize($data->events), 9));
}
- if ($idediting) {
- $data->id = $idservice;
+ if (boolval($idediting)) {
+ $data->id = $serviceid;
$DB->update_record("local_webhooks_service", $data);
+ redirect($managerservice, new lang_string("eventwebserviceserviceupdated", "webservice"));
} else {
$DB->insert_record("local_webhooks_service", $data);
+ redirect($managerservice, new lang_string("eventwebserviceservicecreated", "webservice"));
}
-
- redirect($managerservice);
}
/* Page template */