Skip to content

Commit

Permalink
PS 8 compliancy
Browse files Browse the repository at this point in the history
  • Loading branch information
cchalamon committed Apr 10, 2023
1 parent 6672e4a commit acac9ff
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 43 deletions.
4 changes: 2 additions & 2 deletions controllers/front/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ public function initContent()
}

// Subject
$ever_subject = Configuration::getInt('EVERPSQUOTATION_MAIL_SUBJECT');
$ever_subject = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_MAIL_SUBJECT');
$subject = $ever_subject[(int)Context::getContext()->language->id];
// Filename
$filename = Configuration::getInt('EVERPSQUOTATION_FILENAME');
$filename = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_FILENAME');
$ever_filename = $filename[(int)Context::getContext()->language->id];

$id_shop = (int)Context::getContext()->shop->id;
Expand Down
49 changes: 10 additions & 39 deletions everpsquotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct()
{
$this->name = 'everpsquotation';
$this->tab = 'payments_gateways';
$this->version = '3.3.1';
$this->version = '4.0.1';
$this->author = 'Team Ever';
$this->need_instance = 0;
$this->bootstrap = true;
Expand All @@ -51,7 +51,7 @@ public function __construct()
$this->displayName = $this->l('Ever PS Quotation');
$this->description = $this->l('Simply accept quotations on your Prestashop !');
$this->confirmUninstall = $this->l('Do you REALLY want to uninstall this awesome module ?');
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
}

