Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions application/controllers/General_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function index(): void
'terms_and_conditions_content',
'display_privacy_policy',
'privacy_policy_content',
'webhooks_enabled',
];

/**
Expand Down
2 changes: 2 additions & 0 deletions application/language/english/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@
$lang['admin_delete'] = 'Admin Delete';
$lang['options'] = 'Options';
$lang['webhooks'] = 'Webhooks';
$lang['webhooks_enabled'] = 'Enable Webhooks';
$lang['webhooks_enabled_hint'] = 'Turn this off to temporarily stop all webhooks from firing.';
$lang['webhooks_info'] = 'Webhooks enable you to send HTTP notifications to external web applications in response to various application events, such as the creation of an appointment or the removal of a customer.';
$lang['integrations_info'] = 'Integrations enable you to make third-party connections with external applications and APIs.';
$lang['configure'] = 'Configure';
Expand Down
5 changes: 5 additions & 0 deletions application/libraries/Webhooks_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public function __construct()
*/
public function trigger(string $action, array $payload)
{
// Global kill-switch: when webhooks are disabled in the general settings, skip all dispatching.
if (!setting('webhooks_enabled', '1')) {
return;
}

$webhooks = $this->CI->webhooks_model->get();

foreach ($webhooks as $webhook) {
Expand Down
39 changes: 39 additions & 0 deletions application/migrations/070_add_webhooks_enabled_setting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.5.0
* ---------------------------------------------------------------------------- */

/**
* Migration: Add webhooks enabled setting.
*
* Adds a global on/off switch for webhook dispatching. Enabled by default to keep the current behavior.
*/
class Migration_Add_webhooks_enabled_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
$this->db->insert('settings', [
'name' => 'webhooks_enabled',
'value' => '1',
]);
}

/**
* Downgrade method.
*/
public function down(): void
{
$this->db->delete('settings', ['name' => 'webhooks_enabled']);
}
}
20 changes: 20 additions & 0 deletions application/views/pages/general_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,26 @@ class="form-control">
</div>
</div>

<div class="row mb-5">
<div class="col-12">
<h5 class="mb-3 fw-light"><?= lang('webhooks') ?></h5>

<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox"
id="webhooks-enabled" data-field="webhooks_enabled">
<label class="form-check-label" for="webhooks-enabled">
<?= lang('webhooks_enabled') ?>
</label>
</div>

<div class="form-text text-muted">
<small>
<?= lang('webhooks_enabled_hint') ?>
</small>
</div>
</div>
</div>

</fieldset>
</form>
</div>
Expand Down