diff --git a/classes/Form/TechnicalChecklistForm.php b/classes/Form/TechnicalChecklistForm.php
index 25ee02ef..94131722 100644
--- a/classes/Form/TechnicalChecklistForm.php
+++ b/classes/Form/TechnicalChecklistForm.php
@@ -71,6 +71,8 @@ public function getDescription()
'accountConfigured' => $this->method == null ? false : $this->method->isConfigured(),
'sslActivated' => $this->module->isSslActive(),
'localizationUrl' => $this->context->link->getAdminLink('AdminLocalization', true),
+ 'numberRedundantFiles' => count($this->module->getRedundantFiles()),
+ 'diagnosticPage' => $this->context->link->getAdminLink('AdminPaypalDiagnostic', true),
];
if ($this->webhookOption->isEligibleContext()) {
diff --git a/controllers/admin/AdminPaypalDiagnostic.php b/controllers/admin/AdminPaypalDiagnostic.php
index e593a9e6..f23608cd 100644
--- a/controllers/admin/AdminPaypalDiagnostic.php
+++ b/controllers/admin/AdminPaypalDiagnostic.php
@@ -31,6 +31,7 @@
require_once _PS_MODULE_DIR_ . 'paypal/vendor/autoload.php';
+use PaypalAddons\services\ToolKit;
use PaypalPPBTlib\Extensions\Diagnostic\Controllers\Admin\AdminDiagnosticController;
class AdminPaypalDiagnosticController extends AdminDiagnosticController
@@ -40,4 +41,24 @@ public function initPageHeaderToolbar()
parent::initPageHeaderToolbar();
$this->context->smarty->clearAssign('help_link');
}
+
+ public function initContent()
+ {
+ $this->context->smarty->assign('isRedundantFileExist', count($this->module->getRedundantFiles()) > 0);
+ parent::initContent();
+ }
+
+ public function initProcess()
+ {
+ parent::initProcess();
+
+ if (Tools::isSubmit('remove_redundant_files')) {
+ $kit = new ToolKit();
+ $baseDir = _PS_MODULE_DIR_ . 'paypal/';
+
+ foreach ($this->module->getRedundantFiles() as $file) {
+ $kit->unlink($baseDir . $file);
+ }
+ }
+ }
}
diff --git a/paypal.php b/paypal.php
index 3a53cc5a..7622456e 100755
--- a/paypal.php
+++ b/paypal.php
@@ -71,6 +71,7 @@
use PaypalAddons\services\WebhookService;
use PaypalPPBTlib\Extensions\AbstractModuleExtension;
use PaypalPPBTlib\Extensions\Diagnostic\DiagnosticExtension;
+use PaypalPPBTlib\Extensions\Diagnostic\Stubs\Concrete\FileIntegrityStub;
use PaypalPPBTlib\Extensions\ProcessLogger\ProcessLoggerExtension;
use PaypalPPBTlib\Extensions\ProcessLogger\ProcessLoggerHandler;
use PaypalPPBTlib\Install\ModuleInstaller;
@@ -3089,4 +3090,32 @@ public function isConsiderGiftProductAsDiscount()
{
return version_compare(_PS_VERSION_, '1.7.4.4', '>=') && version_compare(_PS_VERSION_, '1.7.6', '<');
}
+
+ public function getDiagnosticSettings()
+ {
+ return include _PS_MODULE_DIR_ . 'paypal/diagnostic.php';
+ }
+
+ public function getRedundantFiles()
+ {
+ $diagnosticConf = $this->getDiagnosticSettings();
+
+ if (empty($diagnosticConf[0]['stubs'][FileIntegrityStub::class])) {
+ return [];
+ }
+
+ $stub = new FileIntegrityStub($diagnosticConf[0]['stubs'][FileIntegrityStub::class]);
+ $stub->setModule($this);
+ $response = $stub->getHandler()->handle();
+
+ if (empty($response['created'])) {
+ return [];
+ }
+
+ return array_filter(
+ $response['created'],
+ function ($file) {
+ return !preg_match('/^config_[a-z]+\.xml$/', $file) && $file !== 'config.xml';
+ });
+ }
}
diff --git a/services/Kit.php b/services/ToolKit.php
similarity index 99%
rename from services/Kit.php
rename to services/ToolKit.php
index 9b94187c..d9e7daf0 100644
--- a/services/Kit.php
+++ b/services/ToolKit.php
@@ -30,7 +30,7 @@
use Exception;
use Throwable;
-class Kit
+class ToolKit
{
public function rrmdir($dir)
{
diff --git a/translations/fr.php b/translations/fr.php
index cb2b70cd..ee7fbf43 100644
--- a/translations/fr.php
+++ b/translations/fr.php
@@ -190,6 +190,7 @@
$_MODULE['<{paypal}prestashop>statusblock_b0fb9d7e6d4ed47cb12f3092943fafc2'] = 'Le protocole SSL doit être activé sur votre site.';
$_MODULE['<{paypal}prestashop>statusblock_ba54b8645ec3d87e95b4da1b5baad66f'] = 'L\'extension cURL PHP doit être activée sur votre serveur.';
$_MODULE['<{paypal}prestashop>statusblock_5914be43ea057f2fd9fa49180f5db5bf'] = 'Vous devez vous connecter à votre compte PayPal.';
+$_MODULE['<{paypal}prestashop>statusblock_85e650a9b75ce606496731a086c28d0b'] = 'Vous avez des fichiers dans votre module PayPal qui ne sont pas présents dans le contenu officiel. Voir plus de détails sur [a @href1@]page de diagnostic.[/a]';
$_MODULE['<{paypal}prestashop>helperoptioninfo_36c23650a89439d28101b389567fe2f5'] = 'Les logs avec ID de commande ne seront pas effacés.';
$_MODULE['<{paypal}prestashop>headerlogo_536b624906878dc3954749a6cef3b0fa'] = 'Activation en 2 étapes simples';
$_MODULE['<{paypal}prestashop>headerlogo_e269d95cbf9105896810d64a7307acdd'] = 'Activez le module PayPal pour commencer à vendre à plus de 300 millions de clients PayPal dans le monde entier';
diff --git a/upgrade/Upgrade-6.4.3.php b/upgrade/Upgrade-6.4.3.php
index 478fe13f..e8a6235b 100644
--- a/upgrade/Upgrade-6.4.3.php
+++ b/upgrade/Upgrade-6.4.3.php
@@ -25,6 +25,8 @@
*
*/
+use PaypalPPBTlib\Extensions\Diagnostic\Stubs\Concrete\FileIntegrityStub;
+
if (!defined('_PS_VERSION_')) {
exit;
}
@@ -34,51 +36,35 @@
*
* @return bool
*/
-function upgrade_module_6_4_3($module)
+function upgrade_module_6_4_3(PayPal $module)
{
- $kit = new \PaypalAddons\services\Kit();
- $baseDir = _PS_ROOT_DIR_ . '/modules/paypal/';
- $dirs = [
- '_dev',
- 'classes/APM',
- 'views/templates/apm',
- 'views/templates/admin/_partials/paypalBanner',
- 'views/templates/admin/_partials/form/fields',
- ];
- $files = [
- 'controllers/admin/AdminPayPalCustomizeCheckoutController.php',
- 'controllers/admin/AdminPayPalHelpController.php',
- 'controllers/admin/AdminPayPalInstallmentController.php',
- 'controllers/admin/AdminPayPalLogsController.php',
- 'controllers/admin/AdminPayPalPUIListenerController.php',
- 'controllers/admin/AdminPayPalSetupController.php',
- 'controllers/admin/AdminPaypalGetCredentialsController.php',
- 'views/templates/admin/customizeCheckout.tpl',
- 'views/templates/admin/help.tpl',
- 'views/templates/admin/installment.tpl',
- 'views/templates/admin/setup.tpl',
- 'views/templates/admin/_partials/accountSettingsBlock.tpl',
- 'views/templates/admin/_partials/blockPreviewButtonContext.tpl',
- 'views/templates/admin/_partials/block_info.tpl',
- 'views/templates/admin/_partials/carrierMap.tpl',
- 'views/templates/admin/_partials/ecCredentialFields.tpl',
- 'views/templates/admin/_partials/headerLogo.tpl',
- 'views/templates/admin/_partials/helperOptionInfo.tpl',
- 'views/templates/admin/_partials/mbCredentialsForm.tpl',
- 'views/templates/admin/_partials/pppCredentialsForm.tpl',
- 'views/templates/admin/_partials/roundingSettings.tpl',
- 'views/templates/admin/_partials/switchSandboxBlock.tpl',
- 'views/templates/admin/_partials/white-list.tpl',
- 'views/templates/admin/_partials/form/colorDescriptions.tpl',
- 'views/templates/admin/_partials/form/customizeStyleSection.tpl',
- 'views/templates/admin/_partials/form/sectionTitle.tpl',
- ];
+ $baseDir = _PS_MODULE_DIR_ . 'paypal/';
+ $diagnosticConf = include _PS_MODULE_DIR_ . 'paypal/diagnostic.php';
+
+ if (empty($diagnosticConf[0]['stubs'][FileIntegrityStub::class])) {
+ return true;
+ }
- foreach ($dirs as $dir) {
- $kit->rrmdir($baseDir . $dir);
+ $stub = new FileIntegrityStub($diagnosticConf[0]['stubs'][FileIntegrityStub::class]);
+ $stub->setModule($module);
+ $response = $stub->getHandler()->handle();
+
+ if (empty($response['created'])) {
+ return true;
}
+
+ $files = array_filter(
+ $response['created'],
+ function ($file) {
+ return !preg_match('/^config_[a-z]+\.xml$/', $file) && $file !== 'config.xml';
+ });
+
foreach ($files as $file) {
- $kit->unlink($baseDir . $file);
+ try {
+ unlink($baseDir . $file);
+ } catch (Exception $e) {
+ } catch (Throwable $e) {
+ }
}
return true;
diff --git a/vendor/.htaccess b/vendor/.htaccess
new file mode 100644
index 00000000..3de9e400
--- /dev/null
+++ b/vendor/.htaccess
@@ -0,0 +1,10 @@
+# Apache 2.2
+