| @@ -1,0 +1,79 @@ | ||
| 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 | +/** | |
| 14 | + * @wponly this View is only for WP | |
| 15 | + */ | |
| 16 | + | |
| 17 | +// import Joomla view library | |
| 18 | +jimport('joomla.application.component.view'); | |
| 19 | + | |
| 20 | +class VikBookingViewGetpro extends JViewVikBooking { | |
| 21 | + | |
| 22 | + function display($tpl = null) { | |
| 23 | + // Set the toolbar | |
| 24 | + $this->addToolBar(); | |
| 25 | + | |
| 26 | + VikBookingLoader::import('update.changelog'); | |
| 27 | + VikBookingLoader::import('update.license'); | |
| 28 | + | |
| 29 | + $version = VikRequest::getString('version', '', 'request'); | |
| 30 | + if (!empty($version)) { | |
| 31 | + /** | |
| 32 | + * Download Changelog | |
| 33 | + * | |
| 34 | + * @since 1.2.12 | |
| 35 | + */ | |
| 36 | + $http = new JHttp; | |
| 37 | + | |
| 38 | + $url = 'https://vikwp.com/api/?task=products.changelog'; | |
| 39 | + | |
| 40 | + $data = array( | |
| 41 | + 'sku' => 'vbo', | |
| 42 | + 'version' => $version, | |
| 43 | + ); | |
| 44 | + | |
| 45 | + $response = $http->post($url, $data); | |
| 46 | + | |
| 47 | + if ($response->code == 200) { | |
| 48 | + VikBookingChangelog::store(json_decode($response->body)); | |
| 49 | + } | |
| 50 | + } | |
| 51 | + | |
| 52 | + $changelog = VikBookingChangelog::build(); | |
| 53 | + $lic_key = VikBookingLicense::getKey(); | |
| 54 | + $lic_date = VikBookingLicense::getExpirationDate(); | |
| 55 | + $is_pro = VikBookingLicense::isPro(); | |
| 56 | + | |
| 57 | + if (!$is_pro) { | |
| 58 | + VikError::raiseWarning('', JText::translate('VBONOPROERROR')); | |
| 59 | + JFactory::getApplication()->redirect('index.php?option=com_vikbooking&view=gotopro'); | |
| 60 | + exit; | |
| 61 | + } | |
| 62 | + | |
| 63 | + $this->changelog = $changelog; | |
| 64 | + $this->lic_key = $lic_key; | |
| 65 | + $this->lic_date = $lic_date; | |
| 66 | + $this->is_pro = $is_pro; | |
| 67 | + | |
| 68 | + // Display the template | |
| 69 | + parent::display($tpl); | |
| 70 | + } | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * Sets the toolbar | |
| 74 | + */ | |
| 75 | + protected function addToolBar() { | |
| 76 | + JToolBarHelper::title(JText::translate('VBMAINGETPROTITLE'), 'vikbooking'); | |
| 77 | + } | |
| 78 | + | |
| 79 | +} | |