Skip to content

Commit

Permalink
release 4.12.7 (#26)
Browse files Browse the repository at this point in the history
* Wrap tables with backticks

* Remove indent

* Update version
  • Loading branch information
KFoobar authored Jan 13, 2023
1 parent bae795a commit 4ea2b3d
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 35 deletions.
18 changes: 9 additions & 9 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Copyright 2022 Svea Ekonomi AB

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2 changes: 1 addition & 1 deletion docs/info.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"module_version": "4.12.6"
"module_version": "4.12.7"
}
2 changes: 1 addition & 1 deletion src/admin/model/extension/svea/campaigns.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function truncateScoCampaignsTable()

public function fetchScoCountries($countryString)
{
$countries = $this->db->query("SELECT `key`, `value` FROM " . DB_PREFIX . "setting WHERE `key` LIKE " . $countryString . ";");
$countries = $this->db->query("SELECT `key`, `value` FROM `" . DB_PREFIX . "setting` WHERE `key` LIKE " . $countryString . ";");
return $countries;
}

Expand Down
4 changes: 2 additions & 2 deletions src/admin/model/extension/svea/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function addSveaCustomEvent($code, $trigger, $action)

$this->load->model($this->eventString);

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "event WHERE `code` = '" . $this->db->escape($code) . "'");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "event` WHERE `code` = '" . $this->db->escape($code) . "'");