/**
Expand Down Expand Up @@ -82,8 +82,6 @@ public function checkHooks()
{
return ($this->createQuoteHooks()
&& $this->registerHook('header')
&& $this->registerHook('actionBeforeCreateEverQuote')
&& $this->registerHook('actionAfterCreateEverQuote')
&& $this->registerHook('displayCustomerAccount')
&& $this->registerHook('displayShoppingCart')
&& $this->registerHook('displayReassurance')
Expand Down Expand Up @@ -590,13 +588,13 @@ protected function postProcess()

Configuration::updateValue(
'EVERPSQUOTATION_CATEGORIES',
Tools::jsonEncode(Tools::getValue('EVERPSQUOTATION_CATEGORIES')),
json_encode(Tools::getValue('EVERPSQUOTATION_CATEGORIES')),
true
);

Configuration::updateValue(
'EVERPSQUOTATION_GROUPS',
Tools::jsonEncode(Tools::getValue('EVERPSQUOTATION_GROUPS')),
json_encode(Tools::getValue('EVERPSQUOTATION_GROUPS')),
true
);

Expand Down Expand Up @@ -650,27 +648,6 @@ protected function postProcess()
*/
protected function getConfigFormValues()
{
$everpsquotation_subject = array();
$everpsquotation_filename = array();
$everpsquotation_text = array();
foreach (Language::getLanguages(false) as $lang) {
$everpsquotation_subject[$lang['id_lang']] = (Tools::getValue(
'EVERPSQUOTATION_MAIL_SUBJECT_'.$lang['id_lang']
)) ? Tools::getValue(
'EVERPSQUOTATION_MAIL_SUBJECT_'.$lang['id_lang']
) : '';
$everpsquotation_filename[$lang['id_lang']] = (Tools::getValue(
'EVERPSQUOTATION_FILENAME_'.$lang['id_lang']
)) ? Tools::getValue(
'EVERPSQUOTATION_FILENAME_'.$lang['id_lang']
) : '';
$everpsquotation_text[$lang['id_lang']] = (Tools::getValue(
'EVERPSQUOTATION_TEXT_'.$lang['id_lang']
)) ? Tools::getValue(
'EVERPSQUOTATION_TEXT_'.$lang['id_lang']
) : '';
}

return array(
'EVERPSQUOTATION_CATEGORIES' => Tools::getValue(
'EVERPSQUOTATION_CATEGORIES',
Expand Down Expand Up @@ -733,19 +710,13 @@ protected function getConfigFormValues()
'EVERPSQUOTATION_RENDER_ON_VALIDATION'
)
),
'EVERPSQUOTATION_MAIL_SUBJECT' => (!empty(
$everpsquotation_subject[(int)Configuration::get('PS_LANG_DEFAULT')]
)) ? $everpsquotation_subject : Configuration::getInt(
'EVERPSQUOTATION_MAIL_SUBJECT' => Configuration::getConfigInMultipleLangs(
'EVERPSQUOTATION_MAIL_SUBJECT'
),
'EVERPSQUOTATION_FILENAME' => (!empty(
$everpsquotation_filename[(int)Configuration::get('PS_LANG_DEFAULT')]
)) ? $everpsquotation_filename : Configuration::getInt(
'EVERPSQUOTATION_FILENAME' => Configuration::getConfigInMultipleLangs(
'EVERPSQUOTATION_FILENAME'
),
'EVERPSQUOTATION_TEXT' => (!empty(
$everpsquotation_text[(int)Configuration::get('PS_LANG_DEFAULT')]
)) ? $everpsquotation_text : Configuration::getInt(
'EVERPSQUOTATION_TEXT' => Configuration::getConfigInMultipleLangs(
'EVERPSQUOTATION_TEXT'
),
);
Expand Down Expand Up @@ -1134,7 +1105,7 @@ private function createSimpleProductQuote($id_product, $id_product_attribute, $i
// die(var_dump($price_without_tax));
$quotedetail = new EverpsquotationDetail();
$quotedetail->id_everpsquotation_quotes = (int)$quote->id;
$quotedetail->id_warehouse = (int)$cart_details['total_discounts']['id_warehouse'];
// $quotedetail->id_warehouse = (int)$cart_details['total_discounts']['id_warehouse'];
$quotedetail->id_shop = (int)$cart_product['id_shop'];
$quotedetail->product_id = (int)$cart_product['id_product'];
$quotedetail->product_attribute_id = (int)$cart_product['id_product_attribute'];
Expand Down Expand Up @@ -1166,10 +1137,10 @@ private function createSimpleProductQuote($id_product, $id_product_attribute, $i
}

// Subject
$ever_subject = Configuration::getInt('EVERPSQUOTATION_MAIL_SUBJECT');
$ever_subject = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_MAIL_SUBJECT');
$subject = $ever_subject[(int)Context::getContext()->language->id];
// Filename
$filename = Configuration::getInt('EVERPSQUOTATION_FILENAME');
$filename = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_FILENAME');
$ever_filename = $filename[(int)Context::getContext()->language->id];

$id_shop = (int)Context::getContext()->shop->id;
Expand Down
4 changes: 2 additions & 2 deletions models/HTMLTemplateEverQuotationPdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function __construct($id_everpsquotation_quotes, $smarty)
$this->context = Context::getContext();
$this->shop = new Shop(Context::getContext()->shop->id);
$this->lang = new Language((int)Context::getContext()->language->id);
$text = Configuration::getInt('EVERPSQUOTATION_TEXT');
$filename = Configuration::getInt('EVERPSQUOTATION_FILENAME');
$text = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_TEXT');
$filename = Configuration::getConfigInMultipleLangs('EVERPSQUOTATION_FILENAME');
$this->text = $text[(int)Context::getContext()->language->id];
$this->filename = $filename[(int)Context::getContext()->language->id]
.$this->id_everpsquotation_quotes;
Expand Down
30 changes: 30 additions & 0 deletions override/classes/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Project : everpsquotation
* @author Team Ever
* @copyright Team Ever
* @license Tous droits réservés / Le droit d'auteur s'applique (All rights reserved / French copyright law applies)
* @see https://www.team-ever.com
*/

class Configuration extends ConfigurationCore
{
/**
* Get a single configuration value (in multiple languages).
*
* @param string $key Configuration Key
* @param int $idShopGroup Shop Group ID
* @param int $idShop Shop ID
*
* @return array Values in multiple languages
*/
public static function getConfigInMultipleLangs($key, $idShopGroup = null, $idShop = null)
{
$resultsArray = [];
foreach (Language::getIDs() as $idLang) {
$resultsArray[$idLang] = Configuration::get($key, $idLang, $idShopGroup, $idShop);
}

return $resultsArray;
}
}
18 changes: 18 additions & 0 deletions override/classes/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Project : everpsadvancepayment
* @author Team Ever
* @copyright Team Ever
* @license Tous droits réservés / Le droit d'auteur s'applique (All rights reserved / French copyright law applies)
* @see https://www.team-ever.com
*/

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
18 changes: 18 additions & 0 deletions override/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Project : everpsadvancepayment
* @author Team Ever
* @copyright Team Ever
* @license Tous droits réservés / Le droit d'auteur s'applique (All rights reserved / French copyright law applies)
* @see https://www.team-ever.com
*/

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;

0 comments on commit acac9ff

Please sign in to comment.