<?php
/**
* 2023 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
*  @author    Anvanto <anvantoco@gmail.com>
*  @copyright 2023 Anvanto
*  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*/

if (!defined('_PS_VERSION_')) {
    exit;
}

function upgrade_module_2_4_11($object)
{
    $object->anThemeFiles->createFoldersJsCss();
    @unlink(_PS_MODULE_DIR_ . 'an_theme/cfg/theme_colors.php');
    Tools::recurseCopy(_PS_MODULE_DIR_ . 'an_theme/cfg', $object->anThemeFiles->pathConfig, true);

    Tools::deleteDirectory(_PS_MODULE_DIR_ . 'an_theme/views/img/background');
    @unlink(_PS_MODULE_DIR_ . 'an_theme/views/img/fileType');
    @unlink(_PS_MODULE_DIR_ . 'an_theme/views/img/index.php');
    Tools::recurseCopy(_PS_MODULE_DIR_ . 'an_theme/views/img/', $object->anThemeFiles->pathImg);
    
    $list = glob(_PS_MODULE_DIR_ . 'an_theme/views/img/');
    foreach ($list as $file){
        $nameFile = basename($file);
        if ($nameFile != 'loading.svg' && $nameFile != 'index.php'){
            @unlink($file);
        }  
    }

    return true;
}