aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2017-12-19 13:50:30 +0300
committerValentin Popov <info@valentineus.link>2017-12-19 13:50:30 +0300
commit97711bb1863bd8a2cbe3a258e4a5c676598302b1 (patch)
tree8db71029f827197fe22a3745e08cd5557eaf1f28
parent999ad9f47277e7c032df2bfd0bdddff81704f496 (diff)
downloadlocal_webhooks-97711bb1863bd8a2cbe3a258e4a5c676598302b1.tar.xz
local_webhooks-97711bb1863bd8a2cbe3a258e4a5c676598302b1.zip
Added function to change the status of the service
-rw-r--r--lib.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib.php b/lib.php
index a63d8a4..5817ef8 100644
--- a/lib.php
+++ b/lib.php
@@ -27,6 +27,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.
*
* @param number $limitfrom