2017-08-30 11:37:48 +02:00

65 lines
2.3 KiB
PHP

<?php
/**
* TNT OFFICIAL MODULE FOR PRESTASHOP
*
* @author GFI Informatique <www.gfi.fr>
* @copyright 2016-2017 GFI Informatique, 2016-2017 TNT
* @license https://opensource.org/licenses/MIT MIT License
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_1_2_17($objArgTNTOfficiel_1_2_17)
{
$arrTemplateOverrideList = array(
array(
'fileName' => 'view.tpl',
'directorySrc' => 'views/templates/admin/override/controllers/admin/templates/orders/helpers/view/',
'directoryDst' => 'controllers/admin/templates/orders/helpers/view/',
),
);
//$strModuleDirSrc = _PS_MODULE_DIR_.$objTNTOfficiel->name.DIRECTORY_SEPARATOR;
$strModuleDirSrc = $objArgTNTOfficiel_1_2_17->getLocalPath();
foreach ($arrTemplateOverrideList as $arrTemplateOverride) {
$strPathTemplateSrc = $strModuleDirSrc.$arrTemplateOverride['directorySrc'];
$strFileTemplateSrc = $strPathTemplateSrc.$arrTemplateOverride['fileName'];
$strPathTemplateDst = _PS_OVERRIDE_DIR_.$arrTemplateOverride['directoryDst'];
$strFileTemplateDst = $strPathTemplateDst.$arrTemplateOverride['fileName'];
try {
// Create directory if unexist.
if (!is_dir($strPathTemplateDst)) {
mkdir($strPathTemplateDst, 0777, true);
}
// Delete previous template file if exist.
if (file_exists($strFileTemplateDst)) {
unlink($strFileTemplateDst);
}
// Copy new template file.
copy($strFileTemplateSrc, $strFileTemplateDst);
} catch (Exception $objException) {
$objFileLogger = new FileLogger();
$objFileLogger->setFilename(_PS_ROOT_DIR_.'/log/'.date('Ymd').'_tnt_exception.log');
$objFileLogger->logError($objException->getMessage());
return false;
}
}
// Reinstall Overrides: Module::uninstallOverrides() Module::installOverrides().
if (!($objArgTNTOfficiel_1_2_17->uninstallOverrides() && $objArgTNTOfficiel_1_2_17->installOverrides())) {
return false;
}
// Delete unused config.
if (!Configuration::deleteByName('TNT_CARRIER_CREDENTIALS_OK')) {
return false;
}
// Success.
return true;
}