name = 'freeorderconfirmation'; $this->version = '1.2.0'; $this->author = 'MyPresta.eu'; $this->tab = 'Other'; $this->mypresta_link = 'https://mypresta.eu/modules/front-office-features/ask-about-product-free.html'; $this->need_instance = 0; $this->bootstrap = 1; $this->secure_key = Tools::encrypt($this->name); parent::__construct(); if (!$dontTranslate) { $this->displayName = $this->l('Order confirmation page for free orders'); $this->description = $this->l('This module displays standard order confirmation page for "free orders". By default - prestashop\'s redirects customers to order history page. With this addon you can display standard confiramtion page.'); } $this->ps_versions_compliancy = array( 'min' => '1.7', 'max' => '9.0' ); $this->checkforupdates(0, 0); } public function hookactionAdminControllerSetMedia($params) { //for update feature purposes } public function checkforupdates($display_msg = 0, $form = 0) { // ---------- // // ---------- // // VERSION 16 // // ---------- // // ---------- // $this->mkey = "nlc"; if (@file_exists('../modules/' . $this->name . '/key.php')) { @require_once('../modules/' . $this->name . '/key.php'); } else { if (@file_exists(dirname(__FILE__) . $this->name . '/key.php')) { @require_once(dirname(__FILE__) . $this->name . '/key.php'); } else { if (@file_exists('modules/' . $this->name . '/key.php')) { @require_once('modules/' . $this->name . '/key.php'); } } } if ($form == 1) { return '
' . ($this->psversion() == 6 || $this->psversion() == 7 ? '
' . $this->l('MyPresta updates') . '
' : '') . '
' . ($this->psversion() == 5 ? '' . $this->l('MyPresta updates') . '' : '') . '
' . (Tools::isSubmit('submit_settings_updates_now') ? ($this->inconsistency(0) ? '' : '') . $this->checkforupdates(1) : '') . '

' . $this->l('Turn this option on if you want to check MyPresta.eu for module updates automatically. This option will display notification about new versions of this addon.') . '

' . $this->displayName . '

' . $this->l('This is direct link to official addon page, where you can read about changes in the module (changelog)') . '

'; } else { if (defined('_PS_ADMIN_DIR_')) { if (Tools::isSubmit('submit_settings_updates')) { Configuration::updateValue('mypresta_updates', Tools::getValue('mypresta_updates')); } if (Configuration::get('mypresta_updates') != 0 || (bool)Configuration::get('mypresta_updates') != false) { if (Configuration::get('update_' . $this->name) < (date("U") - 259200)) { $actual_version = freeorderconfirmationUpdate::verify($this->name, (isset($this->mkey) ? $this->mkey : 'nokey'), $this->version); } if (freeorderconfirmationUpdate::version($this->version) < freeorderconfirmationUpdate::version(Configuration::get('updatev_' . $this->name)) && Tools::getValue('ajax', 'false') == 'false') { $this->context->controller->warnings[] = '' . $this->displayName . ': ' . $this->l('New version available, check http://MyPresta.eu for more informations') . ' ' . $this->l('More details in changelog') . ''; $this->warning = $this->context->controller->warnings[0]; } } else { if (Configuration::get('update_' . $this->name) < (date("U") - 259200)) { $actual_version = freeorderconfirmationUpdate::verify($this->name, (isset($this->mkey) ? $this->mkey : 'nokey'), $this->version); } } if ($display_msg == 1) { if (freeorderconfirmationUpdate::version($this->version) < freeorderconfirmationUpdate::version(freeorderconfirmationUpdate::verify($this->name, (isset($this->mkey) ? $this->mkey : 'nokey'), $this->version))) { return "" . $this->l('New version available!') . ""; } else { return "" . $this->l('Module is up to date!') . ""; } } } } } public function inconsistency($ret = false) { return; } public function install() { return (parent::install()); } public function psversion($part = 1) { $version = _PS_VERSION_; $exp = $explode = explode(".", $version); if ($part == 1) { return $exp[1]; } if ($part == 2) { return $exp[2]; } if ($part == 3) { return $exp[3]; } if ($part == 4) { return $exp[3]; } } public function getContent() { return $this->renderConfigForm() . $this->checkforupdates(0, 1); } public function renderConfigForm() { if (Tools::isSubmit('freeorderconfirmation_oc')) { Configuration::updateValue('freeorderconfirmation_oc', Tools::getValue('freeorderconfirmation_oc', 0)); $this->context->controller->confirmations[] = $this->l('Settings saved'); } $fields_form_1 = array( 'form' => array( 'legend' => array( 'title' => $this->l('Configuration'), 'icon' => 'icon-cogs', ), 'input' => array( array( 'type' => 'switch', 'is_bool' => true, 'label' => $this->l('Turn on order confirmation page'), 'desc' => $this->l('Feature when active will display standard order confirmation page for free orders. If feature will be disabled - a standard behaviour will occur'), 'name' => 'freeorderconfirmation_oc', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled'), ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'), ), ), ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-default pull-right', 'name' => 'submitSettings', ), ), ); $helper = new HelperForm(); $helper->show_toolbar = false; $helper->default_form_language = $this->context->language->id; $helper->module = $this; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->submit_action = 'submitfreeorderconfirmationConfiguration'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array( 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id, ); return $helper->generateForm(array($fields_form_1)); } public function getConfigFieldsValues() { return array( 'freeorderconfirmation_oc' => Tools::getValue('freeorderconfirmation_oc', Configuration::get('freeorderconfirmation_oc')), ); } public function getOrderConfirmationPage($id_order) { if (!is_int($id_order)) { return false; } if (Configuration::get('freeorderconfirmation_oc') == 1) { return 'index.php?controller=order-confirmation&id_order=' . $id_order; } else { return false; } } } class freeorderconfirmationUpdate extends freeorderconfirmation { public static function _isCurl() { return function_exists('curl_version'); } public static function version($version) { $version = (int)str_replace(".", "", $version); if (strlen($version) == 3) { $version = (int)$version . "0"; } if (strlen($version) == 2) { $version = (int)$version . "00"; } if (strlen($version) == 1) { $version = (int)$version . "000"; } if (strlen($version) == 0) { $version = (int)$version . "0000"; } return (int)$version; } public static function verify($module, $key) { if (ini_get("allow_url_fopen")) { if (function_exists("file_get_contents")) { $actual_version = @file_get_contents('http://dev.mypresta.eu/update/get.php?module=' . $module . "&lic=$key&u=" . self::encrypt(_PS_BASE_URL_ . __PS_BASE_URI__)); } } Configuration::updateValue("update_" . $module, date("U")); Configuration::updateValue("updatev_" . $module, $actual_version); return $actual_version; } public static function encrypt($string) { return base64_encode($string); } }