Qual: Default usage to create dir when enabling module is the "simple" mode (we declare only the directory).
This commit is contained in:
parent
524f01348c
commit
7697a914d1
@ -69,20 +69,9 @@ class modMyModule extends DolibarrModules
|
|||||||
$this->picto='generic';
|
$this->picto='generic';
|
||||||
|
|
||||||
// Data directories to create when module is enabled.
|
// Data directories to create when module is enabled.
|
||||||
|
// Example: this->dirs = array("/mymodule/temp");
|
||||||
$this->dirs = array();
|
$this->dirs = array();
|
||||||
$r=0;
|
$r=0;
|
||||||
|
|
||||||
//$this->dirs[$r][0] = "output";
|
|
||||||
//$this->dirs[$r][1] = "/mymodule";
|
|
||||||
//$this->dirs[$r][2] = 1; // Create constante in database if different of "output" and "temp" (ex: MAIN_MODULE_MYMODULE_DIR_OUTPUT)
|
|
||||||
//$this->dirs[$r][3] = "submodule"; // Add submodule name (ex: $conf->mymodule->submodule->dir_output)
|
|
||||||
//$this->dirs[$r][4] = "newmodulename"; // Change the module name if different (ex: $conf->newmodulename->dir_output)
|
|
||||||
//$r++;
|
|
||||||
//$this->dirs[$r][0] = "temp";
|
|
||||||
//$this->dirs[$r][1] = "/mymodule/temp";
|
|
||||||
//$this->dirs[$r][2] = 1; // Create constante in database if different of "output" and "temp" (ex: MAIN_MODULE_MYMODULE_DIR_TEMP)
|
|
||||||
//$this->dirs[$r][3] = "submodule"; // Add submodule name (ex: $conf->mymodule->submodule->dir_temp)
|
|
||||||
//$this->dirs[$r][4] = "newmodulename"; // Change the module name if different (ex: $conf->newmodulename->dir_temp)
|
|
||||||
|
|
||||||
// Relative path to module style sheet if exists. Example: '/mymodule/mycss.css'.
|
// Relative path to module style sheet if exists. Example: '/mymodule/mycss.css'.
|
||||||
$this->style_sheet = '';
|
$this->style_sheet = '';
|
||||||
|
|||||||
@ -107,7 +107,8 @@ class Conf
|
|||||||
$this->tabs_modules[$params[0]][]=$value;
|
$this->tabs_modules[$params[0]][]=$value;
|
||||||
//print 'xxx'.$params[0].'-'.$value;
|
//print 'xxx'.$params[0].'-'.$value;
|
||||||
}
|
}
|
||||||
// If this is constant for module directories
|
// If this is constant to force a module directories (used to manage some exceptions)
|
||||||
|
// Should not be used by modules
|
||||||
if (eregi('^MAIN_MODULE_([A-Z_]+)_DIR_',$key,$reg) && $value)
|
if (eregi('^MAIN_MODULE_([A-Z_]+)_DIR_',$key,$reg) && $value)
|
||||||
{
|
{
|
||||||
$module=strtolower($reg[1]);
|
$module=strtolower($reg[1]);
|
||||||
@ -116,7 +117,7 @@ class Conf
|
|||||||
{
|
{
|
||||||
$dir_name = "dir_".strtolower($reg[2]);
|
$dir_name = "dir_".strtolower($reg[2]);
|
||||||
$submodule = strtolower($reg[1]);
|
$submodule = strtolower($reg[1]);
|
||||||
$this->$module->$submodule->$dir_name = $value;
|
$this->$module->$submodule->$dir_name = $value; // We put only dir name. We will add DOL_DATA_ROOT later
|
||||||
//print '->'.$module.'->'.$submodule.'->'.$dir_name.' = '.$this->$module->$submodule->$dir_name.'<br>';
|
//print '->'.$module.'->'.$submodule.'->'.$dir_name.' = '.$this->$module->$submodule->$dir_name.'<br>';
|
||||||
}
|
}
|
||||||
else if (eregi('_DIR_([A-Z]+)$',$key,$reg))
|
else if (eregi('_DIR_([A-Z]+)$',$key,$reg))
|
||||||
@ -167,6 +168,13 @@ class Conf
|
|||||||
// If multicompany module is enabled, we redefine the root of data
|
// If multicompany module is enabled, we redefine the root of data
|
||||||
if (! empty($this->global->MAIN_MODULE_MULTICOMPANY) && ! empty($this->entity)) $rootfordata.='/'.$this->entity;
|
if (! empty($this->global->MAIN_MODULE_MULTICOMPANY) && ! empty($this->entity)) $rootfordata.='/'.$this->entity;
|
||||||
|
|
||||||
|
// For backward compatibility
|
||||||
|
// TODO Remove params this->xxx->enabled. Must be replaced by conf->global->MAIN_MODULE_XXX
|
||||||
|
$this->comptaexpert->enabled=defined("MAIN_MODULE_COMPTABILITE_EXPERT")?MAIN_MODULE_COMPTABILITE_EXPERT:0;
|
||||||
|
$this->compta->enabled=defined("MAIN_MODULE_COMPTABILITE")?MAIN_MODULE_COMPTABILITE:0;
|
||||||
|
$this->webcal->enabled=defined('MAIN_MODULE_WEBCALENDAR')?MAIN_MODULE_WEBCALENDAR:0;
|
||||||
|
$this->propal->enabled=defined("MAIN_MODULE_PROPALE")?MAIN_MODULE_PROPALE:0;
|
||||||
|
|
||||||
// Define default dir_output and dir_temp for directories of modules
|
// Define default dir_output and dir_temp for directories of modules
|
||||||
foreach($this->modules as $module)
|
foreach($this->modules as $module)
|
||||||
{
|
{
|
||||||
@ -176,19 +184,13 @@ class Conf
|
|||||||
else $this->$module->dir_temp=$rootfordata.$this->$module->dir_temp;
|
else $this->$module->dir_temp=$rootfordata.$this->$module->dir_temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For backward compatibility
|
|
||||||
$this->comptaexpert->enabled=defined("MAIN_MODULE_COMPTABILITE_EXPERT")?MAIN_MODULE_COMPTABILITE_EXPERT:0;
|
|
||||||
$this->compta->enabled=defined("MAIN_MODULE_COMPTABILITE")?MAIN_MODULE_COMPTABILITE:0;
|
|
||||||
$this->webcal->enabled=defined('MAIN_MODULE_WEBCALENDAR')?MAIN_MODULE_WEBCALENDAR:0;
|
|
||||||
$this->propal->enabled=defined("MAIN_MODULE_PROPALE")?MAIN_MODULE_PROPALE:0;
|
|
||||||
|
|
||||||
// Exception: Some dir are not the name of module. So we keep exception here
|
// Exception: Some dir are not the name of module. So we keep exception here
|
||||||
// for backward compatibility.
|
// for backward compatibility.
|
||||||
|
|
||||||
// Module user
|
// Module user
|
||||||
$this->user->dir_output=$rootfordata."/users";
|
$this->user->dir_output=$rootfordata."/users";
|
||||||
$this->user->dir_temp=$rootfordata."/users/temp";
|
$this->user->dir_temp=$rootfordata."/users/temp";
|
||||||
|
|
||||||
// Module RSS
|
// Module RSS
|
||||||
$this->externalrss->dir_output=$rootfordata."/rss";
|
$this->externalrss->dir_output=$rootfordata."/rss";
|
||||||
$this->externalrss->dir_temp=$rootfordata."/rss/temp";
|
$this->externalrss->dir_temp=$rootfordata."/rss/temp";
|
||||||
@ -223,8 +225,6 @@ class Conf
|
|||||||
$this->fournisseur->commande->dir_temp =$rootfordata."/fournisseur/commande/temp";
|
$this->fournisseur->commande->dir_temp =$rootfordata."/fournisseur/commande/temp";
|
||||||
$this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture";
|
$this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture";
|
||||||
$this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp";
|
$this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp";
|
||||||
// Module produit
|
|
||||||
$this->produit->MultiPricesEnabled=defined("PRODUIT_MULTIPRICES")?PRODUIT_MULTIPRICES:0;
|
|
||||||
// Module service
|
// Module service
|
||||||
$this->service->dir_output=$rootfordata."/produit";
|
$this->service->dir_output=$rootfordata."/produit";
|
||||||
$this->service->dir_temp =$rootfordata."/produit/temp";
|
$this->service->dir_temp =$rootfordata."/produit/temp";
|
||||||
@ -364,8 +364,8 @@ class Conf
|
|||||||
$this->global->MAIN_GRAPH_LIBRARY = 'artichow';
|
$this->global->MAIN_GRAPH_LIBRARY = 'artichow';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format de la date
|
// Format for date
|
||||||
// \todo Mettre les 4 formats dans fichier langue
|
// TODO Mettre les formats dans fichier langue
|
||||||
$this->format_date_short="%d/%m/%Y";
|
$this->format_date_short="%d/%m/%Y";
|
||||||
$this->format_hour_short="%H:%M";
|
$this->format_hour_short="%H:%M";
|
||||||
$this->format_date_text_short="%d %b %Y";
|
$this->format_date_text_short="%d %b %Y";
|
||||||
@ -384,7 +384,7 @@ class Conf
|
|||||||
// Define umask
|
// Define umask
|
||||||
if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK='0664';
|
if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK='0664';
|
||||||
|
|
||||||
/* \todo Ajouter une option Gestion de la TVA dans le module compta qui permet de desactiver la fonction TVA
|
/* TODO Ajouter une option Gestion de la TVA dans le module compta qui permet de desactiver la fonction TVA
|
||||||
* (pour particuliers ou liberaux en franchise)
|
* (pour particuliers ou liberaux en franchise)
|
||||||
* En attendant, valeur forcee a 1 car toujours interessant a avoir meme ceux qui veulent pas.
|
* En attendant, valeur forcee a 1 car toujours interessant a avoir meme ceux qui veulent pas.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -599,6 +599,8 @@ class DolibarrModules
|
|||||||
dol_syslog("DolibarrModules::delete_boxes sql=".$sql);
|
dol_syslog("DolibarrModules::delete_boxes sql=".$sql);
|
||||||
if (! $this->db->query($sql))
|
if (! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
dol_syslog("DolibarrModules::delete_boxes ".$this->error, LOG_ERR);
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -626,6 +628,8 @@ class DolibarrModules
|
|||||||
dol_syslog("DolibarrModules::delete_style_sheet sql=".$sql);
|
dol_syslog("DolibarrModules::delete_style_sheet sql=".$sql);
|
||||||
if (! $this->db->query($sql))
|
if (! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
dol_syslog("DolibarrModules::delete_style_sheet ".$this->error, LOG_ERR);
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -650,6 +654,8 @@ class DolibarrModules
|
|||||||
dol_syslog("DolibarrModules::delete_tabs sql=".$sql);
|
dol_syslog("DolibarrModules::delete_tabs sql=".$sql);
|
||||||
if (! $this->db->query($sql))
|
if (! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
dol_syslog("DolibarrModules::delete_tabs ".$this->error, LOG_ERR);
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -902,8 +908,10 @@ class DolibarrModules
|
|||||||
$sql.= " WHERE module = '".$this->rights_class."'";
|
$sql.= " WHERE module = '".$this->rights_class."'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
dol_syslog("DolibarrModules::delete_permissions sql=".$sql);
|
dol_syslog("DolibarrModules::delete_permissions sql=".$sql);
|
||||||
if (!$this->db->query($sql))
|
if (! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
dol_syslog("DolibarrModules::delete_dirs ".$this->error, LOG_ERR);
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1013,6 +1021,8 @@ class DolibarrModules
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if (! $resql)
|
if (! $resql)
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
dol_syslog("DolibarrModules::delete_menus ".$this->error, LOG_ERR);
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1033,16 +1043,21 @@ class DolibarrModules
|
|||||||
{
|
{
|
||||||
foreach ($this->dirs as $key => $value)
|
foreach ($this->dirs as $key => $value)
|
||||||
{
|
{
|
||||||
$constname = $this->const_name."_DIR_";
|
$addtodatabase=0;
|
||||||
$dir = $this->dirs[$key][1];
|
|
||||||
$const = empty($this->dirs[$key][2])?'':$this->dirs[$key][2]; // Create constante in llx_const
|
|
||||||
$subname = empty($this->dirs[$key][3])?'':strtoupper($this->dirs[$key][3]); // Add submodule name (ex: $conf->module->submodule->dir_output)
|
|
||||||
$forcename = empty($this->dirs[$key][4])?'':strtoupper($this->dirs[$key][4]); // Change the module name if different
|
|
||||||
|
|
||||||
if ($forcename) $constname = 'MAIN_MODULE_'.$forcename."_DIR_";
|
if (! is_array($value)) $dir=$value; // Default simple mode
|
||||||
if ($subname) $constname = $constname.$subname."_";
|
else {
|
||||||
|
$constname = $this->const_name."_DIR_";
|
||||||
$name = $constname.strtoupper($this->dirs[$key][0]);
|
$dir = $this->dirs[$key][1];
|
||||||
|
$addtodatabase = empty($this->dirs[$key][2])?'':$this->dirs[$key][2]; // Create constante in llx_const
|
||||||
|
$subname = empty($this->dirs[$key][3])?'':strtoupper($this->dirs[$key][3]); // Add submodule name (ex: $conf->module->submodule->dir_output)
|
||||||
|
$forcename = empty($this->dirs[$key][4])?'':strtoupper($this->dirs[$key][4]); // Change the module name if different
|
||||||
|
|
||||||
|
if ($forcename) $constname = 'MAIN_MODULE_'.$forcename."_DIR_";
|
||||||
|
if ($subname) $constname = $constname.$subname."_";
|
||||||
|
|
||||||
|
$name = $constname.strtoupper($this->dirs[$key][0]);
|
||||||
|
}
|
||||||
|
|
||||||
// Define directory full path
|
// Define directory full path
|
||||||
if (empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $fulldir = DOL_DATA_ROOT.$dir;
|
if (empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $fulldir = DOL_DATA_ROOT.$dir;
|
||||||
@ -1057,8 +1072,9 @@ class DolibarrModules
|
|||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// define the constant if requested
|
|
||||||
if ($const)
|
// Define the constant in database if requested (not the default mode)
|
||||||
|
if ($addtodatabase)
|
||||||
{
|
{
|
||||||
$result = $this->insert_dirs($name,$dir);
|
$result = $this->insert_dirs($name,$dir);
|
||||||
if ($result) $err++;
|
if ($result) $err++;
|
||||||
@ -1122,9 +1138,11 @@ class DolibarrModules
|
|||||||
$sql.= " WHERE name like '".$this->const_name."_DIR_%'";
|
$sql.= " WHERE name like '".$this->const_name."_DIR_%'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
dol_syslog("DolibarrModules::delete_tabs sql=".$sql);
|
dol_syslog("DolibarrModules::delete_dirs sql=".$sql);
|
||||||
if (! $this->db->query($sql))
|
if (! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
dol_syslog("DolibarrModules::delete_dirs ".$this->error, LOG_ERR);
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -63,15 +63,7 @@ class modAgenda extends DolibarrModules
|
|||||||
$this->picto='calendar';
|
$this->picto='calendar';
|
||||||
|
|
||||||
// Data directories to create when module is enabled
|
// Data directories to create when module is enabled
|
||||||
$this->dirs = array();
|
$this->dirs = array("/agenda/temp");
|
||||||
$r=0;
|
|
||||||
|
|
||||||
$this->dirs[$r][0] = "output";
|
|
||||||
$this->dirs[$r][1] = "/agenda";
|
|
||||||
|
|
||||||
$r++;
|
|
||||||
$this->dirs[$r][0] = "temp";
|
|
||||||
$this->dirs[$r][1] = "/agenda/temp";
|
|
||||||
|
|
||||||
// Config pages
|
// Config pages
|
||||||
//-------------
|
//-------------
|
||||||
@ -182,7 +174,7 @@ class modAgenda extends DolibarrModules
|
|||||||
{
|
{
|
||||||
// Prevent pb of modules not correctly disabled
|
// Prevent pb of modules not correctly disabled
|
||||||
//$this->remove($options);
|
//$this->remove($options);
|
||||||
|
|
||||||
$sql = array();
|
$sql = array();
|
||||||
|
|
||||||
return $this->_init($sql,$options);
|
return $this->_init($sql,$options);
|
||||||
|
|||||||
@ -6,6 +6,11 @@
|
|||||||
-- when current version is 2.6.0 or higher.
|
-- when current version is 2.6.0 or higher.
|
||||||
--
|
--
|
||||||
|
|
||||||
|
-- Usage of llx_menu_const and llx_menu_constraint is too complicated
|
||||||
|
-- We remove it
|
||||||
|
alter table llx_menu_const drop foreign key fk_menu_const_fk_menu;
|
||||||
|
|
||||||
|
|
||||||
-- Multi company
|
-- Multi company
|
||||||
ALTER TABLE llx_rights_def ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER module;
|
ALTER TABLE llx_rights_def ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER module;
|
||||||
ALTER TABLE llx_events ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER type;
|
ALTER TABLE llx_events ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER type;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user