NEW add property to show warnings when activating modules
This commit is contained in:
parent
d241adc201
commit
c962daabac
@ -235,6 +235,8 @@ $help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'
|
||||
llxHeader('',$langs->trans("Setup"),$help_url);
|
||||
|
||||
$arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers"));
|
||||
$arrayofwarnings=array(); // Array of warning each module want to show when activated
|
||||
$arrayofwarningsext=array(); // Array of warning each module want to show when we activate an external module
|
||||
|
||||
// Search modules dirs
|
||||
$modulesdir = dolGetModulesDirs();
|
||||
@ -266,7 +268,7 @@ foreach ($modulesdir as $dir)
|
||||
|
||||
if ($modName)
|
||||
{
|
||||
if (! empty($modNameLoaded[$modName]))
|
||||
if (! empty($modNameLoaded[$modName])) // In cache of already loaded modules ?
|
||||
{
|
||||
$mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
|
||||
setEventMessages($mesg, null, 'warnings');
|
||||
@ -297,7 +299,7 @@ foreach ($modulesdir as $dir)
|
||||
if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0;
|
||||
if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0;
|
||||
|
||||
// We discard modules according to property disabled
|
||||
// We discard modules according to property ->hidden
|
||||
if (! empty($objMod->hidden)) $modulequalified=0;
|
||||
|
||||
if ($modulequalified > 0)
|
||||
@ -321,8 +323,8 @@ foreach ($modulesdir as $dir)
|
||||
// Define array $categ with categ with at least one qualified module
|
||||
if ($modulequalified > 0)
|
||||
{
|
||||
$modules[$i] = $objMod;
|
||||
$filename[$i]= $modName;
|
||||
$modules[$modName] = $objMod;
|
||||
|
||||
$special = $objMod->special;
|
||||
|
||||
@ -342,6 +344,16 @@ foreach ($modulesdir as $dir)
|
||||
|
||||
if ($special == 1) $familykey='interface';
|
||||
|
||||
// Add list of warnings to show into arrayofwarnings and arrayofwarningsext
|
||||
if (! empty($objMod->warnings_activation))
|
||||
{
|
||||
$arrayofwarnings[$modName]=$objMod->warnings_activation;
|
||||
}
|
||||
if (! empty($objMod->warnings_activation_ext))
|
||||
{
|
||||
$arrayofwarningsext[$modName]=$objMod->warnings_activation_ext;
|
||||
}
|
||||
|
||||
$orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number
|
||||
$dirmod[$i] = $dir;
|
||||
//print $i.'-'.$dirmod[$i].'<br>';
|
||||
@ -484,7 +496,7 @@ if ($mode == 'common')
|
||||
$familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3];
|
||||
|
||||
$modName = $filename[$key];
|
||||
$objMod = $modules[$key];
|
||||
$objMod = $modules[$modName];
|
||||
$dirofmodule = $dirmod[$key];
|
||||
|
||||
$special = $objMod->special;
|
||||
@ -633,7 +645,7 @@ if ($mode == 'common')
|
||||
print "</td>\n";
|
||||
|
||||
// Activate/Disable and Setup (2 columns)
|
||||
if (! empty($conf->global->$const_name)) // If module is activated
|
||||
if (! empty($conf->global->$const_name)) // If module is already activated
|
||||
{
|
||||
$disableSetup = 0;
|
||||
|
||||
@ -699,12 +711,12 @@ if ($mode == 'common')
|
||||
}
|
||||
|
||||
}
|
||||
else // Module not activated
|
||||
else // Module not yet activated
|
||||
{
|
||||
print '<td align="center" valign="middle">';
|
||||
if (! empty($objMod->always_enabled))
|
||||
{
|
||||
// Ne devrait pas arriver.
|
||||
// Should never happened
|
||||
}
|
||||
else if (! empty($objMod->disabled))
|
||||
{
|
||||
@ -712,7 +724,34 @@ if ($mode == 'common')
|
||||
}
|
||||
else
|
||||
{
|
||||
// Module non actif
|
||||
// Module qualified for activation
|
||||
$warningmessage='';
|
||||
if (! empty($arrayofwarnings[$modName]))
|
||||
{
|
||||
print '<!-- This module has a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n";
|
||||
foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage)
|
||||
{
|
||||
$warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code);
|
||||
}
|
||||
}
|
||||
if ($objMod->isCoreOrExternalModule() == 'external' && ! empty($arrayofwarningsext))
|
||||
{
|
||||
print '<!-- This module is an external module and it may have a warning to show (note: your country is '.$mysoc->country_code.') -->'."\n";
|
||||
foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry)
|
||||
{
|
||||
if (! empty($modules[$keymodule]->const_name)) // If module that request warning is on
|
||||
{
|
||||
foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage)
|
||||
{
|
||||
if ($keycountry == 'always' || $keycountry == $mysoc->country_code)
|
||||
{
|
||||
$warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
print '<!-- Message to show: '.$warningmessage.' -->'."\n";
|
||||
print '<a class="reposition" href="modules.php?id='.$objMod->numero.'&module_position='.$module_position.'&action=set&value=' . $modName . '&mode=' . $mode . $param . '">';
|
||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||
print "</a>\n";
|
||||
|
||||
@ -779,16 +779,21 @@ function activateModule($value,$withdeps=1)
|
||||
{
|
||||
if (isset($objMod->depends) && is_array($objMod->depends) && ! empty($objMod->depends))
|
||||
{
|
||||
// Activation des modules dont le module depend
|
||||
$num = count($objMod->depends);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
// Activation of modules this module depends on
|
||||
// this->depends may be array('modModule1', 'mmodModule2') or array('always'=>"modModule1", 'FR'=>'modModule2')
|
||||
foreach ($objMod->depend as $key => $modulestring)
|
||||
{
|
||||
if ((! is_numeric($key)) && $key != 'always' && $key != $mysoc->country_code)
|
||||
{
|
||||
dol_syslog("We are not concerned by dependency with key=".$key." because our country is ".$mysoc->country_code);
|
||||
continue;
|
||||
}
|
||||
$activate = false;
|
||||
foreach ($modulesdir as $dir)
|
||||
{
|
||||
if (file_exists($dir.$objMod->depends[$i].".class.php"))
|
||||
if (file_exists($dir.$modulestring.".class.php"))
|
||||
{
|
||||
$resarray = activateModule($objMod->depends[$i]);
|
||||
$resarray = activateModule($modulestring);
|
||||
if (empty($resarray['errors'])){
|
||||
$activate = true;
|
||||
}else{
|
||||
@ -807,7 +812,7 @@ function activateModule($value,$withdeps=1)
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $objMod->depends[$i]);
|
||||
$ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $modulestring);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,11 +215,6 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
*/
|
||||
public $descriptionlong;
|
||||
|
||||
/**
|
||||
* @var string[] Module language files
|
||||
*/
|
||||
public $langfiles;
|
||||
|
||||
/**
|
||||
* @var string Module export code
|
||||
*/
|
||||
@ -291,6 +286,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
*/
|
||||
public $config_page_url;
|
||||
|
||||
|
||||
/**
|
||||
* @var string[] List of module class names that must be enabled if this module is enabled.
|
||||
*
|
||||
@ -309,6 +305,26 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
*/
|
||||
public $conflictwith;
|
||||
|
||||
/**
|
||||
* @var string[] Module language files
|
||||
*/
|
||||
public $langfiles;
|
||||
|
||||
/**
|
||||
* @var string[] Array of warnings to show when we activate the module
|
||||
*
|
||||
* array('always'='text') or array('FR'='text')
|
||||
*/
|
||||
public $warnings_activation;
|
||||
|
||||
/**
|
||||
* @var string[] Array of warnings to show when we activate an external module
|
||||
*
|
||||
* array('always'='text') or array('FR'='text')
|
||||
*/
|
||||
public $warnings_activation_ext;
|
||||
|
||||
|
||||
/**
|
||||
* @var array() Minimum version of PHP required by module.
|
||||
* e.g.: PHP ≥ 5.3 = array(5, 3)
|
||||
@ -326,6 +342,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
*/
|
||||
public $hidden = false;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor. Define names, constants, directories, boxes, permissions
|
||||
*
|
||||
|
||||
@ -67,7 +67,7 @@ class modCron extends DolibarrModules
|
||||
|
||||
// Dependancies
|
||||
//-------------
|
||||
$this->hidden = ! empty($conf->global->CRON_MODULE_DISABLED); // A condition to disable module
|
||||
$this->hidden = ! empty($conf->global->MODULE_CRON_DISABLED); // A condition to disable module
|
||||
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
|
||||
$this->requiredby = array(); // List of modules id to disable if this one is disabled
|
||||
$this->conflictwith = array(); // List of modules id this module is in conflict with
|
||||
|
||||
@ -64,11 +64,13 @@ class modFacture extends DolibarrModules
|
||||
$this->dirs = array("/facture/temp");
|
||||
|
||||
// Dependencies
|
||||
$this->depends = array("modSociete");
|
||||
$this->depends = array('always'=>"modSociete", 'FR'=>'modBlockChainLog');
|
||||
$this->requiredby = array("modComptabilite","modAccounting");
|
||||
$this->conflictwith = array();
|
||||
$this->langfiles = array("bills","companies","compta","products");
|
||||
|
||||
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
|
||||
$this->warnings_activation_ext = array('CA'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text')
|
||||
|
||||
// Config pages
|
||||
$this->config_page_url = array("facture.php");
|
||||
|
||||
@ -96,7 +98,8 @@ class modFacture extends DolibarrModules
|
||||
$this->const[$r][3] = "";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
|
||||
|
||||
// Boxes
|
||||
//$this->boxes = array(0=>array(1=>'box_factures_imp.php'),1=>array(1=>'box_factures.php'));
|
||||
$this->boxes = array(
|
||||
|
||||
@ -65,7 +65,7 @@ class modSkype extends DolibarrModules
|
||||
|
||||
// Dependancies
|
||||
//-------------
|
||||
$this->hidden = ! empty($conf->global->SKYPE_MODULE_DISABLED); // A condition to disable module
|
||||
$this->hidden = ! empty($conf->global->MODULE_SKYPE_DISABLED); // A condition to disable module
|
||||
$this->depends = array('modSociete'); // List of modules id that must be enabled if this module is enabled
|
||||
$this->requiredby = array(); // List of modules id to disable if this one is disabled
|
||||
$this->conflictwith = array(); // List of modules id this module is in conflict with
|
||||
|
||||
@ -67,7 +67,7 @@ class modWebsites extends DolibarrModules
|
||||
|
||||
// Dependancies
|
||||
//-------------
|
||||
$this->hidden = ! empty($conf->global->WEBSITE_MODULE_DISABLED); // A condition to disable module
|
||||
$this->hidden = ! empty($conf->global->MODULE_WEBSITE_DISABLED); // A condition to disable module
|
||||
$this->depends = array('modFckeditor'); // List of modules id that must be enabled if this module is enabled
|
||||
$this->requiredby = array(); // List of modules id to disable if this one is disabled
|
||||
$this->conflictwith = array(); // List of modules id this module is in conflict with
|
||||
|
||||
@ -1661,6 +1661,7 @@ ModuleEnabledAdminMustCheckRights=Module has been activated. Permissions for act
|
||||
UserHasNoPermissions=This user has no permission defined
|
||||
TypeCdr=Use "None" if the date of payment term is date of invoice plus a delta in days (delta is field "Nb of days")<br>Use "At end of month", if, after delta, the date must be increased to reach the end of month (+ an optional "Offset" in days)<br>Use "Current/Next" to have payment term date being the first Nth of the month (N is stored into field "Nb of days")
|
||||
BaseCurrency=Reference currency of the company (go into setup of company to change this)
|
||||
WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module <strong>%s</strong> that is an external module. Activate an external module only if it does not alterate negatively the behavior required by your country laws (%s). If the module bring a non legal feature, you are the only responsible for the use of a non-compliant software.
|
||||
##### Resource ####
|
||||
ResourceSetup=Configuration du module Resource
|
||||
UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list).
|
||||
|
||||
Loading…
Reference in New Issue
Block a user