From 90e98c9c4727e1ba264b9b1f752aa5a0a317c7a9 Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Fri, 23 Jun 2023 15:37:27 +0200 Subject: [PATCH] Corrections --- admin/class/data/eCommerceDict.class.php | 12 ++++++++---- admin/order.php | 3 +-- admin/product.php | 3 +-- admin/stock.php | 3 +-- admin/tpl/extrafields.tpl.php | 3 ++- class/data/eCommercePaymentGateways.class.php | 9 ++++----- class/data/eCommerceRemoteAccess.class.php | 8 +++----- .../eCommerceRemoteAccessWoocommerce.class.php | 12 +++++++++--- includes/oauth-subscriber-woocommerce/src/Oauth1.php | 6 ++---- 9 files changed, 31 insertions(+), 28 deletions(-) diff --git a/admin/class/data/eCommerceDict.class.php b/admin/class/data/eCommerceDict.class.php index 7b1a64d..fdc8155 100644 --- a/admin/class/data/eCommerceDict.class.php +++ b/admin/class/data/eCommerceDict.class.php @@ -107,7 +107,8 @@ public function search($keys) if (is_array($keys) && count($keys) > 0) { $fields = array(); foreach ($keys as $field => $value) { - switch (isset($value['type'])) { + $type = isset($value['type']) ? $value['type'] : ''; + switch ($type) { case 'string': $key = "= '".$this->db->escape($value['value'])."'"; break; @@ -148,7 +149,8 @@ public function update($values, $keys) if (is_array($values) && count($values) > 0) { $fields = array(); foreach ($values as $field => $value) { - switch (isset($value['type'])) { + $type = isset($value['type']) ? $value['type'] : ''; + switch ($type) { case 'string': $key = "= '" . $this->db->escape($value['value']) . "'"; break; @@ -166,7 +168,8 @@ public function update($values, $keys) if (is_array($keys) && count($keys) > 0) { $fields = array(); foreach ($keys as $field => $value) { - switch (isset($value['type'])) { + $type = isset($value['type']) ? $value['type'] : ''; + switch ($type) { case 'string': $key = "= '" . $this->db->escape($value['value']) . "'"; break; @@ -205,7 +208,8 @@ public function insert($fields, $values) if (is_array($values) && count($values) > 0) { foreach ($fields as $field) { if (isset($values[$field])) { - switch ($values[$field]['type']) { + $type = isset($values[$field]['type']) ? $values[$field]['type'] : ''; + switch ($type) { case 'string': $values_list[] = "'" . $this->db->escape($values[$field]['value']) . "'"; break; diff --git a/admin/order.php b/admin/order.php index d0aeea1..fc8dd53 100644 --- a/admin/order.php +++ b/admin/order.php @@ -267,14 +267,13 @@ )); $formconfirm = ''; -$lineid = ''; if ($action == 'synchronize_payment_gateways') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ECommerceUpdatePaymentGateways'), $langs->trans('ECommerceConfirmUpdatePaymentGateways'), 'confirm_synchronize_payment_gateways', '', 0, 1, 200, 800); } // Call Hook formConfirm -$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); +$parameters = array('formConfirm' => $formconfirm); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $formconfirm .= $hookmanager->resPrint; diff --git a/admin/product.php b/admin/product.php index 085ed74..9b9171b 100644 --- a/admin/product.php +++ b/admin/product.php @@ -265,7 +265,6 @@ )); $formconfirm = ''; -$lineid = ''; if ($action == 'synchronize_attributes') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ECommerceWoocommerceUpdateDictAttributes'), $langs->trans('ECommerceWoocommerceConfirmUpdateDictAttributes'), 'confirm_synchronize_attributes', '', 0, 1, 200, 800); @@ -276,7 +275,7 @@ } // Call Hook formConfirm -$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); +$parameters = array('formConfirm' => $formconfirm); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $formconfirm .= $hookmanager->resPrint; diff --git a/admin/stock.php b/admin/stock.php index 920ea18..c655a9c 100644 --- a/admin/stock.php +++ b/admin/stock.php @@ -137,14 +137,13 @@ llxHeader('', $langs->trans("ECommerceSetup"), $wikihelp); $formconfirm = ''; -$lineid = ''; if ($action == 'update_remote_warehouses' && !empty($object->parameters['enable_warehouse_plugin_sl_support'])) { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&plugin=' . $plugin, $langs->trans('ECommerceUpdateRemoteWarehouses'), $langs->trans('ECommerceConfirmUpdateRemoteWarehouses'), 'confirm_update_remote_warehouses', '', 0, 1, 200, 800); } // Call Hook formConfirm -$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); +$parameters = array('formConfirm' => $formconfirm); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $formconfirm .= $hookmanager->resPrint; diff --git a/admin/tpl/extrafields.tpl.php b/admin/tpl/extrafields.tpl.php index 0542c88..8564ded 100644 --- a/admin/tpl/extrafields.tpl.php +++ b/admin/tpl/extrafields.tpl.php @@ -82,8 +82,9 @@ if (!empty($info['default'])) { $not_supported = in_array($extrafields->attributes[$table_element]['type'][$key], [ 'date', 'datetime' ]); + $default_value = ''; if (isset($extrafields->attributes[$table_element]['default'][$key])) $default_value = $extrafields->attributes[$table_element]['default'][$key]; - $value = isset($values_info['dft'][$key]) ? $values_info['dft'][$key] : isset($default_value); + $value = isset($values_info['dft'][$key]) ? $values_info['dft'][$key] : $default_value; $activated = !empty($activated_info['dft'][$key]); print '' . "\n"; if ($not_supported) { diff --git a/class/data/eCommercePaymentGateways.class.php b/class/data/eCommercePaymentGateways.class.php index 4558b0c..a4bcb71 100755 --- a/class/data/eCommercePaymentGateways.class.php +++ b/class/data/eCommercePaymentGateways.class.php @@ -92,9 +92,9 @@ public function set($site_id, $payment_gateways) $sql .= ', ' . ($infos['payment_mode_id'] > 0 ? $infos['payment_mode_id'] : 'NULL'); $sql .= ', ' . ($infos['bank_account_id'] > 0 ? $infos['bank_account_id'] : 'NULL'); $sql .= ', ' . (!empty($infos['create_invoice_payment']) ? 1 : 'NULL'); - $sql .= ', ' . (!empty($infos['mail_model_for_send_invoice']) > 0 ? $infos['mail_model_for_send_invoice'] : 'NULL'); + $sql .= ', ' . (!empty($infos['mail_model_for_send_invoice']) && $infos['mail_model_for_send_invoice'] > 0 ? $infos['mail_model_for_send_invoice'] : 'NULL'); $sql .= ', ' . ($infos['supplier_id'] > 0 ? $infos['supplier_id'] : 'NULL'); - $sql .= ', ' . (!empty($infos['product_id_for_fee']) > 0 ? $infos['product_id_for_fee'] : 'NULL'); + $sql .= ', ' . (!empty($infos['product_id_for_fee']) && $infos['product_id_for_fee'] > 0 ? $infos['product_id_for_fee'] : 'NULL'); $sql .= ', ' . (!empty($infos['create_supplier_invoice_payment']) ? 1 : 'NULL'); $sql .= ', ' . $conf->entity; $sql .= ')'; @@ -106,10 +106,9 @@ public function set($site_id, $payment_gateways) $sql .= ', payment_mode_id = ' . ($infos['payment_mode_id'] > 0 ? $infos['payment_mode_id'] : 'NULL'); $sql .= ', bank_account_id = ' . ($infos['bank_account_id'] > 0 ? $infos['bank_account_id'] : 'NULL'); $sql .= ', create_invoice_payment = ' . (!empty($infos['create_invoice_payment']) ? 1 : 'NULL'); - $sql .= ', mail_model_for_send_invoice = ' . (!empty($infos['mail_model_for_send_invoice']) > 0 ? $infos['mail_model_for_send_invoice'] : 'NULL'); + $sql .= ', mail_model_for_send_invoice = ' . (!empty($infos['mail_model_for_send_invoice']) && $infos['mail_model_for_send_invoice'] > 0 ? $infos['mail_model_for_send_invoice'] : 'NULL'); $sql .= ', supplier_id = ' . ($infos['supplier_id'] > 0 ? $infos['supplier_id'] : 'NULL'); - // $sql .= ', product_id_for_fee = ' . ($infos['product_id_for_fee'] > 0 ? $infos['product_id_for_fee'] : 'NULL'); - $sql .= ', product_id_for_fee = ' . (!empty($infos['product_id_for_fee']) > 0 ? $infos['product_id_for_fee'] : 'NULL'); + $sql .= ', product_id_for_fee = ' . (!empty($infos['product_id_for_fee']) && $infos['product_id_for_fee'] > 0 ? $infos['product_id_for_fee'] : 'NULL'); $sql .= ', create_supplier_invoice_payment = ' . (!empty($infos['create_supplier_invoice_payment']) ? 1 : 'NULL'); $sql .= ' WHERE site_id = ' . $site_id; $sql .= " AND payment_gateway_id = '" . $this->db->escape($payment_gateway_id) . "'"; diff --git a/class/data/eCommerceRemoteAccess.class.php b/class/data/eCommerceRemoteAccess.class.php index 3961aed..72d46dc 100644 --- a/class/data/eCommerceRemoteAccess.class.php +++ b/class/data/eCommerceRemoteAccess.class.php @@ -29,8 +29,8 @@ class eCommerceRemoteAccess private $class; private $db; - var $error; - var $errors; + public $error; + public $errors; /** * Class for access remote sites @@ -74,9 +74,7 @@ private function setClass() public function connect() { $result = $this->class->connect(); - // $this->error=$this->class->error; - $error = 0; - $this->error=$error; + $this->error=$this->class->error; $this->errors=$this->class->errors; return $result; } diff --git a/class/data/woocommerce/eCommerceRemoteAccessWoocommerce.class.php b/class/data/woocommerce/eCommerceRemoteAccessWoocommerce.class.php index 9f389e9..c9ab9f2 100755 --- a/class/data/woocommerce/eCommerceRemoteAccessWoocommerce.class.php +++ b/class/data/woocommerce/eCommerceRemoteAccessWoocommerce.class.php @@ -91,6 +91,13 @@ class eCommerceRemoteAccessWoocommerce */ private $db; + /** + * Error. + * + * @var string + */ + public $error; + /** * Errors list. * @@ -98,8 +105,6 @@ class eCommerceRemoteAccessWoocommerce */ public $errors; - public $error; - /** * GMT timezone. * @@ -160,7 +165,8 @@ function __construct($db, $site) $this->db = $db; $this->site = $site; - $this->errors = []; + $this->error = ''; + $this->errors = []; $this->gmtTimeZone = new DateTimeZone('GMT'); $this->currentTimeZone = new DateTimeZone(date_default_timezone_get()); diff --git a/includes/oauth-subscriber-woocommerce/src/Oauth1.php b/includes/oauth-subscriber-woocommerce/src/Oauth1.php index c2c2f26..f91ca02 100644 --- a/includes/oauth-subscriber-woocommerce/src/Oauth1.php +++ b/includes/oauth-subscriber-woocommerce/src/Oauth1.php @@ -248,11 +248,9 @@ private function signUsingHmac($algo, $baseString) $key = rawurlencode($this->config['consumer_secret']); // Add token only if present to avoid wrong encoding due to the superflous ampersand (&) - // if((isset($this->config['token_secret']) && !empty($this->config['token_secret'])) || !\in_array($this->apiVersion, ['v1', 'v2'])) { - if((isset($this->config['token_secret']) && !empty($this->config['token_secret'])) || !\in_array($this->config['api_version'], ['v1', 'v2'])) { - // $key .= '&' . rawurlencode($this->config['token_secret']); - $key .= '&' . rawurlencode(isset($this->config['token_secret']) && !empty($this->config['token_secret'])); + $token = !empty($this->config['token_secret']) ? $this->config['token_secret'] : ''; + $key .= '&' . rawurlencode($token); } return hash_hmac($algo, $baseString, $key, true);