default.php
363 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 | JHtml::fetch('bootstrap.tooltip', '.hasTooltip'); |
| 15 | JHtml::fetch('vaphtml.assets.fontawesome'); |
| 16 | JHtml::fetch('vaphtml.assets.toast', 'bottom-right'); |
| 17 | |
| 18 | $rows = $this->rows; |
| 19 | |
| 20 | $filters = $this->filters; |
| 21 | |
| 22 | $ordering = $this->ordering; |
| 23 | |
| 24 | $vik = VAPApplication::getInstance(); |
| 25 | |
| 26 | $is_searching = $this->hasFilters(); |
| 27 | |
| 28 | /** |
| 29 | * Trigger event to display custom HTML. |
| 30 | * In case it is needed to include any additional fields, |
| 31 | * it is possible to create a plugin and attach it to an event |
| 32 | * called "onDisplayViewApilogsList". The event method receives the |
| 33 | * view instance as argument. |
| 34 | * |
| 35 | * @since 1.7 |
| 36 | */ |
| 37 | $forms = $this->onDisplayListView($is_searching); |
| 38 | |
| 39 | ?> |
| 40 | |
| 41 | <form action="index.php?option=com_vikappointments" method="post" name="adminForm" id="adminForm"> |
| 42 | |
| 43 | <div class="btn-toolbar" style="height: 32px;"> |
| 44 | <div class="btn-group pull-left input-append"> |
| 45 | <input type="text" name="keysearch" id="vapkeysearch" size="32" |
| 46 | value="<?php echo $this->escape($filters['keysearch']); ?>" placeholder="<?php echo $this->escape(JText::translate('JSEARCH_FILTER_SUBMIT')); ?>" /> |
| 47 | |
| 48 | <button type="submit" class="btn"> |
| 49 | <i class="fas fa-search"></i> |
| 50 | </button> |
| 51 | </div> |
| 52 | |
| 53 | <!-- Define role to detect the supported hook --> |
| 54 | <!-- {"rule":"customizer","event":"onDisplayViewApilogsList","type":"search","key":"search"} --> |
| 55 | |
| 56 | <?php |
| 57 | // plugins can use the "search" key to introduce custom |
| 58 | // filters within the search bar |
| 59 | if (isset($forms['search'])) |
| 60 | { |
| 61 | echo $forms['search']; |
| 62 | } |
| 63 | |
| 64 | // in case a plugin needs to use the filter bar, display the button |
| 65 | if (isset($forms['filters'])) |
| 66 | { |
| 67 | ?> |
| 68 | <div class="btn-group pull-left"> |
| 69 | <button type="button" class="btn <?php echo ($is_searching ? 'btn-primary' : ''); ?>" onclick="vapToggleSearchToolsButton(this);"> |
| 70 | <?php echo JText::translate('JSEARCH_TOOLS'); ?> <i class="fas fa-caret-<?php echo ($is_searching ? 'up' : 'down'); ?>" id="vap-tools-caret"></i> |
| 71 | </button> |
| 72 | </div> |
| 73 | <?php |
| 74 | } |
| 75 | ?> |
| 76 | |
| 77 | <div class="btn-group pull-left"> |
| 78 | <button type="button" class="btn" onclick="clearFilters();"> |
| 79 | <?php echo JText::translate('JSEARCH_FILTER_CLEAR'); ?> |
| 80 | </button> |
| 81 | </div> |
| 82 | </div> |
| 83 | |
| 84 | <div class="btn-toolbar" id="vap-search-tools" style="height: 32px;<?php echo ($is_searching ? '' : 'display: none;'); ?>"> |
| 85 | |
| 86 | <!-- Define role to detect the supported hook --> |
| 87 | <!-- {"rule":"customizer","event":"onDisplayViewApilogsList","type":"search","key":"filters"} --> |
| 88 | |
| 89 | <?php |
| 90 | // plugins can use the "filters" key to introduce custom |
| 91 | // filters within the search bar |
| 92 | if (isset($forms['filters'])) |
| 93 | { |
| 94 | echo $forms['filters']; |
| 95 | } |
| 96 | ?> |
| 97 | |
| 98 | </div> |
| 99 | |
| 100 | <?php |
| 101 | if (count($rows) == 0) |
| 102 | { |
| 103 | echo $vik->alert(JText::translate('JGLOBAL_NO_MATCHING_RESULTS')); |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | /** |
| 108 | * Trigger event to display custom columns. |
| 109 | * |
| 110 | * @since 1.7 |
| 111 | */ |
| 112 | $columns = $this->onDisplayTableColumns(); |
| 113 | ?> |
| 114 | |
| 115 | <!-- Define role to detect the supported hook --> |
| 116 | <!-- {"rule":"customizer","event":"onDisplayApilogsTableTH","type":"th"} --> |
| 117 | |
| 118 | <!-- Define role to detect the supported hook --> |
| 119 | <!-- {"rule":"customizer","event":"onDisplayApilogsTableTD","type":"td"} --> |
| 120 | |
| 121 | <table cellpadding="4" cellspacing="0" border="0" width="100%" class="<?php echo $vik->getAdminTableClass(); ?>"> |
| 122 | |
| 123 | <?php echo $vik->openTableHead(); ?> |
| 124 | <tr> |
| 125 | |
| 126 | <th width="1%"> |
| 127 | <?php echo $vik->getAdminToggle(count($rows)); ?> |
| 128 | </th> |
| 129 | |
| 130 | <!-- ID --> |
| 131 | |
| 132 | <th class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>" width="1%" style="text-align: left;"> |
| 133 | <?php echo JText::translate('VAPMANAGEGROUP1'); ?> |
| 134 | </th> |
| 135 | |
| 136 | <!-- CREATED ON --> |
| 137 | |
| 138 | <th class="<?php echo $vik->getAdminThClass('left'); ?>" width="15%" style="text-align: left;"> |
| 139 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGEMEDIA14', 'l.createdon', $this->orderDir, $this->ordering); ?> |
| 140 | </th> |
| 141 | |
| 142 | <!-- CONTENT --> |
| 143 | |
| 144 | <th class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>" width="30%" style="text-align: left;"> |
| 145 | <?php echo JText::translate('VAPMANAGECRONJOBLOG3'); ?> |
| 146 | </th> |
| 147 | |
| 148 | <!-- PAYLOAD --> |
| 149 | |
| 150 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="2%" style="text-align: center;"> |
| 151 | |
| 152 | </th> |
| 153 | |
| 154 | <!-- CUSTOM --> |
| 155 | |
| 156 | <?php |
| 157 | foreach ($columns as $k => $col) |
| 158 | { |
| 159 | ?> |
| 160 | <th data-id="<?php echo $this->escape($k); ?>" class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>"> |
| 161 | <?php echo $col->th; ?> |
| 162 | </th> |
| 163 | <?php |
| 164 | } |
| 165 | ?> |
| 166 | |
| 167 | <!-- STATUS --> |
| 168 | |
| 169 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="15%" style="text-align: center;"> |
| 170 | <?php echo JHtml::fetch('vaphtml.admin.sort', 'VAPMANAGECRONJOBLOG4', 'l.status', $this->orderDir, $this->ordering); ?> |
| 171 | </th> |
| 172 | |
| 173 | <!-- IP ADDRESS --> |
| 174 | |
| 175 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="10%" style="text-align: center;"> |
| 176 | <?php echo JText::translate('VAPMANAGEAPIUSER17'); ?> |
| 177 | </th> |
| 178 | |
| 179 | </tr> |
| 180 | <?php echo $vik->closeTableHead(); ?> |
| 181 | |
| 182 | <?php |
| 183 | $kk = 0; |
| 184 | for ($i = 0; $i < count($rows); $i++) |
| 185 | { |
| 186 | $row = $rows[$i]; |
| 187 | ?> |
| 188 | <tr class="row<?php echo $kk; ?>"> |
| 189 | |
| 190 | <td> |
| 191 | <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row['id']; ?>" onClick="<?php echo $vik->checkboxOnClick(); ?>"> |
| 192 | </td> |
| 193 | |
| 194 | <!-- ID --> |
| 195 | |
| 196 | <td class="hidden-phone"> |
| 197 | <?php echo $row['id']; ?> |
| 198 | </td> |
| 199 | |
| 200 | <!-- CREATION DATE --> |
| 201 | |
| 202 | <td> |
| 203 | <span class="hasTooltip" title="<?php echo $this->escape(JHtml::fetch('date', $row['createdon'], JText::translate('DATE_FORMAT_LC2'))); ?>"> |
| 204 | <?php echo JHtml::fetch('date.relative', $row['createdon'], null, null, JText::translate('DATE_FORMAT_LC2')); ?> |
| 205 | </span> |
| 206 | |
| 207 | <div> |
| 208 | <?php |
| 209 | if ($row['application'] || $row['username']) |
| 210 | { |
| 211 | ?> |
| 212 | <span class="badge"> |
| 213 | <?php echo $row['application'] ? $row['application'] : $row['username']; ?> |
| 214 | </span> |
| 215 | <?php |
| 216 | } |
| 217 | ?> |
| 218 | </div> |
| 219 | </td> |
| 220 | |
| 221 | <!-- CONTENT --> |
| 222 | |
| 223 | <td class="hidden-phone"> |
| 224 | <?php echo nl2br($row['content']); ?> |
| 225 | </td> |
| 226 | |
| 227 | <!-- PAYLOAD --> |
| 228 | |
| 229 | <td style="text-align: center;"> |
| 230 | <?php |
| 231 | if ($row['payload']) |
| 232 | { |
| 233 | ?> |
| 234 | <a href="javascript:void(0)" onclick="openPayloadModal(<?php echo $row['id']; ?>);"> |
| 235 | <i class="fas fa-code-branch big"></i> |
| 236 | </a> |
| 237 | <?php |
| 238 | } |
| 239 | else |
| 240 | { |
| 241 | ?> |
| 242 | <a class="disabled"> |
| 243 | <i class="fas fa-code-branch big"></i> |
| 244 | </a> |
| 245 | <?php |
| 246 | } |
| 247 | ?> |
| 248 | </td> |
| 249 | |
| 250 | <!-- CUSTOM --> |
| 251 | |
| 252 | <?php |
| 253 | foreach ($columns as $k => $col) |
| 254 | { |
| 255 | ?> |
| 256 | <td data-id="<?php echo $this->escape($k); ?>" class="hidden-phone"> |
| 257 | <?php echo isset($col->td[$i]) ? $col->td[$i] : ''; ?> |
| 258 | </td> |
| 259 | <?php |
| 260 | } |
| 261 | ?> |
| 262 | |
| 263 | <!-- STATUS --> |
| 264 | |
| 265 | <td style="text-align: center;"> |
| 266 | <b style="text-transform:uppercase;color:#<?php echo ($row['status'] ? '090' : '900'); ?>"> |
| 267 | <?php echo JText::translate($row['status'] ? 'VAPCRONLOGSTATUSOK' : 'VAPCRONLOGSTATUSERROR'); ?> |
| 268 | </b> |
| 269 | </td> |
| 270 | |
| 271 | <!-- IP ADDRESS --> |
| 272 | |
| 273 | <td style="text-align: center;" class="hidden-phone"> |
| 274 | <?php echo $row['ip']; ?> |
| 275 | </td> |
| 276 | |
| 277 | </tr> |
| 278 | <?php |
| 279 | $kk = 1 - $kk; |
| 280 | } |
| 281 | ?> |
| 282 | </table> |
| 283 | <?php |
| 284 | } |
| 285 | ?> |
| 286 | |
| 287 | <input type="hidden" name="boxchecked" value="0" /> |
| 288 | <input type="hidden" name="task" value="" /> |
| 289 | <input type="hidden" name="view" value="apilogs" /> |
| 290 | <input type="hidden" name="id_login" value="<?php echo $filters['id_login']; ?>" /> |
| 291 | |
| 292 | <input type="hidden" name="filter_order" value="<?php echo $this->ordering; ?>" /> |
| 293 | <input type="hidden" name="filter_order_Dir" value="<?php echo $this->orderDir; ?>" /> |
| 294 | |
| 295 | <?php echo JHtml::fetch('form.token'); ?> |
| 296 | <?php echo $this->navbut; ?> |
| 297 | </form> |
| 298 | |
| 299 | <?php |
| 300 | foreach ($rows as $row) |
| 301 | { |
| 302 | $this->currentLog = $row; |
| 303 | |
| 304 | echo JHtml::fetch( |
| 305 | 'bootstrap.renderModal', |
| 306 | 'jmodal-payload-' . $row['id'], |
| 307 | array( |
| 308 | 'title' => JText::translate('VAPMANAGEAPIUSER22'), |
| 309 | 'closeButton' => true, |
| 310 | 'keyboard' => false, |
| 311 | 'bodyHeight' => 80, |
| 312 | 'footer' => '<button type="button" class="btn" data-role="copy-payload" data-id="' . $row['id'] . '">' . JText::translate('VAPCOPY') . '</button>', |
| 313 | ), |
| 314 | $this->loadTemplate('payload') |
| 315 | ); |
| 316 | } |
| 317 | |
| 318 | JText::script('VAPSYSTEMCONFIRMATIONMSG'); |
| 319 | JText::script('VAPCOPIED'); |
| 320 | ?> |
| 321 | |
| 322 | <script> |
| 323 | |
| 324 | function clearFilters() { |
| 325 | jQuery('#vapkeysearch').val(''); |
| 326 | |
| 327 | document.adminForm.submit(); |
| 328 | } |
| 329 | |
| 330 | function openPayloadModal(id) { |
| 331 | vapOpenJModal('payload-' + id, null, true); |
| 332 | } |
| 333 | |
| 334 | function vapOpenJModal(id, url, jqmodal) { |
| 335 | <?php echo $vik->bootOpenModalJS(); ?> |
| 336 | } |
| 337 | |
| 338 | (function($) { |
| 339 | 'use strict'; |
| 340 | |
| 341 | $(function() { |
| 342 | $('button[data-role="copy-payload"]').on('click', function() { |
| 343 | const textarea = $('#payload_copy_' + $(this).data('id')); |
| 344 | |
| 345 | copyToClipboard(textarea[0]).then(() => { |
| 346 | ToastMessage.dispatch(Joomla.JText._('VAPCOPIED')); |
| 347 | }).catch((err) => { |
| 348 | // do nothing on error |
| 349 | }); |
| 350 | }); |
| 351 | }); |
| 352 | |
| 353 | Joomla.submitbutton = (task) => { |
| 354 | if (task == 'apilog.truncate' && !confirm(Joomla.JText._('VAPSYSTEMCONFIRMATIONMSG'))) { |
| 355 | return false; |
| 356 | } |
| 357 | |
| 358 | Joomla.submitform(task, document.adminForm); |
| 359 | } |
| 360 | })(jQuery); |
| 361 | |
| 362 | </script> |
| 363 |