aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2018-03-20 03:13:47 +0300
committerValentin Popov <info@valentineus.link>2018-03-20 03:13:47 +0300
commit41a6a89ac8c32d5b219ce19b2973406a3e193a98 (patch)
tree41354c72099448f6ab84dce1dc076e937d095d07
parent279fca5ed18cdbd12df0957c62f2657e72e34f4e (diff)
downloadlocal_webhooks-41a6a89ac8c32d5b219ce19b2973406a3e193a98.tar.xz
local_webhooks-41a6a89ac8c32d5b219ce19b2973406a3e193a98.zip
Updated the status change function
Signed-off-by: Valentin Popov <info@valentineus.link>
-rw-r--r--lib.php10
1 files 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;
}