diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index f8a8034c9b5..d36569902d8 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -69,20 +69,9 @@ class modMyModule extends DolibarrModules $this->picto='generic'; // Data directories to create when module is enabled. + // Example: this->dirs = array("/mymodule/temp"); $this->dirs = array(); $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'. $this->style_sheet = ''; diff --git a/htdocs/core/conf.class.php b/htdocs/core/conf.class.php index 849da7819ec..7451303cea6 100644 --- a/htdocs/core/conf.class.php +++ b/htdocs/core/conf.class.php @@ -107,7 +107,8 @@ class Conf $this->tabs_modules[$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) { $module=strtolower($reg[1]); @@ -116,7 +117,7 @@ class Conf { $dir_name = "dir_".strtolower($reg[2]); $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.'
'; } 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 (! 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 foreach($this->modules as $module) { @@ -176,19 +184,13 @@ class Conf 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 // for backward compatibility. // Module user $this->user->dir_output=$rootfordata."/users"; $this->user->dir_temp=$rootfordata."/users/temp"; - + // Module RSS $this->externalrss->dir_output=$rootfordata."/rss"; $this->externalrss->dir_temp=$rootfordata."/rss/temp"; @@ -223,8 +225,6 @@ class Conf $this->fournisseur->commande->dir_temp =$rootfordata."/fournisseur/commande/temp"; $this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture"; $this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp"; - // Module produit - $this->produit->MultiPricesEnabled=defined("PRODUIT_MULTIPRICES")?PRODUIT_MULTIPRICES:0; // Module service $this->service->dir_output=$rootfordata."/produit"; $this->service->dir_temp =$rootfordata."/produit/temp"; @@ -364,8 +364,8 @@ class Conf $this->global->MAIN_GRAPH_LIBRARY = 'artichow'; } - // Format de la date - // \todo Mettre les 4 formats dans fichier langue + // Format for date + // TODO Mettre les formats dans fichier langue $this->format_date_short="%d/%m/%Y"; $this->format_hour_short="%H:%M"; $this->format_date_text_short="%d %b %Y"; @@ -384,7 +384,7 @@ class Conf // Define umask 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) * En attendant, valeur forcee a 1 car toujours interessant a avoir meme ceux qui veulent pas. */ diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php index 82316252f1b..e0a0c6fe0f2 100644 --- a/htdocs/includes/modules/DolibarrModules.class.php +++ b/htdocs/includes/modules/DolibarrModules.class.php @@ -599,6 +599,8 @@ class DolibarrModules dol_syslog("DolibarrModules::delete_boxes sql=".$sql); if (! $this->db->query($sql)) { + $this->error=$this->db->lasterror(); + dol_syslog("DolibarrModules::delete_boxes ".$this->error, LOG_ERR); $err++; } } @@ -626,6 +628,8 @@ class DolibarrModules dol_syslog("DolibarrModules::delete_style_sheet sql=".$sql); if (! $this->db->query($sql)) { + $this->error=$this->db->lasterror(); + dol_syslog("DolibarrModules::delete_style_sheet ".$this->error, LOG_ERR); $err++; } } @@ -650,6 +654,8 @@ class DolibarrModules dol_syslog("DolibarrModules::delete_tabs sql=".$sql); if (! $this->db->query($sql)) { + $this->error=$this->db->lasterror(); + dol_syslog("DolibarrModules::delete_tabs ".$this->error, LOG_ERR); $err++; } @@ -902,8 +908,10 @@ class DolibarrModules $sql.= " WHERE module = '".$this->rights_class."'"; $sql.= " AND entity = ".$conf->entity; 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++; } @@ -1013,6 +1021,8 @@ class DolibarrModules $resql=$this->db->query($sql); if (! $resql) { + $this->error=$this->db->lasterror(); + dol_syslog("DolibarrModules::delete_menus ".$this->error, LOG_ERR); $err++; } @@ -1033,16 +1043,21 @@ class DolibarrModules { foreach ($this->dirs as $key => $value) { - $constname = $this->const_name."_DIR_"; - $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 + $addtodatabase=0; - if ($forcename) $constname = 'MAIN_MODULE_'.$forcename."_DIR_"; - if ($subname) $constname = $constname.$subname."_"; - - $name = $constname.strtoupper($this->dirs[$key][0]); + if (! is_array($value)) $dir=$value; // Default simple mode + else { + $constname = $this->const_name."_DIR_"; + $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 if (empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $fulldir = DOL_DATA_ROOT.$dir; @@ -1057,8 +1072,9 @@ class DolibarrModules $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); if ($result) $err++; @@ -1122,9 +1138,11 @@ class DolibarrModules $sql.= " WHERE name like '".$this->const_name."_DIR_%'"; $sql.= " AND entity = ".$conf->entity; - dol_syslog("DolibarrModules::delete_tabs sql=".$sql); + dol_syslog("DolibarrModules::delete_dirs sql=".$sql); if (! $this->db->query($sql)) { + $this->error=$this->db->lasterror(); + dol_syslog("DolibarrModules::delete_dirs ".$this->error, LOG_ERR); $err++; } diff --git a/htdocs/includes/modules/modAgenda.class.php b/htdocs/includes/modules/modAgenda.class.php index 7084a8918bc..492b9abff64 100644 --- a/htdocs/includes/modules/modAgenda.class.php +++ b/htdocs/includes/modules/modAgenda.class.php @@ -63,15 +63,7 @@ class modAgenda extends DolibarrModules $this->picto='calendar'; // Data directories to create when module is enabled - $this->dirs = array(); - $r=0; - - $this->dirs[$r][0] = "output"; - $this->dirs[$r][1] = "/agenda"; - - $r++; - $this->dirs[$r][0] = "temp"; - $this->dirs[$r][1] = "/agenda/temp"; + $this->dirs = array("/agenda/temp"); // Config pages //------------- @@ -182,7 +174,7 @@ class modAgenda extends DolibarrModules { // Prevent pb of modules not correctly disabled //$this->remove($options); - + $sql = array(); return $this->_init($sql,$options); diff --git a/mysql/migration/2.6.0-2.7.0.sql b/mysql/migration/2.6.0-2.7.0.sql index 2bffc4b8410..5413686537a 100644 --- a/mysql/migration/2.6.0-2.7.0.sql +++ b/mysql/migration/2.6.0-2.7.0.sql @@ -6,6 +6,11 @@ -- 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 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;