aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/event/service_deletedall.php4
-rw-r--r--lib.php19
2 files changed, 14 insertions, 9 deletions
diff --git a/classes/event/service_deletedall.php b/classes/event/service_deletedall.php
index 8958cd9..a7eba67 100644
--- a/classes/event/service_deletedall.php
+++ b/classes/event/service_deletedall.php
@@ -46,14 +46,14 @@ class service_deletedall extends \core\event\base {
* Return localised event name.
*/
public static function get_name() {
- return new \lang_string("deleteall", "moodle");
+ return new \lang_string("deleted", "moodle");
}
/**
* Returns description of what happened.
*/
public function get_description() {
- return new \lang_string("eventwebserviceservicedeleted", "webservice");
+ return new \lang_string("deletecompletely", "moodle");
}
/**
diff --git a/lib.php b/lib.php
index 64f2065..f22c61b 100644
--- a/lib.php
+++ b/lib.php
@@ -35,15 +35,13 @@ require_once(__DIR__ . "/locallib.php");
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);
+ $result = false;
+ if ($record = local_webhooks_get_record($serviceid)) {
+ $record->enable = !boolval($record->enable);
+ $result = local_webhooks_update_record($record);
}
- return boolval($result);
+ return $result;
}
/**
@@ -99,6 +97,7 @@ function local_webhooks_create_record($record) {
}
$result = $DB->insert_record("local_webhooks_service", $record, true, false);
+ local_webhooks_events::service_added($result);
return boolval($result);
}
@@ -116,6 +115,7 @@ function local_webhooks_update_record($record) {
}
$result = $DB->update_record("local_webhooks_service", $record, false);
+ local_webhooks_events::service_updated($record->id);
return boolval($result);
}
@@ -128,6 +128,7 @@ function local_webhooks_update_record($record) {
function local_webhooks_delete_record($serviceid) {
global $DB;
$result = $DB->delete_records("local_webhooks_service", array("id" => $serviceid));
+ local_webhooks_events::service_deleted($serviceid);
return boolval($result);
}
@@ -139,6 +140,7 @@ function local_webhooks_delete_record($serviceid) {
function local_webhooks_delete_all_records() {
global $DB;
$result = $DB->delete_records("local_webhooks_service", null);
+ local_webhooks_events::service_deletedall();
return boolval($result);
}
@@ -150,6 +152,7 @@ function local_webhooks_delete_all_records() {
function local_webhooks_create_backup() {
$listrecords = local_webhooks_get_list_records();
$result = local_webhooks_serialization_data($listrecords);
+ local_webhooks_events::backup_performed();
return $result;
}
@@ -168,6 +171,8 @@ function local_webhooks_restore_backup($data, $deleterecords = false) {
foreach ($listrecords as $servicerecord) {
local_webhooks_create_record($servicerecord);
}
+
+ local_webhooks_events::backup_restored();
}
/**