PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / views / apiusers / view.html.php
vikappointments / admin / views / apiusers Last commit date
tmpl 2 days ago index.html 2 days ago view.html.php 2 days ago
view.html.php
150 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 API users view.
16 *
17 * @since 1.7
18 */
19 class VikAppointmentsViewapiusers 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['keysearch'] = $app->getUserStateFromRequest($this->getPoolName() . '.keysearch', 'keysearch', '', 'string');
37 $filters['active'] = $app->getUserStateFromRequest($this->getPoolName() . '.active', 'active', -1, 'int');
38
39 $this->filters = $filters;
40
41 $this->ordering = $app->getUserStateFromRequest($this->getPoolName() . '.ordering', 'filter_order', 'a.id', 'string');
42 $this->orderDir = $app->getUserStateFromRequest($this->getPoolName() . '.orderdir', 'filter_order_Dir', 'ASC', 'string');
43
44 $lim = $app->getUserStateFromRequest('com_vikappointments.limit', 'limit', $app->get('list_limit'), 'int');
45 $lim0 = $this->getListLimitStart($filters);
46 $navbut = "";
47
48 $rows = array();
49
50 $q = $dbo->getQuery(true)
51 ->select('SQL_CALC_FOUND_ROWS a.*')
52 ->from($dbo->qn('#__vikappointments_api_login', 'a'))
53 ->where(1)
54 ->order($dbo->qn($this->ordering) . ' ' . $this->orderDir);
55
56 if ($filters['keysearch'])
57 {
58 $q->andWhere(array(
59 $dbo->qn('a.application') . ' LIKE ' . $dbo->q("%{$filters['keysearch']}%"),
60 $dbo->qn('a.username') . ' LIKE ' . $dbo->q("%{$filters['keysearch']}%"),
61 ), 'OR');
62 }
63
64 if ($filters['active'] != -1)
65 {
66 $q->where($dbo->qn('a.active') . ' = ' . $filters['active']);
67 }
68
69 /**
70 * Add support for manipulating query through the plugins.
71 *
72 * @see /site/helpers/libraries/mvc/view.php @ JViewVAP::onBeforeListQuery()
73 *
74 * @since 1.7
75 */
76 $this->onBeforeListQuery($q);
77
78 $dbo->setQuery($q, $lim0, $lim);
79 $dbo->execute();
80
81 // assert limit used for list query
82 $this->assertListQuery($lim0, $lim);
83
84 if ($dbo->getNumRows())
85 {
86 $rows = $dbo->loadAssocList();
87 $dbo->setQuery('SELECT FOUND_ROWS();');
88 jimport('joomla.html.pagination');
89 $pageNav = new JPagination($dbo->loadResult(), $lim0, $lim);
90 $navbut = JLayoutHelper::render('blocks.pagination', ['pageNav' => $pageNav]);
91 }
92
93 foreach ($rows as &$r)
94 {
95 $q = "SELECT `l`.* FROM `#__vikappointments_api_login_logs` AS `l` WHERE `l`.`createdon` = (
96 SELECT MAX(`l2`.`createdon`) FROM `#__vikappointments_api_login_logs` AS `l2` WHERE `l2`.`id_login` = {$r['id']}
97 )";
98
99 $dbo->setQuery($q, 0, 1);
100 $r['log'] = $dbo->loadAssoc();
101 }
102
103 $this->rows = $rows;
104 $this->navbut = $navbut;
105
106 // display the template (default.php)
107 parent::display($tpl);
108 }
109
110 /**
111 * Setting the toolbar.
112 *
113 * @return void
114 */
115 private function addToolBar()
116 {
117 // add menu title and some buttons to the page
118 JToolbarHelper::title(JText::translate('VAPMAINTITLEVIEWAPIUSERS'), 'vikappointments');
119
120 $user = JFactory::getUser();
121
122 JToolBarHelper::back('JTOOLBAR_BACK', 'index.php?option=com_vikappointments&view=editconfigapp');
123
124 if ($user->authorise('core.create', 'com_vikappointments'))
125 {
126 JToolbarHelper::addNew('apiuser.add');
127 }
128
129 if ($user->authorise('core.edit', 'com_vikappointments'))
130 {
131 JToolbarHelper::editList('apiuser.edit');
132 }
133
134 if ($user->authorise('core.delete', 'com_vikappointments'))
135 {
136 JToolbarHelper::deleteList(VikAppointments::getConfirmSystemMessage(), 'apiuser.delete');
137 }
138 }
139
140 /**
141 * Checks for advanced filters set in the request.
142 *
143 * @return boolean True if active, otherwise false.
144 */
145 protected function hasFilters()
146 {
147 return $this->filters['active'] != -1;
148 }
149 }
150