From 41a6a89ac8c32d5b219ce19b2973406a3e193a98 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 20 Mar 2018 04:13:47 +0400 Subject: Updated the status change function Signed-off-by: Valentin Popov --- lib.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib.php b/lib.php index 68750bd..e8687bd 100644 --- a/lib.php +++ b/lib.php @@ -32,15 +32,21 @@ require_once(__DIR__ . "/locallib.php"); /** * Change the status of the service. * - * @param number $serviceid - * @return boolean + * @param number $serviceid Service identifier + * @return boolean The result of the operation */ function local_webhooks_change_status($serviceid) { global $DB; + /* Gets the current status */ $status = $DB->get_field(LOCAL_WEBHOOKS_TABLE_SERVICES, "status", array("id" => $serviceid), IGNORE_MISSING); + + /* Changes the status to the opposite */ $result = $DB->set_field(LOCAL_WEBHOOKS_TABLE_SERVICES, "status", !boolval($status), array("id" => $serviceid)); + /* Clears the cache */ + local_webhooks_cache_reset(); + return $result; } -- cgit v1.2.3