diff --git a/ChangeLog b/ChangeLog index 797dbaec627..a834607cdb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,8 @@ For developers: - New: Show version of client lib used by mysql drivers. - New: Add function to get content of an url (using all dolibarr setup like timeout, proxies...) - New: Upgrade lib of TCPDF to 6.0 +- New: Add property hidden into module descriptor to allow to hide a module according to + some dynamic conditions. ***** ChangeLog for 3.4 compared to 3.3.2 ***** diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 8fa37d04ecb..50676b17ec4 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -97,8 +97,10 @@ class modMyModule extends DolibarrModules $this->config_page_url = array("mysetuppage.php@mymodule"); // Dependencies + $this->hidden = false; // A condition to hide 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 $this->phpmin = array(5,0); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->langfiles = array("mylangfile@mymodule"); diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index acdf756eb86..45df64a5355 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -152,8 +152,9 @@ foreach ($modulesdir as $dir) $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod))); if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0; if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0; - //if ($mode == 'expdev' && ($objMod->version != 'experimental' && $objMod->version != 'development')) $modulequalified=0; - + // We discard modules according to property disabled + if (isset($objMod->hidden) && $objMod->hidden) $modulequalified=false; + // Define array $categ with categ with at least one qualified module if ($modulequalified) { diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 80b94a062d0..f8e10c858a9 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -39,6 +39,8 @@ class modCron extends DolibarrModules */ function __construct($db) { + global $langs,$conf; + $this->db = $db; $this->numero = 2300; @@ -65,8 +67,10 @@ class modCron extends DolibarrModules // Dependancies //------------- - $this->depends = array(); - $this->requiredby = array(); + $this->hidden = ! empty($conf->global->CRON_MODULE_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 $this->langfiles = array("cron@cron"); // Constantes