NEW automatic activation of external module on country set
This commit is contained in:
parent
ad46bf9a94
commit
62cd77d999
@ -69,6 +69,7 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha'))
|
||||
|
||||
$s=$mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s,'chaine',0,'',$conf->entity);
|
||||
module_require_by_country($mysoc->country_code);
|
||||
}
|
||||
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom",'nohtml'),'chaine',0,'',$conf->entity);
|
||||
|
||||
@ -1132,6 +1132,82 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate external modules for country if neccessary
|
||||
*
|
||||
* @param string $country_code CountryCode
|
||||
* @return int 1
|
||||
*/
|
||||
function module_require_by_country($country_code)
|
||||
{
|
||||
global $db, $conf, $langs;
|
||||
|
||||
$modulesdir = dolGetModulesDirs();
|
||||
|
||||
foreach ($modulesdir as $dir)
|
||||
{
|
||||
// Load modules attributes in arrays (name, numero, orders) from dir directory
|
||||
dol_syslog("Scan directory ".$dir." for modules");
|
||||
$handle=@opendir(dol_osencode($dir));
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
|
||||
{
|
||||
$modName = substr($file, 0, dol_strlen($file) - 10);
|
||||
|
||||
if ($modName)
|
||||
{
|
||||
include_once $dir.$file;
|
||||
$objMod = new $modName($db);
|
||||
|
||||
if ($objMod->numero > 0)
|
||||
{
|
||||
$j = $objMod->numero;
|
||||
}
|
||||
else
|
||||
{
|
||||
$j = 1000 + $i;
|
||||
}
|
||||
|
||||
$modulequalified=1;
|
||||
|
||||
// We discard modules according to features level (PS: if module is activated we always show it)
|
||||
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
|
||||
|
||||
if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
|
||||
if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
|
||||
if(!empty($conf->global->$const_name)) $modulequalified=0; // already activated
|
||||
|
||||
if ($modulequalified)
|
||||
{
|
||||
// Load languages files of module
|
||||
if (isset($objMod->automatic_activation) && is_array($objMod->automatic_activation) && isset($objMod->automatic_activation[$country_code]))
|
||||
{
|
||||
|
||||
activateModule($modName);
|
||||
|
||||
setEventMessage($objMod->automatic_activation[$country_code],'warnings');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else dol_syslog("Module ".get_class($objMod)." not qualified");
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add external modules to list of contact element
|
||||
*
|
||||
|
||||
@ -73,6 +73,8 @@ class modBlockedLog extends DolibarrModules
|
||||
|
||||
$this->warnings_unactivation = array('FR'=>'BlockedLogAreRequiredByYourCountryLegislation');
|
||||
|
||||
$this->automatic_activation = array('FR'=>'BlockedLogActivatedBecauseRequiredByYourCountryLegislation');
|
||||
|
||||
// Constants
|
||||
//-----------
|
||||
|
||||
|
||||
@ -28,4 +28,5 @@ logDOC_DOWNLOAD=Download of a validated document in order to print or send
|
||||
DataOfArchivedEvent=Full datas of archived event
|
||||
ImpossibleToReloadObject=Object (type %s, id %s) removed
|
||||
BlockedLogAreRequiredByYourCountryLegislation=Unalterable logs are required by the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of non-legal software as it can not be validated by a tax audit.
|
||||
BlockedLogActivatedBecauseRequiredByYourCountryLegislation=Unalterable logs module was activated because of the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of non-legal software as it can not be validated by a tax audit.
|
||||
BlockedLogDisableNotAllowedForCountry=Disable not allowed for this countries
|
||||
Loading…
Reference in New Issue
Block a user