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
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"version": "1.3.1",
"version": "2.0.0",
"name": "WebhooksPlugin.name",
"description": "WebhooksPlugin.description",
"icon": "bi bi-plug-fill",
"authors": [
{
"name": "Phillips Data, Inc.",
Expand Down
186 changes: 94 additions & 92 deletions views/default/admin_main.pdt
Original file line number Diff line number Diff line change
@@ -1,106 +1,108 @@
<?php
echo ($message ?? null);
<?php
echo ($message ?? null);

$links = [
['name' => $this->_('AdminMain.index.category_outgoing', true) . ' <span>(' . (isset($type_count['outgoing']) ? $this->Html->safe($type_count['outgoing']) : null) . ')</span>', 'current' => ((isset($type) ? $type : null) == 'outgoing' ? true : false), 'attributes' => ['href' => $this->base_uri . 'plugin/webhooks/admin_main/index/outgoing/', 'class' => 'ajax']],
['name' => $this->_('AdminMain.index.category_incoming', true) . ' <span>(' . (isset($type_count['incoming']) ? $this->Html->safe($type_count['incoming']) : null) . ')</span>', 'current' => ((isset($type) ? $type : null) == 'incoming' ? true : false), 'attributes' => ['href' => $this->base_uri . 'plugin/webhooks/admin_main/index/incoming/', 'class' => 'ajax']]
];
$link_buttons = [
[
'icon' => 'fas fa-plus',
'name' => '',
'attributes' => [
'title' => $this->_('AdminMain.index.categorylink_addwebhook', true),
'href' => $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/add/')
]
],
[
'icon' => 'fas fa-list',
'name' => $this->_('AdminMain.index.categorylink_viewlogs', true),
'attributes' => [
'title' => $this->_('AdminMain.index.categorylink_viewlogs', true),
'href' => $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/logs/')
]
]
];
$links = [
[
'name' => $this->_('AdminMain.index.category_outgoing', true) . '<span class="badge bg-secondary ms-2">' . ($type_count['outgoing'] ?? 0) . '</span>',
'current' => ($type ?? null) == 'outgoing',
'attributes' => ['href' => $this->base_uri . 'plugin/webhooks/admin_main/index/outgoing/', 'class' => 'ajax']
],
[
'name' => $this->_('AdminMain.index.category_incoming', true) . '<span class="badge bg-secondary ms-2">' . ($type_count['incoming'] ?? 0) . '</span>',
'current' => ($type ?? null) == 'incoming',
'attributes' => ['href' => $this->base_uri . 'plugin/webhooks/admin_main/index/incoming/', 'class' => 'ajax']
]
];
$link_buttons = [
[
'icon' => 'bi bi-plus-lg me-1',
'name' => $this->_('AdminMain.index.categorylink_addwebhook', true),
'attributes' => [
'title' => $this->_('AdminMain.index.categorylink_addwebhook', true),
'href' => $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/add/')
]
],
[
'icon' => 'bi bi-list me-1',
'name' => $this->_('AdminMain.index.categorylink_viewlogs', true),
'attributes' => [
'title' => $this->_('AdminMain.index.categorylink_viewlogs', true),
'href' => $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/logs/')
]
]
];

$this->Widget->clear();
$this->Widget->setLinks($links);
$this->Widget->setLinkButtons($link_buttons);
$this->Widget->create($this->_('AdminMain.index.boxtitle_webhooks', true), ['id' => 'admin_main'], ($render_section ?? null));
$this->Widget->clear();
$this->Widget->setLinks($links);
$this->Widget->setLinkButtons($link_buttons);
$this->Widget->setBodyWrapper(false);
$this->Widget->create($this->_('AdminMain.index.boxtitle_webhooks', true), ['id' => 'admin_main'], ($render_section ?? null));

if (($webhooks ?? false) && ($num_tickets = count($webhooks)) > 0) {
if (($webhooks ?? false) && ($num_tickets = count($webhooks)) > 0) {
?>
<table class="table table-hover" id="webhook_list">
<thead>
<tr>
<th><?php $this->_('AdminMain.index.heading_callback');?></th>
<th><a href="<?php echo $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/index/' . (isset($type) ? $type : null) . '/?sort=event&order=' . ($sort == 'event' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'event' ? ' ' . $order : '');?>"><?php $this->_('AdminMain.index.heading_event');?></a></th>
<th><a href="<?php echo $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/index/' . (isset($type) ? $type : null) . '/?sort=method&order=' . ($sort == 'method' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'method' ? ' ' . $order : '');?>"><?php $this->_('AdminMain.index.heading_method');?></a></th>
<th><?php $this->_('AdminMain.index.heading_options');?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($webhooks as $webhook) {
?>
<p class="p-2 rounded bg-light text-dark"><?php $this->_('AdminMain.index.text_description_' . ($type ?? 'outgoing'));?></p>
<table class="table" id="webhook_list">
<tr class="heading_row">
<td><?php $this->_('AdminMain.index.heading_callback');?></td>
<td><span><a href="<?php echo $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/index/' . (isset($type) ? $type : null) . '/?sort=event&order=' . ($sort == 'event' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'event' ? ' ' . $order : '');?>"><?php $this->_('AdminMain.index.heading_event');?></a></span></td>
<td><span><a href="<?php echo $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/index/' . (isset($type) ? $type : null) . '/?sort=method&order=' . ($sort == 'method' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'method' ? ' ' . $order : '');?>"><?php $this->_('AdminMain.index.heading_method');?></a></span></td>
<td class="last"><?php $this->_('AdminMain.index.heading_options');?></td>
</tr>
<?php
// Display all webhooks
$i = 0;
foreach ($webhooks as $webhook) {
?>
<tr<?php echo (($i++%2 == 1) ? ' class="odd_row"' : '');?>>
<td>
<?php
if ($type == 'incoming') {
echo $this->Html->safe('http://' . Configure::get('Blesta.company')->hostname . $this->base_uri . 'plugin/webhooks/trigger/index/' . ($webhook->callback ?? ''));
} else {
echo $this->Html->safe($webhook->callback ?? '');
}
?>
</td>
<td>
<?php
foreach ($webhook->events ?? [] as $event) {
?>
<div class="badge badge-light"><?php echo $this->Html->safe($event);?></div>
<tr>
<td>
<?php
if ($type == 'incoming') {
echo $this->Html->safe('http://' . Configure::get('Blesta.company')->hostname . $this->base_uri . 'plugin/webhooks/trigger/index/' . ($webhook->callback ?? ''));
} else {
echo $this->Html->safe($webhook->callback ?? '');
}
?>
</td>
<td>
<?php
foreach ($webhook->events ?? [] as $event) {
?>
<span class="badge bg-secondary"><?php echo $this->Html->safe($event);?></span>
<?php
}
?>
</td>
<td><?php echo $this->Html->safe(strtoupper($webhook->method ?? ''));?></td>
<td>
<div class="d-flex gap-1">
<a href="<?php echo $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/logs/?filters[webhook_id]=' . $webhook->id);?>" class="btn btn-sm btn-outline-secondary"><?php $this->_('AdminMain.index.option_logs');?></a>
<a href="<?php echo $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/edit/' . $webhook->id);?>" class="btn btn-sm btn-outline-secondary"><?php $this->_('AdminMain.index.option_edit');?></a>
<?php
}
?>
</td>
<td><?php echo $this->Html->safe(strtoupper($webhook->method ?? ''));?></td>
<td class="last">
<a href="<?php echo $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/logs/?filters[webhook_id]=' . $webhook->id);?>"><?php $this->_('AdminMain.index.option_logs');?></a>,
<a href="<?php echo $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/edit/' . $webhook->id);?>"><?php $this->_('AdminMain.index.option_edit');?></a>,
<?php
$this->Form->create($this->base_uri . 'plugin/webhooks/admin_main/delete/');
$this->Form->create($this->base_uri . 'plugin/webhooks/admin_main/delete/', ['class' => 'd-inline']);
$this->Form->fieldHidden('id', ($webhook->id ?? null));
?>
<a href="<?php echo $this->Html->safe($this->base_uri . 'plugin/webhooks/admin_main/delete/');?>" class="manage" rel="<?php $this->_('AdminMain.modal.delete_text');?>"><?php $this->_('AdminMain.index.option_delete');?></a>
<button type="button" class="btn btn-sm btn-outline-danger modal-confirm-delete" data-confirm-message="<?php $this->_('AdminMain.modal.delete_text');?>"><?php $this->_('AdminMain.index.option_delete');?></button>
<?php
$this->Form->end();
?>
</td>
</tr>
<?php
}
unset($i);
?>
</table>
<?php
// Set pagination
$this->Pagination->build();
} else {
?>
<div class="empty_section">
<div class="empty_box">
<?php $this->_('AdminMain.index.no_results');?>
</div>
</div>
</div>
</td>
</tr>
<?php
}

$this->Widget->end();
?>
</tbody>
</table>
<?php
$this->Pagination->build();
} else {
?>
<div class="card-body text-center text-muted py-5">
<i class="bi bi-plug-fill" style="font-size: 3rem; opacity: 0.3;"></i>
<p class="mt-3 mb-0"><?php $this->_('AdminMain.index.no_results');?></p>
</div>
<?php
}

<script type="text/javascript">
$(document).ready(function() {
// Handle confirmation
$('#admin_main a.manage[rel]').blestaModalConfirm({base_url: '<?php echo (isset($this->base_uri) ? $this->Html->safe($this->base_uri) : null);?>', close: '<?php $this->_('AppController.modal.text_close');?>', submit: true});
});
</script>
$this->Widget->end();
?>
Loading