From fdaa591882e4df99696e6e90bb6f89f8cdc14e57 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Oct 2017 17:25:30 +0400 Subject: Refactoring the editor code --- editservice.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'editservice.php') 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 */ -- cgit v1.2.3