if (count($query->rows) === 0) {
if (VERSION < 3.0) {
Expand All @@ -71,7 +71,7 @@ public function addSveaCustomEvent($code, $trigger, $action)

private function getExtensions($type)
{
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "extension WHERE `type` = '" . $this->db->escape($type) . "'");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension` WHERE `type` = '" . $this->db->escape($type) . "'");

return $query->rows;
}
Expand Down
7 changes: 6 additions & 1 deletion src/admin/model/extension/svea/newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ class ModelExtensionSveaNewsletter extends Model
{
public function getUsersConsentingToNewsletter()
{
$query = $this->db->query("SELECT DISTINCT " . DB_PREFIX . "order.email FROM " . DB_PREFIX . "order INNER JOIN " . DB_PREFIX . "svea_sco_order ON " . DB_PREFIX . "order.order_id=" . DB_PREFIX . "svea_sco_order.order_id WHERE " . DB_PREFIX . "order.email != '' AND " . DB_PREFIX . "svea_sco_order.newsletter != 0;");
$query = $this->db->query("
SELECT DISTINCT `" . DB_PREFIX . "order`.`email` FROM `" . DB_PREFIX . "order`
INNER JOIN `" . DB_PREFIX . "svea_sco_order`
ON `" . DB_PREFIX . "order`.`order_id` = `" . DB_PREFIX . "svea_sco_order`.`order_id`
WHERE `" . DB_PREFIX . "order`.`email` != ''
AND `" . DB_PREFIX . "svea_sco_order`.`newsletter` != 0;");

return $query->rows;
}
Expand Down
8 changes: 4 additions & 4 deletions src/admin/model/extension/svea/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public function upgradeDatabase($module)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
');

$versionQuery = $this->db->query("SELECT version FROM " . DB_PREFIX . "svea_version WHERE module = '$module'");
$versionQuery = $this->db->query("SELECT version FROM `" . DB_PREFIX . "svea_version` WHERE module = '$module'");

if ($versionQuery->num_rows == 0) {
$this->db->query("INSERT INTO " . DB_PREFIX . "svea_version SET module = '$module', version = 0");
$this->db->query("INSERT INTO `" . DB_PREFIX . "svea_version` SET module = '$module', version = 0");
$version = 0;
} else {
$version = $versionQuery->row['version'];
Expand All @@ -44,7 +44,7 @@ public function upgradeDatabase($module)
case 'svea_partpayment':
$tableExists = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . "svea_params_table'");
if ($tableExists->num_rows) {
$this->db->query("ALTER TABLE " . DB_PREFIX . "svea_params_table MODIFY interestRatePercent DOUBLE NOT NULL ");
$this->db->query("ALTER TABLE `" . DB_PREFIX . "svea_params_table` MODIFY interestRatePercent DOUBLE NOT NULL ");
}
break;
case 'sco':
Expand Down Expand Up @@ -82,7 +82,7 @@ public function upgradeDatabase($module)
if ($tableExists->num_rows) {
$tableExists = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . "svea_wp_campaigns'");
if (!$tableExists->num_rows) {
$this->db->query("ALTER TABLE " . DB_PREFIX . "svea_params_table RENAME TO " . DB_PREFIX . "svea_wp_campaigns");
$this->db->query("ALTER TABLE `" . DB_PREFIX . "svea_params_table` RENAME TO `" . DB_PREFIX . "svea_wp_campaigns`");
}
}
break;
Expand Down
4 changes: 2 additions & 2 deletions src/catalog/controller/extension/payment/svea_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function responseSvea()
if ($response->resultcode !== '0') {
if ($response->accepted === 1) {
$cleanClientOrderNumber = str_replace('.err', '', $response->clientOrderNumber);//bug fix for gateway concatenating ".err" on transactionId
$currentOpencartOrderStatus = $this->db->query("SELECT order_status_id FROM " . DB_PREFIX . "order WHERE order_id = '" . $this->db->escape((int)$cleanClientOrderNumber) . "'")->row;
$currentOpencartOrderStatus = $this->db->query("SELECT order_status_id FROM `" . DB_PREFIX . "order` WHERE order_id = '" . $this->db->escape((int)$cleanClientOrderNumber) . "'")->row;

if ($currentOpencartOrderStatus['order_status_id'] == 0) {
$this->model_checkout_order->addOrderHistory($cleanClientOrderNumber, $this->config->get('config_order_status_id'), 'Svea transactionId: '.$response->transactionId, false);
Expand Down Expand Up @@ -199,7 +199,7 @@ public function callbackSvea()

if ($response->accepted === 1) {
$cleanClientOrderNumber = str_replace('.err', '', $response->clientOrderNumber);//bug fix for gateway concatenating ".err" on transactionId
$currentOpencartOrderStatus = $this->db->query("SELECT order_status_id FROM " . DB_PREFIX . "order WHERE order_id = '" . $this->db->escape((int)$cleanClientOrderNumber) . "'")->row;
$currentOpencartOrderStatus = $this->db->query("SELECT order_status_id FROM `" . DB_PREFIX . "order` WHERE order_id = '" . $this->db->escape((int)$cleanClientOrderNumber) . "'")->row;

if ($currentOpencartOrderStatus != null && $currentOpencartOrderStatus['order_status_id'] == 0) {
$this->model_checkout_order->addOrderHistory($cleanClientOrderNumber, $this->config->get('config_order_status_id'), 'Svea transactionId: '.$response->transactionId, false);
Expand Down
4 changes: 2 additions & 2 deletions src/catalog/controller/extension/payment/svea_directbank.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function responseSvea()
if ($response->resultcode !== '0') {
if ($response->accepted === 1) {
$cleanClientOrderNumber = str_replace('.err', '', $response->clientOrderNumber);//bug fix for gateway concatenating ".err" on transactionId
$currentOpencartOrderStatus = $this->db->query("SELECT order_status_id FROM " . DB_PREFIX . "order WHERE order_id = '" . $this->db->escape((int)$cleanClientOrderNumber) . "'")->row;
$currentOpencartOrderStatus = $this->db->query("SELECT order_status_id FROM `" . DB_PREFIX . "order` WHERE order_id = '" . $this->db->escape((int)$cleanClientOrderNumber) . "'")->row;

if ($currentOpencartOrderStatus['order_status_id'] == 0) {
$this->model_checkout_order->addOrderHistory($cleanClientOrderNumber, $this->config->get('config_order_status_id'), 'Svea transactionId: '.$response->transactionId, false);
Expand Down Expand Up @@ -220,7 +220,7 @@ public function callbackSvea()
$cleanClientOrderNumber = str_replace('.err', '', $response->clientOrderNumber);//bug fix for gateway concatenating ".err" on transactionId

if ($response->accepted === 1) {
$currentOpencartOrderStatus = $this->db->query("SELECT order_status_id FROM " . DB_PREFIX . "order WHERE order_id = '" . $this->db->escape((int)$cleanClientOrderNumber) . "'")->row;
$currentOpencartOrderStatus = $this->db->query("SELECT order_status_id FROM `" . DB_PREFIX . "order` WHERE order_id = '" . $this->db->escape((int)$cleanClientOrderNumber) . "'")->row;

if ($currentOpencartOrderStatus != null && $currentOpencartOrderStatus['order_status_id'] == 0) {
$this->model_checkout_order->addOrderHistory($cleanClientOrderNumber, $this->config->get('config_order_status_id'), 'Svea transactionId: '.$response->transactionId, false);
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/controller/extension/svea/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function index()
: null;

if (isset($this->session->data['order_id'])) {
$query_response = $this->db->query("SELECT order_status_id FROM " . DB_PREFIX . "order WHERE order_id='" . $this->db->escape($this->session->data['order_id']) . "';")->row;
$query_response = $this->db->query("SELECT order_status_id FROM `" . DB_PREFIX . "order` WHERE order_id='" . $this->db->escape($this->session->data['order_id']) . "';")->row;
if ($query_response['order_status_id'] != 0) {
unset($this->session->data['order_id']);
unset($this->session->data[$this->moduleString . 'sco_order_id']);
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/controller/extension/svea/success.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function index()
}

if ($order_id && $hash) {
$query = $this->db->query("SELECT `checkout_id` FROM " . DB_PREFIX . "svea_sco_order WHERE order_id = '" . $this->db->escape((int)$order_id) . "'");
$query = $this->db->query("SELECT `checkout_id` FROM `" . DB_PREFIX . "svea_sco_order` WHERE order_id = '" . $this->db->escape((int)$order_id) . "'");
$module_sco_order_id = (int)$query->row['checkout_id'];
}

Expand Down
11 changes: 8 additions & 3 deletions src/catalog/model/extension/payment/svea_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function getMethod($address, $total)
$this->load->language('extension/payment/svea_card');

if ($this->config->get($this->paymentString . 'svea_card_status')) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get($this->paymentString . 'svea_card_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE geo_zone_id = '" . (int)$this->config->get($this->paymentString . 'svea_card_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

if (!$this->config->get($this->paymentString . 'svea_card_geo_zone_id')) {
$status = true;
Expand Down Expand Up @@ -48,14 +48,19 @@ public function getMethod($address, $total)

public function getTaxRate($tax_rate_id)
{
$query = $this->db->query("SELECT tr.tax_rate_id, tr.name AS name, tr.rate, tr.type, tr.geo_zone_id, gz.name AS geo_zone, tr.date_added, tr.date_modified FROM " . DB_PREFIX . "tax_rate tr LEFT JOIN " . DB_PREFIX . "geo_zone gz ON (tr.geo_zone_id = gz.geo_zone_id) WHERE tr.tax_rate_id = '" . (int)$tax_rate_id . "'");
$query = $this->db->query("
SELECT tr.tax_rate_id, tr.name AS name, tr.rate, tr.type, tr.geo_zone_id, gz.name AS geo_zone, tr.date_added, tr.date_modified
FROM `" . DB_PREFIX . "tax_rate` tr
LEFT JOIN `" . DB_PREFIX . "geo_zone` gz
ON (tr.geo_zone_id = gz.geo_zone_id)
WHERE tr.tax_rate_id = '" . (int)$tax_rate_id . "'");

return $query->row;
}

public function getPaymentTaxRateIdByTaxClass($tax_class)
{
$query = $this->db->query("SELECT tax_rate_id FROM " . DB_PREFIX . "tax_rule WHERE tax_class_id = '" . (int)$tax_class . "' ORDER BY priority DESC");
$query = $this->db->query("SELECT tax_rate_id FROM `" . DB_PREFIX . "tax_rule` WHERE tax_class_id = '" . (int)$tax_class . "' ORDER BY priority DESC");

return $query->rows;
}
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/model/extension/payment/svea_directbank.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function getMethod($address, $total)
$this->load->language('extension/payment/svea_directbank');

if ($this->config->get($this->paymentString . 'svea_directbank_status')) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get($this->paymentString . 'svea_directbank_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE geo_zone_id = '" . (int)$this->config->get($this->paymentString . 'svea_directbank_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

if (!$this->config->get($this->paymentString . 'svea_directbank_geo_zone_id')) {
$status = true;
Expand Down
4 changes: 2 additions & 2 deletions src/catalog/model/extension/payment/svea_invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function getMethod($address, $total)
$this->setVersionStrings();

if ($this->config->get($this->paymentString . 'svea_invoice_status')) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get($this->paymentString . 'svea_invoice_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE geo_zone_id = '" . (int)$this->config->get($this->paymentString . 'svea_invoice_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

if (!$this->config->get($this->paymentString . 'svea_invoice_geo_zone_id')) {
$status = true;
Expand Down Expand Up @@ -72,7 +72,7 @@ public function getCountryIdFromCountryCode($countryCode)
{
$this->setVersionStrings();

$query = $this->db->query("SELECT country_id, name FROM " . DB_PREFIX . "country WHERE status = '1' AND iso_code_2 = '$countryCode' ORDER BY name ASC");
$query = $this->db->query("SELECT country_id, name FROM `" . DB_PREFIX . "country` WHERE status = '1' AND iso_code_2 = '$countryCode' ORDER BY name ASC");
$country = $query->rows;

return array("country_id" => $country[0]['country_id'], "country_name" => $country[0]['name']);
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/model/extension/payment/svea_partpayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getMethod($address, $total)
$countryCode = $address['iso_code_2'];

if ($this->config->get($this->paymentString . 'svea_partpayment_status')) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get($this->paymentString . 'svea_partpayment_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone_to_geo_zone` WHERE geo_zone_id = '" . (int)$this->config->get($this->paymentString . 'svea_partpayment_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

if ($this->config->get($this->paymentString . 'svea_partpayment_min_amount_$countryCode') > $this->currency->getValue($this->session->data['currency']) * $total) {
$status = false;
Expand Down
4 changes: 2 additions & 2 deletions src/catalog/model/extension/svea/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function getCheckoutProducts($order_id)
public function getCountryCode($checkout_order_id)
{
$checkout_order_id = (int)$checkout_order_id;
$query = $this->db->query("SELECT currency FROM " . DB_PREFIX . "svea_sco_order WHERE checkout_id = '" . $checkout_order_id . "'");
$query = $this->db->query("SELECT currency FROM `" . DB_PREFIX . "svea_sco_order` WHERE checkout_id = '" . $checkout_order_id . "'");

if ($query->num_rows !== 0) {
if ($query->row['currency'] == "NOK") {
Expand Down Expand Up @@ -515,7 +515,7 @@ public function updateCheckoutOrder($data)
public function addInvoiceFee($data)
{
if (is_array($data['cart']['items']) || is_object($data['cart']['items'])) {
$totals = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$data['clientordernumber'] . "' ORDER BY sort_order");
$totals = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE order_id = '" . (int)$data['clientordernumber'] . "' ORDER BY sort_order");

foreach ($data['cart']['items'] as $order_row) {
if ($order_row['articlenumber'] == "6eaceaec-fffc-41ad-8095-c21de609bcfd") {
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/model/extension/svea/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class ModelExtensionSveaOrder extends Model
{
public function getOrderHistoryComment($orderId)
{
return $this->db->query("SELECT comment FROM " . DB_PREFIX . "order_history WHERE order_id = " . $orderId);
return $this->db->query("SELECT comment FROM `" . DB_PREFIX . "order_history` WHERE order_id = " . $orderId);
}
}
2 changes: 1 addition & 1 deletion src/svea/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "4.12.6"
"version": "4.12.7"
}

0 comments on commit 4ea2b3d

Please sign in to comment.