PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / trunk
VikAppointments Services Booking Calendar vtrunk
trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / views / webhooks / view.html.php
vikappointments / admin / views / webhooks Last commit date
tmpl 4 years ago index.html 4 years ago view.html.php 2 years ago
view.html.php
143 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * VikAppointments web hooks view.
16 *
17 * @since 1.7
18 */
19 class VikAppointmentsViewwebhooks extends JViewVAP
20 {
21 /**
22 * VikAppointments view display method.
23 *
24 * @return void
25 */
26 function display($tpl = null)
27 {
28 $app = JFactory::getApplication();
29 $input = $app->input;
30 $dbo = JFactory::getDbo();
31
32 // set the toolbar
33 $this->addToolBar();
34
35 $filters = array();
36 $filters['keys'] = $app->getUserStateFromRequest($this->getPoolName() . '.keys', 'keys', '', 'string');
37 $filters['status'] = $app->getUserStateFromRequest($this->getPoolName() . '.status', 'status', '', 'string');
38
39 $this->filters = $filters;
40
41 $this->ordering = $app->getUserStateFromRequest($this->getPoolName() . '.ordering', 'filter_order', 'w.id', 'string');
42 $this->orderDir = $app->getUserStateFromRequest($this->getPoolName() . '.orderdir', 'filter_order_Dir', 'DESC', 'string');
43
44 // db object
45 $lim = $app->getUserStateFromRequest('com_vikappointments.limit', 'limit', $app->get('list_limit'), 'uint');
46 $lim0 = $this->getListLimitStart($filters);
47 $navbut = "";
48
49 $rows = array();
50
51 $q = $dbo->getQuery(true);
52
53 $q->select('SQL_CALC_FOUND_ROWS w.*')
54 ->from($dbo->qn('#__vikappointments_webhook', 'w'))
55 ->where(1)
56 ->order($dbo->qn($this->ordering) . ' ' . $this->orderDir);
57
58 if (!empty($filters['keys']))
59 {
60 $q->andWhere(array(
61 $dbo->qn('w.name') . ' LIKE ' . $dbo->q("%{$filters['keys']}%"),
62 $dbo->qn('w.hook') . ' LIKE ' . $dbo->q("%{$filters['keys']}%"),
63 $dbo->qn('w.url') . ' LIKE ' . $dbo->q("%{$filters['keys']}%"),
64 ), 'OR');
65 }
66
67 if (strlen($filters['status']))
68 {
69 $q->where($dbo->qn('w.published') . ' = ' . (int) $filters['status']);
70 }
71
72 /**
73 * Add support for manipulating query through the plugins.
74 *
75 * @see /site/helpers/libraries/mvc/view.php @ JViewVAP::onBeforeListQuery()
76 *
77 * @since 1.7
78 */
79 $this->onBeforeListQuery($q);
80
81 $dbo->setQuery($q, $lim0, $lim);
82 $dbo->execute();
83
84 // assert limit used for list query
85 $this->assertListQuery($lim0, $lim);
86
87 if ($dbo->getNumRows())
88 {
89 $rows = $dbo->loadAssocList();
90 $dbo->setQuery('SELECT FOUND_ROWS();');
91 jimport('joomla.html.pagination');
92 $pageNav = new JPagination($dbo->loadResult(), $lim0, $lim);
93 $navbut = JLayoutHelper::render('blocks.pagination', ['pageNav' => $pageNav]);
94 }
95
96 $this->rows = $rows;
97 $this->navbut = $navbut;
98
99 // display the template (default.php)
100 parent::display($tpl);
101 }
102
103 /**
104 * Setting the toolbar.
105 *
106 * @return void
107 */
108 protected function addToolBar()
109 {
110 // add menu title and some buttons to the page
111 JToolBarHelper::title(JText::translate('VAPMAINTITLEVIEWWEBHOOKS'), 'vikappointments');
112
113 $user = JFactory::getUser();
114
115 JToolBarHelper::back('JTOOLBAR_BACK', 'index.php?option=com_vikappointments&view=editconfigapp');
116
117 if ($user->authorise('core.create', 'com_vikappointments'))
118 {
119 JToolBarHelper::addNew('webhook.add');
120 }
121
122 if ($user->authorise('core.edit', 'com_vikappointments'))
123 {
124 JToolBarHelper::editList('webhook.edit');
125 }
126
127 if ($user->authorise('core.delete', 'com_vikappointments'))
128 {
129 JToolBarHelper::deleteList(VikAppointments::getConfirmSystemMessage(), 'webhook.delete');
130 }
131 }
132
133 /**
134 * Checks for advanced filters set in the request.
135 *
136 * @return boolean True if active, otherwise false.
137 */
138 protected function hasFilters()
139 {
140 return (bool) strlen($this->filters['status']);
141 }
142 }
143