<?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)
*/

class antheme 
{

    public static function updateConfigurations($configurations = [])
    {
        $languages = Language::getLanguages();

        foreach ($configurations as $key => $value){
            if (is_array($value)){
                $val = $value['0'];
                $value = [];
                foreach ($languages as $lang){
                    $value[$lang['id_lang']] = $val;
                }
            }
            Configuration::updateValue($key, $value);
        }
    }

	public static function changeStatusANThemeBlock($blockID, $status = 0)
    {
		if ($blockID == ''){
			return false;
		}
		
		Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'anthemeblock SET status = '.(int) $status.' WHERE block_identifier = "'.pSQL($blockID).'"');
		
		return true;
	} 
	
    public static function changeStatusANHomeProductsBlock($specialBlockID, $active = 0)
    {
		if ($specialBlockID == ''){
			return false;
		}
		
		Db::getInstance()->execute('
        UPDATE ' . _DB_PREFIX_ . 'an_homeproducts_blocks 
        SET active = '.(int) $active.' WHERE special_id_block = "'.pSQL($specialBlockID).'"
        ');
		
		return true;
	}    
    
	public static function changeStatusANHomeProductsBanner($specialBannerID, $active = 0)
    {
		if ($specialBannerID == ''){
			return false;
		}
		
		Db::getInstance()->execute('
        UPDATE ' . _DB_PREFIX_ . 'an_homeproducts_banners 
        SET active = '.(int) $active.' WHERE special_id_banner = "'.pSQL($specialBannerID).'"
        ');
		
		return true;
	}  

	public static function changeStatusANBanners($specialBannerID, $active = 0)
    {
		if ($specialBannerID == ''){
			return false;
		}
		
		Db::getInstance()->execute('
        UPDATE ' . _DB_PREFIX_ . 'an_banners 
        SET active = '.(int) $active.' WHERE special_id_banner = "'.pSQL($specialBannerID).'"
        ');
		
		return true;
	}  

    public static function clearCacheAn_homeproducts()
    {
        if (Module::isEnabled('an_homeproducts')){
            Module::getInstanceByName('an_homeproducts')->_clearCache('*');
        }
    }

}
?>