Skip to content

Commit

Permalink
chore: prestashop validator fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudrolland committed Dec 22, 2020
1 parent dc6a779 commit 6cb4d68
Show file tree
Hide file tree
Showing 8 changed files with 561 additions and 35 deletions.
525 changes: 517 additions & 8 deletions alma/composer.lock

Large diffs are not rendered by default.

20 changes: 7 additions & 13 deletions alma/controllers/admin/AdminAlmaCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ public function init()
{
parent::init();

$this->_select = (
'a.`id_category`, b.`name`, b.`description`, cpl.`name` as `parent`, a.`id_category` as `excluded`'
);
$this->_select = ('a.`id_category`, b.`name`, b.`description`, cpl.`name` as `parent`, a.`id_category` as `excluded`');
$this->_use_found_rows = false;

if (Shop::getContext() == Shop::CONTEXT_SHOP) {
Expand Down Expand Up @@ -186,10 +184,8 @@ public function processFilter()

foreach ($filters as $key => $value) {
/* Extracting filters from $_POST on key filter_ */
if (
$value != null
&& !strncmp($key, $prefix . $this->list_id . 'Filter_', 7 + Tools::strlen($prefix . $this->list_id))
) {
// phpcs:ignore
if ($value != null && !strncmp($key, $prefix . $this->list_id . 'Filter_', 7 + Tools::strlen($prefix . $this->list_id))) {
$key = Tools::substr($key, 7 + Tools::strlen($prefix . $this->list_id));
/* Table alias could be specified using a ! eg. alias!field */
$tmp_tab = explode('!', $key);
Expand Down Expand Up @@ -225,9 +221,7 @@ public function processFilter()
'Admin.Notifications.Error'
);
} else {
$sql_filter .= (
' AND ' . pSQL($key) . ' >= \'' . pSQL(Tools::dateFrom($value[0])) . '\''
);
$sql_filter .= (' AND ' . pSQL($key) . ' >= \'' . pSQL(Tools::dateFrom($value[0])) . '\'');
}
}

Expand Down Expand Up @@ -343,7 +337,7 @@ protected function processBulkEnable()
}

// need to force page refresh here for obscure reason
header('Location:' . $this->context->link->getAdminLink('AdminAlmaCategories'));
Tools::redirectAdmin($this->context->link->getAdminLink('AdminAlmaCategories'));
}

/**
Expand All @@ -362,7 +356,7 @@ protected function processBulkDisable()
}

// need to force page refresh here for obscure reason
header('Location:' . $this->context->link->getAdminLink('AdminAlmaCategories'));
Tools::redirectAdmin($this->context->link->getAdminLink('AdminAlmaCategories'));
}

public static function getExcluded($id_category)
Expand All @@ -386,7 +380,7 @@ public static function getDescriptionClean($description)
if (version_compare(_PS_VERSION_, '1.7', '>=')) {
return Tools::getDescriptionClean($description);
} else {
return strip_tags(stripslashes($description));
return strip_tags(Tools::stripslashes($description));
}
}
}
10 changes: 5 additions & 5 deletions alma/controllers/front/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ public function postProcess()
}

// Check that the selected installments count is indeed enabled
if (
!Settings::isInstallmentPlanEnabled($installmentsCount) ||
Settings::installmentPlanMinAmount($installmentsCount) > $data['payment']['purchase_amount'] ||
Settings::installmentPlanMaxAmount($installmentsCount) < $data['payment']['purchase_amount']
) {
$disabled = !Settings::isInstallmentPlanEnabled($installmentsCount)
|| Settings::installmentPlanMinAmount($installmentsCount) > $data['payment']['purchase_amount']
|| Settings::installmentPlanMaxAmount($installmentsCount) < $data['payment']['purchase_amount'];

if ($disabled) {
$this->genericErrorAndRedirect();

return;
Expand Down
2 changes: 1 addition & 1 deletion alma/controllers/hook/DisplayPaymentHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function run($params)
}

$paymentButtonDescription = Settings::getPaymentButtonDescription();

$sortOrders = [];
foreach ($installmentPlans as $plan) {
$n = $plan->installmentsCount;
if (!$plan->isEligible && Settings::isInstallmentPlanEnabled($n)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public function canRun()

public function run($params)
{

if (array_key_exists('type', $params)) {
if (
(version_compare(_PS_VERSION_, '1.6.0', '>') && $params['type'] === 'price') ||
(!in_array($params['type'], ['price', 'after_price']))
) {
$skip = (version_compare(_PS_VERSION_, '1.6.0', '>') && $params['type'] === 'price') ||
(!in_array($params['type'], ['price', 'after_price']));
if ($skip) {
return null;
}
}
Expand Down
23 changes: 23 additions & 0 deletions alma/views/js/alma-product.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* 2018-2020 Alma SAS
*
* THE MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* @author Alma SAS <[email protected]>
* @copyright 2018-2020 Alma SAS
* @license https://opensource.org/licenses/MIT The MIT License
*/

(function ($) {
$(function () {
var selectors = window.__alma_widgetQuerySelectors;
Expand Down
2 changes: 1 addition & 1 deletion alma/views/templates/hook/_partials/exclusionMsg.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
* @license https://opensource.org/licenses/MIT The MIT License
*}

<img src="{$logo}" alt="Alma" class="logo">
<img src="{$logo|escape:'html':'UTF-8'}" alt="Alma" class="logo">
<span>{$msg|escape:'html':'UTF-8'}</span>
6 changes: 3 additions & 3 deletions alma/views/templates/hook/excludedCategories.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{*
* 2018-2019 Alma SAS
* 2018-2020 Alma SAS
*
* THE MIT LICENSE
*
Expand All @@ -17,7 +17,7 @@
* IN THE SOFTWARE.
*
* @author Alma SAS <[email protected]>
* @copyright 2018-2019 Alma SAS
* @copyright 2018-2020 Alma SAS
* @license https://opensource.org/licenses/MIT The MIT License
*}

Expand All @@ -37,6 +37,6 @@
</p>
<p>
<strong>{l s='Categories currently excluded : ' mod='alma'}</strong>
{$excludedCategories}
{$excludedCategories|escape}
</p>
</div>

0 comments on commit 6cb4d68

Please sign in to comment.