| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage com_vikbooking |
| 5 |
* @author Alessio Gaggii - e4j - Extensionsforjoomla.com |
| 6 |
* @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 12 |
|
| 13 |
// import Joomla view library |
| 14 |
jimport('joomla.application.component.view'); |
| 15 |
|
| 16 |
class VikBookingViewCronexec extends JViewVikBooking |
| 17 |
{ |
| 18 |
function display($tpl = null) |
| 19 |
{ |
| 20 |
// This view is usually called within a modal box, so it does not require the toolbar or page title |
| 21 |
|
| 22 |
$app = JFactory::getApplication(); |
| 23 |
|
| 24 |
$id_cron = $app->input->getUint('cron_id', 0); |
| 25 |
$key = $app->input->getString('cronkey', ''); |
| 26 |
|
| 27 |
$this->cronModel = VBOMvcModel::getInstance('cronjob'); |
| 28 |
|
| 29 |
$this->cron = $this->cronModel->getItem($id_cron); |
| 30 |
|
| 31 |
// Dispatch the cron job by injecting the cron key within the |
| 32 |
// configuration array, in order to make sure that the execution |
| 33 |
// of the job has been requested by a reliable caller. |
| 34 |
// Enable the debug mode to catch the output buffering and disable |
| 35 |
// the strict model to allow the execution of unpublished jobs. |
| 36 |
$this->response = $this->cronModel->dispatch($id_cron, [ |
| 37 |
'key' => $key, |
| 38 |
'debug' => true, |
| 39 |
'strict' => false, |
| 40 |
]); |
| 41 |
|
| 42 |
if ($this->response === false) |
| 43 |
{ |
| 44 |
// an error has occurred |
| 45 |
$error = $this->cronModel->getError(); |
| 46 |
|
| 47 |
if (!$error instanceof Exception) |
| 48 |
{ |
| 49 |
// wrap error message in an exception for a better ease of use |
| 50 |
$error = new Exception($error ?: 'Error', 500); |
| 51 |
} |
| 52 |
|
| 53 |
// terminate session with an error |
| 54 |
VBOHttpDocument::getInstance($app)->close($error->getCode(), $error->getMessage()); |
| 55 |
} |
| 56 |
|
| 57 |
parent::display(); |
| 58 |
} |
| 59 |
} |
| 60 |
|