From 97711bb1863bd8a2cbe3a258e4a5c676598302b1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 19 Dec 2017 14:50:30 +0400 Subject: Added function to change the status of the service --- lib.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib.php') diff --git a/lib.php b/lib.php index a63d8a4..5817ef8 100644 --- a/lib.php +++ b/lib.php @@ -26,6 +26,25 @@ defined("MOODLE_INTERNAL") || die(); require_once(__DIR__ . "/locallib.php"); +/** + * Change the status of the service. + * + * @param number $serviceid + * @return boolean + */ +function local_webhooks_change_status($serviceid) { + global $DB; + + $result = false; + $conditions = array("id" => $serviceid); + if ($DB->record_exists("local_webhooks_service", $conditions)) { + $enabled = $DB->get_field("local_webhooks_service", "enable", $conditions, IGNORE_MISSING); + $result = $DB->set_field("local_webhooks_service", "enable", !boolval($enabled), $conditions); + } + + return boolval($result); +} + /** * Getting a list of all services. * -- cgit v1.2.3