From e445392f2e47e0bd944febf05659ed4bc23da4e4 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 24 Mar 2022 12:05:59 +0100 Subject: [PATCH 1/4] Remove the deprecated method `Tools::jsonDecode` --- classes/APIFAQClass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/APIFAQClass.php b/classes/APIFAQClass.php index e1b81225..26044a86 100755 --- a/classes/APIFAQClass.php +++ b/classes/APIFAQClass.php @@ -46,7 +46,7 @@ public function getData($module_key, $version) return false; } /** @var object $content */ - $content = Tools::jsonDecode($content, true); + $content = json_decode($content, true); if (empty($content->categories)) { return false; } From 97443e469137f1aaf93f43573c8c4fde707cb886 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 24 Mar 2022 12:07:53 +0100 Subject: [PATCH 2/4] Bump version to 1.4.1 --- config.xml | 2 +- psgdpr.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.xml b/config.xml index 0fe97444..fa1a29de 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ psgdpr - + diff --git a/psgdpr.php b/psgdpr.php index 0d16ab5a..59102af9 100755 --- a/psgdpr.php +++ b/psgdpr.php @@ -119,7 +119,7 @@ public function __construct() // Settings $this->name = 'psgdpr'; $this->tab = 'administration'; - $this->version = '1.4.0'; + $this->version = '1.4.1'; $this->author = 'PrestaShop'; $this->need_instance = 0; From 27a4d4b4bba614d92a94b66e06a21912dc33588f Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 24 Mar 2022 12:14:06 +0100 Subject: [PATCH 3/4] Move create index in CREATE TABLE --- sql/install.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sql/install.php b/sql/install.php index de4312e6..f6835e97 100755 --- a/sql/install.php +++ b/sql/install.php @@ -48,12 +48,10 @@ `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_gdpr_log`), - INDEX (`id_customer`) + INDEX (`id_customer`), + INDEX `idx_id_customer` ( `id_customer`, `id_guest`, `client_name`, `id_module`, `date_add`, `date_upd`) ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;'; -$sql[] = ' ALTER TABLE `' . _DB_PREFIX_ . 'psgdpr_log` - ADD INDEX `idx_id_customer` ( `id_customer`, `id_guest`, `client_name`, `id_module`, `date_add`, `date_upd`); '; - foreach ($sql as $query) { if (Db::getInstance()->execute($query) == false) { return false; From 8813cc749572b42ef1792922ba076193786d500d Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Tue, 29 Mar 2022 12:45:54 +0200 Subject: [PATCH 4/4] Check if PS < 8.0.0 for fetching Referrers --- psgdpr.php | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/psgdpr.php b/psgdpr.php index 59102af9..aebd3e6a 100755 --- a/psgdpr.php +++ b/psgdpr.php @@ -766,7 +766,7 @@ public function getCustomerDataFromPrestashop(Customer $customer) $genderName = $gender->name; unset($gender); - $customerInfo = [ + $data['customerInfo'] = [ 'id_customer' => $customer->id, 'gender' => $genderName, 'firstname' => $customer->firstname, @@ -784,7 +784,7 @@ public function getCustomerDataFromPrestashop(Customer $customer) ]; // get orders - $orders = []; + $data['orders'] = []; $orderList = Order::getCustomerOrders($customer->id); if (count($orderList) >= 1) { @@ -793,7 +793,7 @@ public function getCustomerDataFromPrestashop(Customer $customer) $productsOrder = $orderObject->getProducts(); $currency = Currency::getCurrency($order['id_currency']); - array_push($orders, [ + $data['orders'][] = [ 'id_order' => $order['id_order'], 'reference' => $order['reference'], 'payment' => $order['payment'], @@ -803,22 +803,22 @@ public function getCustomerDataFromPrestashop(Customer $customer) 'total_paid_tax_incl' => number_format($order['total_paid_tax_incl'], 2) . ' ' . $currency['iso_code'], 'nb_products' => $order['nb_products'], 'products' => [], - ]); + ]; foreach ($productsOrder as $product) { - array_push($orders[$index]['products'], [ + $data['orders'][$index]['products'][] = [ 'id_product' => $product['product_id'], 'id_product_attribute' => $product['product_attribute_id'], 'product_reference' => $product['product_reference'], 'product_name' => $product['product_name'], 'product_quantity' => $product['product_quantity'], - ]); + ]; } unset($orderObject); } } // get carts - $carts = []; + $data['carts'] = []; $cartList = Cart::getCustomerCarts($customer->id, false); if (count($cartList) >= 1) { @@ -826,57 +826,51 @@ public function getCustomerDataFromPrestashop(Customer $customer) $cartObject = new Cart($cart['id_cart']); $productsCart = $cartObject->getProducts(); - array_push($carts, [ + $data['carts'][] = [ 'id_cart' => $cart['id_cart'], 'nb_products' => count($productsCart), 'products' => [], 'date_add' => $cart['date_add'], - ]); + ]; foreach ($productsCart as $product) { - array_push($carts[$index]['products'], [ + $data['carts'][$index]['products'][] = [ 'id_product' => $product['id_product'], 'id_product_attribute' => $product['id_product_attribute'], 'product_reference' => $product['reference'], 'product_name' => $product['name'], 'product_quantity' => $product['cart_quantity'], 'total_wt' => $product['total_wt'], - ]); + ]; } unset($cartObject); } } // get addresses - $addresses = $customer->getAddresses($id_lang); + $data['addresses'] = $customer->getAddresses($id_lang); // get messages - $messages = []; + $data['messages'] = []; $messageList = CustomerThread::getCustomerMessages($customer->id); if (count($messageList) >= 1) { foreach ($messageList as $index => $message) { - array_push($messages, [ + $data['messages'][] = [ 'id_customer_thread' => $message['id_customer_thread'], 'message' => $message['message'], 'ip' => (int) $message['ip_address'] == $message['ip_address'] ? long2ip((int) $message['ip_address']) : $message['ip_address'], 'date_add' => $message['date_add'], - ]); + ]; } } // get connections - $connections = $customer->getLastConnections(); + $data['connections'] = $customer->getLastConnections(); // get referrers - $referrer = Referrer::getReferrers($customer->id); - - $data['customerInfo'] = $customerInfo; - $data['orders'] = $orders; - $data['carts'] = $carts; - $data['addresses'] = $addresses; - $data['messages'] = $messages; - $data['connections'] = $connections; - $data['referrer'] = $referrer; + if (version_compare(_PS_VERSION_, '8.0.0', '<')) { + $data['referrer'] = Referrer::getReferrers($customer->id); + } return $data; }