Skip to content
Snippets Groups Projects
Commit 26d102c7 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

New: A module can overwrite all default language files by forcing priority on...

New: A module can overwrite all default language files by forcing priority on langs directories on its own lang directory.
parent 1aa3409b
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,12 @@ For users: ...@@ -5,12 +5,12 @@ For users:
- New: Can add information on current user on odt generation - New: Can add information on current user on odt generation
- New: Prefix on third party is not used by default. Hidden option - New: Prefix on third party is not used by default. Hidden option
SOCIETE_USEPREFIX can restore old feature. SOCIETE_USEPREFIX can restore old feature.
- New: Standing orders module use bank account from banks module - New: Standing orders module use bank account from banks module.
- New: Ask password when creating a user from a contact - New: Ask password when creating a user from a contact.
For developers: For developers:
- New: External modules can add their own menu manager - New: External modules can add their own menu manager.
- New: External modules can remove tabs - New: External modules can remove tabs.
- New: A module can overwrite all default language files by forcing - New: A module can overwrite all default language files by forcing
priority on langs directories on its own lang directory. priority on langs directories on its own lang directory.
......
...@@ -88,15 +88,16 @@ class modMyModule extends DolibarrModules ...@@ -88,15 +88,16 @@ class modMyModule extends DolibarrModules
// Dependencies // Dependencies
$this->depends = array(); // List of modules id that must be enabled if this module is enabled $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->requiredby = array(); // List of modules id to disable if this one is disabled
$this->phpmin = array(4,3); // Minimum version of PHP required by module $this->phpmin = array(5,0); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(2,5); // Minimum version of Dolibarr required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module
$this->langfiles = array("langfiles@mymodule"); $this->langfiles = array("langfiles@mymodule");
// Constants // Constants
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
// 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',1) // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',1)
$this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') $this->const = array();
// Array to add new pages in new tabs // Array to add new pages in new tabs
// Example: $this->tabs = array('objecttype:+tabname1:Title1:@mymodule:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab // Example: $this->tabs = array('objecttype:+tabname1:Title1:@mymodule:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab
......
...@@ -55,8 +55,8 @@ class DolibarrModules ...@@ -55,8 +55,8 @@ class DolibarrModules
/** /**
* \brief Constructeur * Constructor
* \param DB handler d'acces base * @param DB Database access handler
*/ */
function DolibarrModules($DB) function DolibarrModules($DB)
{ {
...@@ -66,10 +66,10 @@ class DolibarrModules ...@@ -66,10 +66,10 @@ class DolibarrModules
/** /**
* \brief Fonction d'activation. Insere en base les constantes et boites du module * Fonction d'activation. Insere en base les constantes et boites du module
* \param array_sql Tableau de requete sql a executer a l'activation * @param array_sql Tableau de requete sql a executer a l'activation
* \param options Options when enabling module ('', 'noboxes') * @param options Options when enabling module ('', 'noboxes')
* \return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
function _init($array_sql, $options='') function _init($array_sql, $options='')
{ {
...@@ -96,7 +96,7 @@ class DolibarrModules ...@@ -96,7 +96,7 @@ class DolibarrModules
// Insert activation login method // Insert activation login method
if (! $err) $err+=$this->insert_login_method(); if (! $err) $err+=$this->insert_login_method();
// Insere les constantes associees au module dans llx_const // Insert constant defined by modules, into llx_const
if (! $err) $err+=$this->insert_const(); if (! $err) $err+=$this->insert_const();
// Insere les boites dans llx_boxes_def // Insere les boites dans llx_boxes_def
...@@ -164,10 +164,10 @@ class DolibarrModules ...@@ -164,10 +164,10 @@ class DolibarrModules
} }
/** /**
* \brief Fonction de desactivation. Supprime de la base les constantes et boites du module * Fonction de desactivation. Supprime de la base les constantes et boites du module
* \param array_sql tableau de requete sql a executer a la desactivation * @param array_sql tableau de requete sql a executer a la desactivation
* \param options Options when disabling module ('', 'noboxes') * @param options Options when disabling module ('', 'noboxes')
* \return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
function _remove($array_sql, $options='') function _remove($array_sql, $options='')
{ {
...@@ -194,6 +194,9 @@ class DolibarrModules ...@@ -194,6 +194,9 @@ class DolibarrModules
// Remove activation of module's authentification method (MAIN_MODULE_MYMODULE_LOGIN_METHOD in llx_const) // Remove activation of module's authentification method (MAIN_MODULE_MYMODULE_LOGIN_METHOD in llx_const)
if (! $err) $err+=$this->delete_login_method(); if (! $err) $err+=$this->delete_login_method();
// Remove constants defined by modules
if (! $err) $err+=$this->delete_const();
// Remove list of module's available boxes (entry in llx_boxes) // Remove list of module's available boxes (entry in llx_boxes)
if (! $err && $options != 'noboxes') $err+=$this->delete_boxes(); if (! $err && $options != 'noboxes') $err+=$this->delete_boxes();
...@@ -418,8 +421,8 @@ class DolibarrModules ...@@ -418,8 +421,8 @@ class DolibarrModules
/** /**
* \brief Insert constant to activate module * Insert constant to activate module
* \return int Nb of errors (0 if OK) * @return int Nb of errors (0 if OK)
*/ */
function _active() function _active()
{ {
...@@ -453,8 +456,8 @@ class DolibarrModules ...@@ -453,8 +456,8 @@ class DolibarrModules
/** /**
* \brief Remove activation line * Remove activation line
* \return int Nb of errors (0 if OK) * @return int Nb of errors (0 if OK)
**/ **/
function _unactive() function _unactive()
{ {
...@@ -807,8 +810,8 @@ class DolibarrModules ...@@ -807,8 +810,8 @@ class DolibarrModules
} }
/** /**
* \brief Insert constants defined into $this->const array into table llx_const * Insert constants defined into $this->const array into table llx_const
* \return int Number of errors (0 if OK) * @return int Number of errors (0 if OK)
*/ */
function insert_const() function insert_const()
{ {
...@@ -823,7 +826,7 @@ class DolibarrModules ...@@ -823,7 +826,7 @@ class DolibarrModules
$val = $this->const[$key][2]; $val = $this->const[$key][2];
$note = isset($this->const[$key][3])?$this->const[$key][3]:''; $note = isset($this->const[$key][3])?$this->const[$key][3]:'';
$visible = isset($this->const[$key][4])?$this->const[$key][4]:0; $visible = isset($this->const[$key][4])?$this->const[$key][4]:0;
$entity = ! empty($this->const[$key][5])?0:$conf->entity; $entity = (! empty($this->const[$key][5]) && $this->const[$key][5]!='current')?0:$conf->entity;
// Clean // Clean
if (empty($visible)) $visible='0'; if (empty($visible)) $visible='0';
...@@ -873,6 +876,39 @@ class DolibarrModules ...@@ -873,6 +876,39 @@ class DolibarrModules
return $err; return $err;
} }
/**
* Remove constants with tags deleteonunactive
* @return int <0 if KO, 0 if OK
*/
function delete_const()
{
global $conf;
$err=0;
foreach ($this->const as $key => $value)
{
$name = $this->const[$key][0];
$deleteonunactive = (! empty($this->const[$key][6]))?1:0;
if ($deleteonunactive)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
$sql.= " WHERE ".$this->db->decrypt('name')." = '".$name."'";
$sql.= " AND entity in (0, ".$conf->entity.")";
dol_syslog("DolibarrModules::delete_const sql=".$sql);
if (! $this->db->query($sql))
{
$this->error=$this->db->lasterror();
dol_syslog("DolibarrModules::delete_const ".$this->error, LOG_ERR);
$err++;
}
}
}
return $err;
}
/** /**
* \brief Insert permissions definitions related to the module into llx_rights_def * \brief Insert permissions definitions related to the module into llx_rights_def
* \param $reinitadminperms If 1, we also grant them to admin user * \param $reinitadminperms If 1, we also grant them to admin user
...@@ -975,8 +1011,8 @@ class DolibarrModules ...@@ -975,8 +1011,8 @@ class DolibarrModules
/** /**
\brief Supprime les permissions * \brief Supprime les permissions
\return int Nombre d'erreurs (0 si ok) * \return int Nombre d'erreurs (0 si ok)
*/ */
function delete_permissions() function delete_permissions()
{ {
...@@ -991,7 +1027,7 @@ class DolibarrModules ...@@ -991,7 +1027,7 @@ class DolibarrModules
if (! $this->db->query($sql)) if (! $this->db->query($sql))
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog("DolibarrModules::delete_dirs ".$this->error, LOG_ERR); dol_syslog("DolibarrModules::delete_permissions ".$this->error, LOG_ERR);
$err++; $err++;
} }
...@@ -1000,8 +1036,8 @@ class DolibarrModules ...@@ -1000,8 +1036,8 @@ class DolibarrModules
/** /**
* \brief Insere les menus dans llx_menu* * \brief Insert menus entries into llx_menu*
* \return int Nombre d'erreurs (0 si ok) * \return int Nb of errors (0 if OK)
*/ */
function insert_menus() function insert_menus()
{ {
...@@ -1299,8 +1335,8 @@ class DolibarrModules ...@@ -1299,8 +1335,8 @@ class DolibarrModules
} }
/** /**
* \brief Insert activation login method from modules in llx_const * Insert activation login method from modules in llx_const
* \return int Number of errors (0 if ok) * @return int Number of errors (0 if ok)
*/ */
function insert_login_method() function insert_login_method()
{ {
...@@ -1339,8 +1375,8 @@ class DolibarrModules ...@@ -1339,8 +1375,8 @@ class DolibarrModules
} }
/** /**
* \brief Remove activation login method from modules in llx_const * Remove activation login method from modules in llx_const
* \return int Nombre d'erreurs (0 si ok) * @return int Nombre d'erreurs (0 si ok)
*/ */
function delete_login_method() function delete_login_method()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment