Update function 'local_webhooks_create_record'
Signed-off-by: Valentin Popov <info@valentineus.link>
This commit is contained in:
parent
639276c33d
commit
57a870f56f
18
lib.php
18
lib.php
@ -144,20 +144,14 @@ function local_webhooks_get_total_count() {
|
|||||||
function local_webhooks_create_record($record) {
|
function local_webhooks_create_record($record) {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
|
if (empty($record->events)) {
|
||||||
|
$record->events = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Adding entries */
|
||||||
$transaction = $DB->start_delegated_transaction();
|
$transaction = $DB->start_delegated_transaction();
|
||||||
$serviceid = $DB->insert_record(LOCAL_WEBHOOKS_TABLE_SERVICES, $record, true, false);
|
$serviceid = $DB->insert_record(LOCAL_WEBHOOKS_TABLE_SERVICES, $record, true, false);
|
||||||
|
local_webhooks_insert_events($serviceid, $record->events);
|
||||||
if (!empty($record->events)) {
|
|
||||||
foreach ($record->events as $eventname => $eventstatus) {
|
|
||||||
$event = new stdClass();
|
|
||||||
$event->name = $eventname;
|
|
||||||
$event->serviceid = $serviceid;
|
|
||||||
$event->status = $record->status;
|
|
||||||
|
|
||||||
$DB->insert_record(LOCAL_WEBHOOKS_TABLE_EVENTS, $event, false, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$transaction->allow_commit();
|
$transaction->allow_commit();
|
||||||
|
|
||||||
/* Clear the plugin cache */
|
/* Clear the plugin cache */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user