From 762140e975ee8e89e9b3360e8efa697360cfe807 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Mon, 6 Oct 2008 07:39:52 +0000 Subject: [PATCH] Fix: Error management in module activation --- htdocs/admin/modules.php | 19 +- .../modules/DolibarrModules.class.php | 1057 +++++++++-------- htdocs/includes/modules/modAdherent.class.php | 2 +- htdocs/includes/modules/modBanque.class.php | 2 +- htdocs/includes/modules/modBarcode.class.php | 2 +- htdocs/includes/modules/modBookmark.class.php | 2 +- htdocs/includes/modules/modBoutique.class.php | 4 +- htdocs/includes/modules/modCashDesk.class.php | 2 +- .../includes/modules/modCategorie.class.php | 2 +- .../includes/modules/modClickToDial.class.php | 2 +- htdocs/includes/modules/modCommande.class.php | 2 +- .../includes/modules/modCommercial.class.php | 2 +- .../modules/modComptabilite.class.php | 2 +- .../modules/modComptabiliteExpert.class.php | 2 +- htdocs/includes/modules/modContrat.class.php | 2 +- .../includes/modules/modDeplacement.class.php | 2 +- htdocs/includes/modules/modDocument.class.php | 2 +- htdocs/includes/modules/modDomain.class.php | 2 +- htdocs/includes/modules/modDon.class.php | 2 +- .../includes/modules/modDroitPret.class.php | 2 +- htdocs/includes/modules/modECM.class.php | 2 +- htdocs/includes/modules/modEditeur.class.php | 2 +- htdocs/includes/modules/modEnergie.class.php | 2 +- .../includes/modules/modExpedition.class.php | 2 +- htdocs/includes/modules/modExport.class.php | 2 +- .../includes/modules/modExternalRss.class.php | 2 +- htdocs/includes/modules/modFacture.class.php | 2 +- .../includes/modules/modFckeditor.class.php | 2 +- .../includes/modules/modFicheinter.class.php | 2 +- .../includes/modules/modFournisseur.class.php | 2 +- htdocs/includes/modules/modImport.class.php | 2 +- htdocs/includes/modules/modLabel.class.php | 2 +- htdocs/includes/modules/modLdap.class.php | 2 +- htdocs/includes/modules/modMailing.class.php | 2 +- htdocs/includes/modules/modMantis.class.php | 2 +- .../modules/modNotification.class.php | 2 +- ...e2.class.php => modOSCommerceWS.class.php} | 8 +- htdocs/includes/modules/modPhenix.class.php | 2 +- htdocs/includes/modules/modPostnuke.class.php | 2 +- .../includes/modules/modPrelevement.class.php | 2 +- htdocs/includes/modules/modProduit.class.php | 2 +- htdocs/includes/modules/modProjet.class.php | 2 +- htdocs/includes/modules/modPropale.class.php | 2 +- htdocs/includes/modules/modService.class.php | 2 +- htdocs/includes/modules/modSociete.class.php | 2 +- htdocs/includes/modules/modStock.class.php | 2 +- htdocs/includes/modules/modSyslog.class.php | 2 +- htdocs/includes/modules/modTax.class.php | 2 +- .../includes/modules/modTelephonie.class.php | 2 +- htdocs/includes/modules/modUser.class.php | 2 +- .../includes/modules/modWebcalendar.class.php | 2 +- 51 files changed, 599 insertions(+), 583 deletions(-) rename htdocs/includes/modules/{modOSCommerce2.class.php => modOSCommerceWS.class.php} (95%) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 545d0113847..c6b92bd0ef9 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -136,11 +136,24 @@ function UnActivate($value,$requiredby=1) if ($modName) { $file = $modName . ".class.php"; - $res=include_once(DOL_DOCUMENT_ROOT."/includes/modules/".$file); + $res=@include_once(DOL_DOCUMENT_ROOT."/includes/modules/".$file); if (defined('DOL_DOCUMENT_ROOT_BIS') && ! $res) include_once(DOL_DOCUMENT_ROOT_BIS."/includes/modules/".$file); - $objMod = new $modName($db); - $result=$objMod->remove(); + if ($res) + { + $objMod = new $modName($db); + $result=$objMod->remove(); + } + else + { + $genericMod = new DolibarrModules($db); + $genericMod->name=eregi_replace('^mod','',$modName); + $genericMod->style_sheet=1; + $genericMod->rights_class=strtolower(eregi_replace('^mod','',$modName)); + $genericMod->const_name='MAIN_MODULE_'.strtoupper(eregi_replace('^mod','',$modName)); + dolibarr_syslog("modules::UnActivate Failed to find module file, we use generic function with name ".$genericMod->name); + $genericMod->_remove(); + } } // Desactivation des modules qui dependent de lui diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php index 2c035e1b61e..e00b149d2ba 100644 --- a/htdocs/includes/modules/DolibarrModules.class.php +++ b/htdocs/includes/modules/DolibarrModules.class.php @@ -21,47 +21,47 @@ */ /** - \file htdocs/includes/modules/DolibarrModules.class.php - \brief Fichier de description et activation des modules Dolibarr - \version $Id$ -*/ + \file htdocs/includes/modules/DolibarrModules.class.php + \brief Fichier de description et activation des modules Dolibarr + \version $Id$ + */ /** - \class DolibarrModules - \brief Classe mere des classes de description et activation des modules Dolibarr -*/ + \class DolibarrModules + \brief Classe mere des classes de description et activation des modules Dolibarr + */ class DolibarrModules { - //! Database handler - var $db; - //! Relative path to module style sheet - var $style_sheet = ''; - //! Path to create when module activated - var $dirs = array(); - //! Tableau des boites - var $boxes; - //! Tableau des constantes - var $const; - //! Tableau des droits - var $rights; - //! Tableau des menus - var $menu=array(); - //! Tableau des documents ??? - var $docs; - - var $dbversion; - - - /** - * \brief Constructeur - * \param DB handler d'acces base - */ - function DolibarrModules($DB) - { - $this->db = $DB ; - $this->dbversion = "-"; - } + //! Database handler + var $db; + //! Relative path to module style sheet + var $style_sheet = ''; + //! Path to create when module activated + var $dirs = array(); + //! Tableau des boites + var $boxes; + //! Tableau des constantes + var $const; + //! Tableau des droits + var $rights; + //! Tableau des menus + var $menu=array(); + //! Tableau des documents ??? + var $docs; + + var $dbversion; + + + /** + * \brief Constructeur + * \param DB handler d'acces base + */ + function DolibarrModules($DB) + { + $this->db = $DB ; + $this->dbversion = "-"; + } /** @@ -73,57 +73,57 @@ class DolibarrModules { global $langs; $err=0; - + $this->db->begin(); - - // Insere une entree dans llx_dolibarr_modules + + // Insert line in module table if (! $err) $err+=$this->_dbactive(); - - // Insere la constante d'activation module + + // Insert activation module constant if (! $err) $err+=$this->_active(); - + // Insere le nom de la feuille de style if (! $err) $err+=$this->insert_style_sheet(); // Insere les constantes associees au module dans llx_const if (! $err) $err+=$this->insert_const(); - + // Insere les boites dans llx_boxes_def if (! $err) $err+=$this->insert_boxes(); - + // Insere les permissions associees au module actif dans llx_rights_def if (! $err) $err+=$this->insert_permissions(); - + // Insere les constantes associees au module dans llx_const if (! $err) $err+=$this->insert_menus(); - + // Execute les requetes sql complementaires for ($i = 0 ; $i < sizeof($array_sql) ; $i++) { - if (! $err) + if (! $err) { $sql=$array_sql[$i]; - + $result=$this->db->query($sql); if (! $result) { $this->error=$this->db->error(); - dolibarr_syslog("DolibarrModules::_init Error sql=".$sql." - ".$this->error, LOG_ERR); - $err++; + dolibarr_syslog("DolibarrModules::_init Error sql=".$sql." - ".$this->error, LOG_ERR); + $err++; } } } - + // Cree les documents generables if (is_array($this->docs)) { foreach ($this->docs as $key => $doc) { - if (! $err) + if (! $err) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_generator (rowid,name,classfile,class) VALUES "; $sql .= "(".$doc[0].",'".addslashes($doc[1])."','".$doc[2]."','".$doc[3]."');"; - + $result=$this->db->query($sql); if (! $result) { @@ -134,7 +134,7 @@ class DolibarrModules } } } - + // Cree les repertoires if (is_array($this->dirs)) { @@ -150,7 +150,7 @@ class DolibarrModules } } } - + // Renvoi valeur de retour if (! $err) { @@ -164,61 +164,61 @@ class DolibarrModules } } - /** - * \brief 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 - * \return int 1 if OK, 0 if KO - */ - function _remove($array_sql) - { - $err = 0; - - // Supprime entree des modules - $err+=$this->_dbunactive(); - - // Supprime la constante d'activation du module - $err+=$this->_unactive(); - - // Supprime les boites de la liste des boites disponibles - $err+=$this->delete_style_sheet(); - - // Supprime les boites de la liste des boites disponibles - $err+=$this->delete_boxes(); - - // Supprime les droits de la liste des droits disponibles - $err+=$this->delete_permissions(); - - // Supprime les menus apportes par le module - $err+=$this->delete_menus(); - - // Supprime les documents generables - $err+=$this->delete_docs(); - - // Execute les requetes sql complementaires - for ($i = 0 ; $i < sizeof($array_sql) ; $i++) - { - if (!$this->db->query($array_sql[$i])) - { - $err++; - } - } - - // Renvoi valeur de retour - if ($err > 0) return 0; - return 1; - } - + /** + * \brief 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 + * \return int 1 if OK, 0 if KO + */ + function _remove($array_sql) + { + $err = 0; + + // Remove line in activation module + $err+=$this->_dbunactive(); + + // Remove activation module line + $err+=$this->_unactive(); + + // Supprime les boites de la liste des boites disponibles + $err+=$this->delete_style_sheet(); + + // Supprime les boites de la liste des boites disponibles + $err+=$this->delete_boxes(); + + // Supprime les droits de la liste des droits disponibles + $err+=$this->delete_permissions(); + + // Supprime les menus apportes par le module + $err+=$this->delete_menus(); + + // Supprime les documents generables + $err+=$this->delete_docs(); + + // Execute les requetes sql complementaires + for ($i = 0 ; $i < sizeof($array_sql) ; $i++) + { + if (!$this->db->query($array_sql[$i])) + { + $err++; + } + } + + // Renvoi valeur de retour + if ($err > 0) return 0; + return 1; + } + /** \brief Retourne le nom traduit du module si la traduction existe dans admin.lang, - sinon le nom defini par defaut dans le module. + sinon le nom defini par defaut dans le module. \return string Nom du module traduit - */ + */ function getName() { global $langs; $langs->load("admin"); - + if ($langs->trans("Module".$this->numero."Name") != ("Module".$this->numero."Name")) { // Si traduction du nom du module existe @@ -230,18 +230,18 @@ class DolibarrModules return $this->name; } } - - + + /** \brief Retourne la description traduite du module si la traduction existe dans admin.lang, sinon la description definie par defaut dans le module. \return string Nom du module traduit - */ + */ function getDesc() { global $langs; $langs->load("admin"); - + if ($langs->trans("Module".$this->numero."Desc") != ("Module".$this->numero."Desc")) { // Si traduction de la description du module existe @@ -253,223 +253,225 @@ class DolibarrModules return $this->description; } } - - + + /** \brief Retourne la version du module. Pour les modules a l'etat 'experimental', retourne la traduction de 'experimental' Pour les modules 'dolibarr', retourne la version de Dolibarr Pour les autres modules, retourne la version du module \return string Version du module - */ + */ function getVersion() { global $langs; $langs->load("admin"); - + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); elseif ($this->version == 'development') return $langs->trans("VersionDevelopment"); elseif ($this->version == 'dolibarr') return DOL_VERSION; elseif ($this->version) return $this->version; else return $langs->trans("VersionUnknown"); } - - - /** - \brief Retourne la version en base du module. - \return string Version du module - */ - function getDbVersion() - { - global $langs; - $langs->load("admin"); - - $sql ="SELECT active_version FROM ".MAIN_DB_PREFIX."dolibarr_modules"; - $sql .= " WHERE numero=".$this->numero." AND active = 1"; - - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - - if ($num > 0) - { - $row = $this->db->fetch_row($resql); - - $this->dbversion = $row[0]; - } - - $this->db->free($resql); - } - - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - elseif ($this->version == 'development') return $langs->trans("VersionDevelopment"); - elseif ($this->version == 'dolibarr') return DOL_VERSION; - elseif ($this->version) return $this->version; - else return ""; - - } - - - /** - \brief Retourne la liste des fichiers lang en rapport avec le module - \return array Tableau des fichier lang - */ - function getLangFilesArray() - { - return $this->langfiles; - } - - /** - \brief Retourne le libelle d'un lot de donnees exportable - \return string Libelle du lot de donnees - */ - function getDatasetLabel($r) - { - global $langs; - - $langstring="ExportDataset_".$this->export_code[$r]; - if ($langs->trans($langstring) == $langstring) - { - // Traduction non trouvee - return $langs->trans($this->export_label[$r]); - } - else - { - // Traduction trouvee - return $langs->trans($langstring); - } - } - - - /** - \brief Insere ligne module - \return int Nombre d'erreurs (0 si ok) - */ - function _dbactive() - { - $err = 0; - - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."dolibarr_modules WHERE numero=".$this->numero.";"; - $this->db->query($sql_del); - - $sql ="INSERT INTO ".MAIN_DB_PREFIX."dolibarr_modules (numero,active,active_date,active_version)"; - $sql .= " VALUES ("; - $sql .= $this->numero.",1,".$this->db->idate(mktime()).",'".$this->version."')"; - - $this->db->query($sql); - - return $err; - } - - - /** - \brief Supprime ligne module - \return int Nombre d'erreurs (0 si ok) - */ - function _dbunactive() - { - $err = 0; - - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."dolibarr_modules WHERE numero=".$this->numero.";"; - $this->db->query($sql_del); - - return $err; - } - - - /** - \brief Insere constante d'activation module - \return int Nombre d'erreurs (0 si ok) - */ - function _active() - { - $err = 0; - - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->const_name."';"; - $this->db->query($sql_del); - - $sql ="INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES - ('".$this->const_name."','1',0);"; - if (!$this->db->query($sql)) - { - $err++; - } - - return $err; - } - - - /** - \brief Supprime constante d'activation module - \return int Nombre d'erreurs (0 si ok) - */ - function _unactive() - { - $err = 0; - - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->const_name."';"; - $this->db->query($sql_del); - - return $err; - } - - - /** - \brief Insere les boites associees au module dans llx_boxes_def - \return int Nombre d'erreurs (0 si ok) - */ - function insert_boxes() - { - $err=0; - - if (is_array($this->boxes)) - { - foreach ($this->boxes as $key => $value) - { - //$titre = $this->boxes[$key][0]; - $file = isset($this->boxes[$key][1])?$this->boxes[$key][1]:''; - $note = isset($this->boxes[$key][2])?$this->boxes[$key][2]:''; - - $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."boxes_def"; - $sql.= " WHERE file ='".$file."'"; - if ($note) $sql.=" AND note ='".addslashes($note)."'"; - - $result=$this->db->query($sql); - if ($result) - { - $row = $this->db->fetch_row($result); - if ($row[0] == 0) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file,note)"; - $sql.= " VALUES ('".addslashes($file)."',"; - $sql.= $note?"'".addslashes($note)."'":"null"; - $sql.= ")"; + + + /** + \brief Retourne la version en base du module. + \return string Version du module + */ + function getDbVersion() + { + global $langs; + $langs->load("admin"); + + $sql ="SELECT active_version FROM ".MAIN_DB_PREFIX."dolibarr_modules"; + $sql .= " WHERE numero=".$this->numero." AND active = 1"; + + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + + if ($num > 0) + { + $row = $this->db->fetch_row($resql); + + $this->dbversion = $row[0]; + } + + $this->db->free($resql); + } + + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'development') return $langs->trans("VersionDevelopment"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return ""; + + } + + + /** + \brief Retourne la liste des fichiers lang en rapport avec le module + \return array Tableau des fichier lang + */ + function getLangFilesArray() + { + return $this->langfiles; + } + + /** + \brief Retourne le libelle d'un lot de donnees exportable + \return string Libelle du lot de donnees + */ + function getDatasetLabel($r) + { + global $langs; + + $langstring="ExportDataset_".$this->export_code[$r]; + if ($langs->trans($langstring) == $langstring) + { + // Traduction non trouvee + return $langs->trans($this->export_label[$r]); + } + else + { + // Traduction trouvee + return $langs->trans($langstring); + } + } + + + /** + * \brief Insert line in module table + * \return int Nombre d'erreurs (0 si ok) + */ + function _dbactive() + { + $err = 0; + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."dolibarr_modules WHERE numero=".$this->numero.";"; + $this->db->query($sql_del); + + $sql ="INSERT INTO ".MAIN_DB_PREFIX."dolibarr_modules (numero,active,active_date,active_version)"; + $sql .= " VALUES ("; + $sql .= $this->numero.",1,".$this->db->idate(mktime()).",'".$this->version."')"; + + $this->db->query($sql); + + return $err; + } + + + /** + * \brief Remove line in module table + * \return int Nb of errors (0 if OK) + */ + function _dbunactive() + { + $err = 0; + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."dolibarr_modules WHERE numero=".$this->numero; + $this->db->query($sql_del); + + return $err; + } + + + /** + * \brief Insert constant to activate module + * \return int Nb of errors (0 if OK) + */ + function _active() + { + $err = 0; + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->const_name."'"; + $this->db->query($sql_del); + + $sql ="INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES + ('".$this->const_name."','1',0)"; + dolibarr_syslog("DolibarrModules::_active sql=".$sql); + if (!$this->db->query($sql)) + { + $err++; + } + + return $err; + } + + + /** + * \brief Remove activation line + * \return int Nb of errors (0 if OK) + **/ + function _unactive() + { + $err = 0; + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->const_name."'"; + dolibarr_syslog("DolibarrModules::_unactive sql=".$sql_del); + $this->db->query($sql_del); + + return $err; + } + + + /** + \brief Insere les boites associees au module dans llx_boxes_def + \return int Nombre d'erreurs (0 si ok) + */ + function insert_boxes() + { + $err=0; + + if (is_array($this->boxes)) + { + foreach ($this->boxes as $key => $value) + { + //$titre = $this->boxes[$key][0]; + $file = isset($this->boxes[$key][1])?$this->boxes[$key][1]:''; + $note = isset($this->boxes[$key][2])?$this->boxes[$key][2]:''; + + $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."boxes_def"; + $sql.= " WHERE file ='".$file."'"; + if ($note) $sql.=" AND note ='".addslashes($note)."'"; + + $result=$this->db->query($sql); + if ($result) + { + $row = $this->db->fetch_row($result); + if ($row[0] == 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file,note)"; + $sql.= " VALUES ('".addslashes($file)."',"; + $sql.= $note?"'".addslashes($note)."'":"null"; + $sql.= ")"; //print $sql; - if (! $this->db->query($sql)) - { - $err++; - } - } - } - else - { - $err++; - } - } - } - - return $err; - } - - - + if (! $this->db->query($sql)) + { + $err++; + } + } + } + else + { + $err++; + } + } + } + + return $err; + } + + + /** - \brief Supprime les documents - \return int Nombre d'erreurs (0 si ok) - */ + \brief Supprime les documents + \return int Nombre d'erreurs (0 si ok) + */ function delete_docs() - { + { $err=0; // Supprime les documents generables @@ -479,28 +481,29 @@ class DolibarrModules { $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_generator "; $sql .= "WHERE name= '".addslashes($doc[0])."' AND classfile='".$doc[1]."'AND class='".$doc[2]."';"; - + + dolibarr_syslog("DolibarrModules::delete_docs sql=".$sql); $result=$this->db->query($sql); if (! $result) { - dolibarr_syslog("DolibarrModules.class::delete_docs Error sql=".$sql." - ".$this->db->error()); + dolibarr_syslog("DolibarrModules::delete_docs Error sql=".$sql." - ".$this->db->error()); $err++; } - + } } return $err; } - - + + /** \brief Supprime les boites \return int Nombre d'erreurs (0 si ok) - */ + */ function delete_boxes() { $err=0; - + if (is_array($this->boxes)) { foreach ($this->boxes as $key => $value) @@ -508,14 +511,14 @@ class DolibarrModules //$titre = $this->boxes[$key][0]; $file = $this->boxes[$key][1]; //$note = $this->boxes[$key][2]; - + $sql = "DELETE ".MAIN_DB_PREFIX."boxes"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def"; $sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid"; $sql.= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".addslashes($file)."'"; dolibarr_syslog("DolibarrModules::delete_boxes sql=".$sql); $this->db->query($sql); - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def"; $sql.= " WHERE file = '".addslashes($file)."'"; dolibarr_syslog("DolibarrModules::delete_boxes sql=".$sql); @@ -525,18 +528,18 @@ class DolibarrModules } } } - + return $err; } - + /** \brief Desactive feuille de style du module par suppression ligne dans llx_const \return int Nombre d'erreurs (0 si ok) - */ + */ function delete_style_sheet() { $err=0; - + if ($this->style_sheet) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; @@ -547,200 +550,200 @@ class DolibarrModules $err++; } } - + return $err; } - /** - \brief Active la feuille de style associee au module par insertion ligne dans llx_const - \return int Nombre d'erreurs (0 si ok) - */ - function insert_style_sheet() - { - $err=0; + /** + \brief Active la feuille de style associee au module par insertion ligne dans llx_const + \return int Nombre d'erreurs (0 si ok) + */ + function insert_style_sheet() + { + $err=0; - if ($this->style_sheet) + if ($this->style_sheet) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible)"; $sql.= " VALUES ('".$this->const_name."_CSS','chaine','".$this->style_sheet."','Style sheet for module ".$this->name."','0')"; dolibarr_syslog("DolibarrModules::insert_style_sheet sql=".$sql); $resql=$this->db->query($sql); /* Allow duplicate key - if (! $resql) + if (! $resql) + { + $err++; + } + */ + } + + return $err; + } + + /** + \brief Insere les constantes associees au module dans llx_const + \return int Nombre d'erreurs (0 si ok) + */ + function insert_const() + { + $err=0; + + foreach ($this->const as $key => $value) + { + $name = $this->const[$key][0]; + $type = $this->const[$key][1]; + $val = $this->const[$key][2]; + $note = $this->const[$key][3]; + $visible= $this->const[$key][4]; + + $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."const WHERE name ='".$name."'"; + + $result=$this->db->query($sql); + if ($result) + { + $row = $this->db->fetch_row($result); + + if ($row[0] == 0) + { + if (! $visible) $visible='0'; + if (strlen($note)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible) VALUES ('$name','$type','$val','$note','$visible')"; + } + elseif (strlen($val)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,visible) VALUES ('$name','$type','$val','$visible')"; + } + else + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,visible) VALUES ('$name','$type','$visible')"; + } + + dolibarr_syslog("DolibarrModules::insert_const sql=".$sql); + if (! $this->db->query($sql) ) + { + dolibarr_syslog("DolibarrModules::insert_const ".$this->db->lasterror(), LOG_ERR); + $err++; + } + } + } + else { $err++; } - */ } - + return $err; } - - /** - \brief Insere les constantes associees au module dans llx_const - \return int Nombre d'erreurs (0 si ok) - */ - function insert_const() - { - $err=0; - - foreach ($this->const as $key => $value) - { - $name = $this->const[$key][0]; - $type = $this->const[$key][1]; - $val = $this->const[$key][2]; - $note = $this->const[$key][3]; - $visible= $this->const[$key][4]; - - $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."const WHERE name ='".$name."'"; - - $result=$this->db->query($sql); - if ($result) - { - $row = $this->db->fetch_row($result); - - if ($row[0] == 0) - { - if (! $visible) $visible='0'; - if (strlen($note)) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,note,visible) VALUES ('$name','$type','$val','$note','$visible')"; - } - elseif (strlen($val)) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,value,visible) VALUES ('$name','$type','$val','$visible')"; - } - else - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,type,visible) VALUES ('$name','$type','$visible')"; - } - dolibarr_syslog("DolibarrModules::insert_const sql=".$sql); - if (! $this->db->query($sql) ) - { - dolibarr_syslog("DolibarrModules::insert_const ".$this->db->lasterror(), LOG_ERR); - $err++; - } - } - } - else - { - $err++; - } - } - - return $err; - } - - /** - \brief Insere les permissions associees au module dans llx_rights_def - \return int Nombre d'erreurs (0 si ok) - */ - function insert_permissions() - { - $err=0; - - //print $this->rights_class." ".sizeof($this->rights)."<br>"; - - // Test si module actif - $sql_del = "SELECT value FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->const_name."'"; - $resql=$this->db->query($sql_del); - if ($resql) { - - $obj=$this->db->fetch_object($resql); - if ($obj->value) { - - // Si module actif - foreach ($this->rights as $key => $value) - { - $r_id = $this->rights[$key][0]; - $r_desc = $this->rights[$key][1]; - $r_type = $this->rights[$key][2]; - $r_def = $this->rights[$key][3]; - $r_perms = $this->rights[$key][4]; - $r_subperms = $this->rights[$key][5]; - $r_modul = $this->rights_class; - - if (empty($r_type)) $r_type='w'; - - if (strlen($r_perms) ) - { - if (strlen($r_subperms) ) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; - $sql .= " (id, libelle, module, type, bydefault, perms, subperms)"; - $sql .= " VALUES "; - $sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')"; - } - else - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; - $sql .= " (id, libelle, module, type, bydefault, perms)"; - $sql .= " VALUES "; - $sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')"; - } - } - else - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; - $sql .= " (id, libelle, module, type, bydefault)"; - $sql .= " VALUES "; - $sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")"; - } - + /** + \brief Insere les permissions associees au module dans llx_rights_def + \return int Nombre d'erreurs (0 si ok) + */ + function insert_permissions() + { + $err=0; + + //print $this->rights_class." ".sizeof($this->rights)."<br>"; + + // Test si module actif + $sql_del = "SELECT value FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->const_name."'"; + $resql=$this->db->query($sql_del); + if ($resql) { + + $obj=$this->db->fetch_object($resql); + if ($obj->value) { + + // Si module actif + foreach ($this->rights as $key => $value) + { + $r_id = $this->rights[$key][0]; + $r_desc = $this->rights[$key][1]; + $r_type = $this->rights[$key][2]; + $r_def = $this->rights[$key][3]; + $r_perms = $this->rights[$key][4]; + $r_subperms = $this->rights[$key][5]; + $r_modul = $this->rights_class; + + if (empty($r_type)) $r_type='w'; + + if (strlen($r_perms) ) + { + if (strlen($r_subperms) ) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; + $sql .= " (id, libelle, module, type, bydefault, perms, subperms)"; + $sql .= " VALUES "; + $sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')"; + } + else + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; + $sql .= " (id, libelle, module, type, bydefault, perms)"; + $sql .= " VALUES "; + $sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')"; + } + } + else + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; + $sql .= " (id, libelle, module, type, bydefault)"; + $sql .= " VALUES "; + $sql .= "(".$r_id.",'".addslashes($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")"; + } + dolibarr_syslog("DolibarrModules::insert_permissions sql=".$sql); - $resql=$this->db->query($sql); - if (! $resql) - { - if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") { - $err++; - } - } - } - } - } - - return $err; - } - - - /** - \brief Supprime les permissions - \return int Nombre d'erreurs (0 si ok) - */ - function delete_permissions() - { - $err=0; - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = '".$this->rights_class."'"; + $resql=$this->db->query($sql); + if (! $resql) + { + if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") { + $err++; + } + } + } + } + } + + return $err; + } + + + /** + \brief Supprime les permissions + \return int Nombre d'erreurs (0 si ok) + */ + function delete_permissions() + { + $err=0; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = '".$this->rights_class."'"; dolibarr_syslog("DolibarrModules::delete_permissions sql=".$sql); - if (!$this->db->query($sql)) - { - $err++; - } - - return $err; - } - - - /** - \brief Insere les menus dans llx_menu* - \return int Nombre d'erreurs (0 si ok) - */ - function insert_menus() - { + if (!$this->db->query($sql)) + { + $err++; + } + + return $err; + } + + + /** + \brief Insere les menus dans llx_menu* + \return int Nombre d'erreurs (0 si ok) + */ + function insert_menus() + { global $user; - + require_once(DOL_DOCUMENT_ROOT."/core/menubase.class.php"); $err=0; - + $this->db->begin(); - - foreach ($this->menu as $key => $value) - { - $menu = new Menubase($this->db); - $menu->menu_handler='all'; + + foreach ($this->menu as $key => $value) + { + $menu = new Menubase($this->db); + $menu->menu_handler='all'; $menu->module=$this->rights_class; if (! $this->menu[$key]['fk_menu']) { @@ -774,51 +777,51 @@ class DolibarrModules { $result=$menu->create($user); if ($result > 0) - { - $this->menu[$key]['rowid']=$result; - } - else - { + { + $this->menu[$key]['rowid']=$result; + } + else + { $this->error=$menu->error; - $err++; - } + $err++; + } } - } - - if (! $err) - { - $this->db->commit(); - } - else - { - dolibarr_syslog("DolibarrModules::insert_menus ".$this->error, LOG_ERR); - $this->db->rollback(); - } - - return $err; - } - - - /** - \brief Supprime les permissions - \return int Nombre d'erreurs (0 si ok) - */ - function delete_menus() - { - $err=0; - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; - $sql.= " WHERE module = '".addslashes($this->rights_class)."'"; - + } + + if (! $err) + { + $this->db->commit(); + } + else + { + dolibarr_syslog("DolibarrModules::insert_menus ".$this->error, LOG_ERR); + $this->db->rollback(); + } + + return $err; + } + + + /** + \brief Supprime les permissions + \return int Nombre d'erreurs (0 si ok) + */ + function delete_menus() + { + $err=0; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; + $sql.= " WHERE module = '".addslashes($this->rights_class)."'"; + dolibarr_syslog("DolibarrModules::delete_menus sql=".$sql); $resql=$this->db->query($sql); if (! $resql) - { - $err++; - } + { + $err++; + } + + return $err; + } - return $err; - } - } ?> diff --git a/htdocs/includes/modules/modAdherent.class.php b/htdocs/includes/modules/modAdherent.class.php index db1c8a463f0..e5e64a8b43d 100644 --- a/htdocs/includes/modules/modAdherent.class.php +++ b/htdocs/includes/modules/modAdherent.class.php @@ -56,7 +56,7 @@ class modAdherent extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Gestion des adherents d'une association"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_ADHERENT'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='user'; diff --git a/htdocs/includes/modules/modBanque.class.php b/htdocs/includes/modules/modBanque.class.php index c76abd97e5f..304d2bcb285 100644 --- a/htdocs/includes/modules/modBanque.class.php +++ b/htdocs/includes/modules/modBanque.class.php @@ -57,7 +57,7 @@ class modBanque extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_BANQUE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='account'; diff --git a/htdocs/includes/modules/modBarcode.class.php b/htdocs/includes/modules/modBarcode.class.php index 093b8c25f38..661ab64ed12 100644 --- a/htdocs/includes/modules/modBarcode.class.php +++ b/htdocs/includes/modules/modBarcode.class.php @@ -54,7 +54,7 @@ class modBarcode extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Gestion des codes barres"; $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_BARCODE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; $this->picto='barcode'; diff --git a/htdocs/includes/modules/modBookmark.class.php b/htdocs/includes/modules/modBookmark.class.php index 9be729dfe31..8d6ce216383 100644 --- a/htdocs/includes/modules/modBookmark.class.php +++ b/htdocs/includes/modules/modBookmark.class.php @@ -56,7 +56,7 @@ class modBookmark extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_BOOKMARK'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; $this->picto='bookmark'; diff --git a/htdocs/includes/modules/modBoutique.class.php b/htdocs/includes/modules/modBoutique.class.php index 7388bd974fe..f6a2c37936f 100644 --- a/htdocs/includes/modules/modBoutique.class.php +++ b/htdocs/includes/modules/modBoutique.class.php @@ -55,7 +55,7 @@ class modBoutique extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Interface de visualisation d'une boutique OSCommerce ou OSCSS"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_BOUTIQUE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 1; // Dir @@ -68,7 +68,7 @@ class modBoutique extends DolibarrModules // D�pendances $this->depends = array(); $this->requiredby = array(); - $this->conflictwith = array("modOSCommerce2"); + $this->conflictwith = array("modOSCommerceWS"); $this->langfiles = array("shop"); // Constantes diff --git a/htdocs/includes/modules/modCashDesk.class.php b/htdocs/includes/modules/modCashDesk.class.php index 34bef3b7ff3..f83751917df 100644 --- a/htdocs/includes/modules/modCashDesk.class.php +++ b/htdocs/includes/modules/modCashDesk.class.php @@ -60,7 +60,7 @@ class modCashDesk extends DolibarrModules $this->version = 'development'; //$this->version = 'experimental'; // 'development' or 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_CASHDESK'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto = 'generic'; diff --git a/htdocs/includes/modules/modCategorie.class.php b/htdocs/includes/modules/modCategorie.class.php index 0cddf2bf7ad..4423b1371f8 100644 --- a/htdocs/includes/modules/modCategorie.class.php +++ b/htdocs/includes/modules/modCategorie.class.php @@ -56,7 +56,7 @@ class modCategorie extends DolibarrModules $this->version = $this->revision[1]; //$this->version = 'experimental'; // 'development' or 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_CATEGORIE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto = ''; diff --git a/htdocs/includes/modules/modClickToDial.class.php b/htdocs/includes/modules/modClickToDial.class.php index 9723d1d1a51..e6f9dd99f56 100644 --- a/htdocs/includes/modules/modClickToDial.class.php +++ b/htdocs/includes/modules/modClickToDial.class.php @@ -56,7 +56,7 @@ class modClickToDial extends DolibarrModules $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_CLICKTODIAL'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 1; $this->picto='phoning'; diff --git a/htdocs/includes/modules/modCommande.class.php b/htdocs/includes/modules/modCommande.class.php index 476c7f9b174..333545b1bbd 100644 --- a/htdocs/includes/modules/modCommande.class.php +++ b/htdocs/includes/modules/modCommande.class.php @@ -56,7 +56,7 @@ class modCommande extends DolibarrModules $this->description = "Gestion des commandes clients"; $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_COMMANDE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='order'; diff --git a/htdocs/includes/modules/modCommercial.class.php b/htdocs/includes/modules/modCommercial.class.php index 443e7617959..cb3da8b070f 100644 --- a/htdocs/includes/modules/modCommercial.class.php +++ b/htdocs/includes/modules/modCommercial.class.php @@ -57,7 +57,7 @@ class modCommercial extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_COMMERCIAL'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='commercial'; diff --git a/htdocs/includes/modules/modComptabilite.class.php b/htdocs/includes/modules/modComptabilite.class.php index 1a84633194f..5d27c5c5424 100644 --- a/htdocs/includes/modules/modComptabilite.class.php +++ b/htdocs/includes/modules/modComptabilite.class.php @@ -59,7 +59,7 @@ class modComptabilite extends DolibarrModules $this->revision = explode(" ","$Revision$"); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_COMPTABILITE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto=''; diff --git a/htdocs/includes/modules/modComptabiliteExpert.class.php b/htdocs/includes/modules/modComptabiliteExpert.class.php index 1808ac94ecf..cbf3b58772c 100644 --- a/htdocs/includes/modules/modComptabiliteExpert.class.php +++ b/htdocs/includes/modules/modComptabiliteExpert.class.php @@ -61,7 +61,7 @@ class modComptabiliteExpert extends DolibarrModules // $this->version = $this->revision[1]; $this->version = "development"; - $this->const_name = 'MAIN_MODULE_COMPTABILITEEXPERT'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; // Config pages diff --git a/htdocs/includes/modules/modContrat.class.php b/htdocs/includes/modules/modContrat.class.php index e0b65b14468..0a22beef3a3 100644 --- a/htdocs/includes/modules/modContrat.class.php +++ b/htdocs/includes/modules/modContrat.class.php @@ -57,7 +57,7 @@ class modContrat extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_CONTRAT'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='contract'; diff --git a/htdocs/includes/modules/modDeplacement.class.php b/htdocs/includes/modules/modDeplacement.class.php index eca9fc634f8..dd27d199e02 100644 --- a/htdocs/includes/modules/modDeplacement.class.php +++ b/htdocs/includes/modules/modDeplacement.class.php @@ -56,7 +56,7 @@ class modDeplacement extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_DEPLACEMENT'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto = "generic"; diff --git a/htdocs/includes/modules/modDocument.class.php b/htdocs/includes/modules/modDocument.class.php index 1256d1bca66..6a6fcad9cc3 100644 --- a/htdocs/includes/modules/modDocument.class.php +++ b/htdocs/includes/modules/modDocument.class.php @@ -54,7 +54,7 @@ class modDocument extends DolibarrModules $this->description = "Gestion des documents"; $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_DOCUMENT'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; $this->picto='dir'; diff --git a/htdocs/includes/modules/modDomain.class.php b/htdocs/includes/modules/modDomain.class.php index 94d0aa387a1..4177ba625df 100644 --- a/htdocs/includes/modules/modDomain.class.php +++ b/htdocs/includes/modules/modDomain.class.php @@ -54,7 +54,7 @@ class modDomain extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Gestion d'une base de noms de domaines"; $this->version = 'development'; // 'development' or 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_DOMAIN'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; $this->picto='user'; diff --git a/htdocs/includes/modules/modDon.class.php b/htdocs/includes/modules/modDon.class.php index 8165bd8d306..d6038a3e925 100644 --- a/htdocs/includes/modules/modDon.class.php +++ b/htdocs/includes/modules/modDon.class.php @@ -55,7 +55,7 @@ class modDon extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Gestion des dons"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_DON'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; // Dir diff --git a/htdocs/includes/modules/modDroitPret.class.php b/htdocs/includes/modules/modDroitPret.class.php index 22a2b36650b..079b4839dbb 100644 --- a/htdocs/includes/modules/modDroitPret.class.php +++ b/htdocs/includes/modules/modDroitPret.class.php @@ -53,7 +53,7 @@ class modDroitPret extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Gestion du droit de prets"; $this->version = 'experimental'; // 'development' or 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_DROITPRET'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; // Dir diff --git a/htdocs/includes/modules/modECM.class.php b/htdocs/includes/modules/modECM.class.php index f62cc7e21de..03c862da60e 100644 --- a/htdocs/includes/modules/modECM.class.php +++ b/htdocs/includes/modules/modECM.class.php @@ -60,7 +60,7 @@ class modECM extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (XXX is id value) - $this->const_name = 'MAIN_MODULE_ECM'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=other) $this->special = 0; // Name of png file (without png) used for this module diff --git a/htdocs/includes/modules/modEditeur.class.php b/htdocs/includes/modules/modEditeur.class.php index 14ca3494ff0..6baf8114b60 100644 --- a/htdocs/includes/modules/modEditeur.class.php +++ b/htdocs/includes/modules/modEditeur.class.php @@ -54,7 +54,7 @@ class modEditeur extends DolibarrModules $this->description = "Gestion des editeurs"; $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_EDITEUR'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 3; $this->picto='book'; diff --git a/htdocs/includes/modules/modEnergie.class.php b/htdocs/includes/modules/modEnergie.class.php index 4ac745b879e..a290e13f61a 100644 --- a/htdocs/includes/modules/modEnergie.class.php +++ b/htdocs/includes/modules/modEnergie.class.php @@ -58,7 +58,7 @@ class modEnergie extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_ENERGIE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; $this->picto='energie'; diff --git a/htdocs/includes/modules/modExpedition.class.php b/htdocs/includes/modules/modExpedition.class.php index 1938ee4a1eb..d0e1515e2c6 100644 --- a/htdocs/includes/modules/modExpedition.class.php +++ b/htdocs/includes/modules/modExpedition.class.php @@ -55,7 +55,7 @@ class modExpedition extends DolibarrModules $this->description = "Gestion des expeditions"; $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_EXPEDITION'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto = "sending"; diff --git a/htdocs/includes/modules/modExport.class.php b/htdocs/includes/modules/modExport.class.php index 5ceadd17a31..185b57ab7e9 100644 --- a/htdocs/includes/modules/modExport.class.php +++ b/htdocs/includes/modules/modExport.class.php @@ -52,7 +52,7 @@ class modExport extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Outils d'exports de donnees Dolibarr (via un assistant)"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_EXPORT'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto=''; diff --git a/htdocs/includes/modules/modExternalRss.class.php b/htdocs/includes/modules/modExternalRss.class.php index b2849c29305..7e0bddff658 100644 --- a/htdocs/includes/modules/modExternalRss.class.php +++ b/htdocs/includes/modules/modExternalRss.class.php @@ -55,7 +55,7 @@ class modExternalRss extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Ajout de files d'informations RSS dans les �crans Dolibarr"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_EXTERNALRSS'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 1; $this->picto='rss'; diff --git a/htdocs/includes/modules/modFacture.class.php b/htdocs/includes/modules/modFacture.class.php index 0f3d1b152a2..abdcd1b1dbb 100644 --- a/htdocs/includes/modules/modFacture.class.php +++ b/htdocs/includes/modules/modFacture.class.php @@ -58,7 +58,7 @@ class modFacture extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_FACTURE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='bill'; diff --git a/htdocs/includes/modules/modFckeditor.class.php b/htdocs/includes/modules/modFckeditor.class.php index 97f2b3daff3..2dc5ee951b6 100644 --- a/htdocs/includes/modules/modFckeditor.class.php +++ b/htdocs/includes/modules/modFckeditor.class.php @@ -53,7 +53,7 @@ class modFckeditor extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Editeur WYSIWYG"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_FCKEDITOR'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; // Dir diff --git a/htdocs/includes/modules/modFicheinter.class.php b/htdocs/includes/modules/modFicheinter.class.php index 2caa1f624bc..e439bc00723 100644 --- a/htdocs/includes/modules/modFicheinter.class.php +++ b/htdocs/includes/modules/modFicheinter.class.php @@ -59,7 +59,7 @@ class modFicheinter extends DolibarrModules $this->revision = explode(" ","$Revision$"); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_FICHEINTER'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto = "intervention"; diff --git a/htdocs/includes/modules/modFournisseur.class.php b/htdocs/includes/modules/modFournisseur.class.php index d743226381f..f283ad1e38e 100644 --- a/htdocs/includes/modules/modFournisseur.class.php +++ b/htdocs/includes/modules/modFournisseur.class.php @@ -56,7 +56,7 @@ class modFournisseur extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_FOURNISSEUR'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='company'; diff --git a/htdocs/includes/modules/modImport.class.php b/htdocs/includes/modules/modImport.class.php index fc670ef319a..09704862626 100644 --- a/htdocs/includes/modules/modImport.class.php +++ b/htdocs/includes/modules/modImport.class.php @@ -53,7 +53,7 @@ class modImport extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Outils d'imports de donnees Dolibarr (via un assistant)"; $this->version = 'development'; // 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_IMPORT'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto=''; diff --git a/htdocs/includes/modules/modLabel.class.php b/htdocs/includes/modules/modLabel.class.php index 0e2553faf07..6ac5ab82624 100644 --- a/htdocs/includes/modules/modLabel.class.php +++ b/htdocs/includes/modules/modLabel.class.php @@ -54,7 +54,7 @@ class modLabel extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Gestion des etiquettes"; $this->version = 'development'; // 'development' or 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_LABEL'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; $this->picto='label'; diff --git a/htdocs/includes/modules/modLdap.class.php b/htdocs/includes/modules/modLdap.class.php index 1934a70e23f..d0361c2bab9 100644 --- a/htdocs/includes/modules/modLdap.class.php +++ b/htdocs/includes/modules/modLdap.class.php @@ -53,7 +53,7 @@ class modLdap extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Synchronisation Ldap"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_LDAP'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 1; // Dir diff --git a/htdocs/includes/modules/modMailing.class.php b/htdocs/includes/modules/modMailing.class.php index e7601e88063..f3bb20f7a09 100644 --- a/htdocs/includes/modules/modMailing.class.php +++ b/htdocs/includes/modules/modMailing.class.php @@ -53,7 +53,7 @@ class modMailing extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Gestion des EMailings"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_MAILING'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 1; $this->picto='email'; diff --git a/htdocs/includes/modules/modMantis.class.php b/htdocs/includes/modules/modMantis.class.php index f15b60e7857..f101a20d07b 100644 --- a/htdocs/includes/modules/modMantis.class.php +++ b/htdocs/includes/modules/modMantis.class.php @@ -61,7 +61,7 @@ class modMantis extends DolibarrModules // Possible values for version are: 'experimental' or 'dolibarr' or version $this->version = 'dolibarr'; // Id used in llx_const table to manage module status (enabled/disabled) - $this->const_name = 'MAIN_MODULE_MANTIS'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=other) $this->special = 1; // Name of png file (without png) used for this module diff --git a/htdocs/includes/modules/modNotification.class.php b/htdocs/includes/modules/modNotification.class.php index 0834eb9e46c..1370724f2e3 100644 --- a/htdocs/includes/modules/modNotification.class.php +++ b/htdocs/includes/modules/modNotification.class.php @@ -55,7 +55,7 @@ class modNotification extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Gestion des notifications (par mail) sur �v�nement Dolibarr"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_NOTIFICATION'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 1; $this->picto='email'; diff --git a/htdocs/includes/modules/modOSCommerce2.class.php b/htdocs/includes/modules/modOSCommerceWS.class.php similarity index 95% rename from htdocs/includes/modules/modOSCommerce2.class.php rename to htdocs/includes/modules/modOSCommerceWS.class.php index 13c6038c0b5..c6d9c361b8a 100644 --- a/htdocs/includes/modules/modOSCommerce2.class.php +++ b/htdocs/includes/modules/modOSCommerceWS.class.php @@ -39,14 +39,14 @@ include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php"); \brief Classe de description et activation du module OSCommerce2 */ -class modOSCommerce2 extends DolibarrModules +class modOSCommerceWS extends DolibarrModules { /** * \brief Constructeur. Definit les noms, constantes et boites * \param DB handler d'acc�s base */ - function modOSCommerce2($DB) + function modOSCommerceWS($DB) { $this->db = $DB ; $this->numero = 900; @@ -56,7 +56,7 @@ class modOSCommerce2 extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Interface de visualisation d'une boutique OSCommerce via des Web services.\nCe module requiert d'installer les composants dans /oscommerce_ws/ws_server sur OSCommerce. Voir fichier README dans /oscommerce_ws/ws_server"; $this->version = 'experimental'; // 'development' or 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_OSCOMMERCEWS'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 1; // Dir @@ -65,7 +65,7 @@ class modOSCommerce2 extends DolibarrModules // Config pages $this->config_page_url = array(); - // D�pendances + // Dependances $this->depends = array(); $this->requiredby = array(); $this->conflictwith = array("modBoutique"); diff --git a/htdocs/includes/modules/modPhenix.class.php b/htdocs/includes/modules/modPhenix.class.php index c03d25a4b5a..32136bb1488 100644 --- a/htdocs/includes/modules/modPhenix.class.php +++ b/htdocs/includes/modules/modPhenix.class.php @@ -60,7 +60,7 @@ class modPhenix extends DolibarrModules // Possible values for version are: 'experimental' or 'dolibarr' or version $this->version = 'development'; // Id used in llx_const table to manage module status (enabled/disabled) - $this->const_name = 'MAIN_MODULE_PHENIX'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=other) $this->special = 1; // Name of png file (without png) used for this module diff --git a/htdocs/includes/modules/modPostnuke.class.php b/htdocs/includes/modules/modPostnuke.class.php index d8f3b9ffd42..929366de094 100644 --- a/htdocs/includes/modules/modPostnuke.class.php +++ b/htdocs/includes/modules/modPostnuke.class.php @@ -54,7 +54,7 @@ class modPostnuke extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Gestion de l'outil PostNuke"; $this->version = 'development'; // 'development' or 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_POSTNUKE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 1; // Dir diff --git a/htdocs/includes/modules/modPrelevement.class.php b/htdocs/includes/modules/modPrelevement.class.php index 98b586d4b33..acec1a5b72c 100644 --- a/htdocs/includes/modules/modPrelevement.class.php +++ b/htdocs/includes/modules/modPrelevement.class.php @@ -58,7 +58,7 @@ class modPrelevement extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_PRELEVEMENT'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; // Name of png file (without png) used for this module $this->picto='payment'; diff --git a/htdocs/includes/modules/modProduit.class.php b/htdocs/includes/modules/modProduit.class.php index 417356f909c..65fc6fc4386 100644 --- a/htdocs/includes/modules/modProduit.class.php +++ b/htdocs/includes/modules/modProduit.class.php @@ -61,7 +61,7 @@ class modProduit extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_PRODUIT'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='product'; diff --git a/htdocs/includes/modules/modProjet.class.php b/htdocs/includes/modules/modProjet.class.php index 7c6680ffdd6..25898174cc0 100644 --- a/htdocs/includes/modules/modProjet.class.php +++ b/htdocs/includes/modules/modProjet.class.php @@ -56,7 +56,7 @@ class modProjet extends DolibarrModules $this->description = "Gestion des projets"; $this->revision = explode(" ","$Revision$"); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_PROJET'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='email'; diff --git a/htdocs/includes/modules/modPropale.class.php b/htdocs/includes/modules/modPropale.class.php index 8462eb30e50..15eb512a747 100644 --- a/htdocs/includes/modules/modPropale.class.php +++ b/htdocs/includes/modules/modPropale.class.php @@ -58,7 +58,7 @@ class modPropale extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_PROPALE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='propal'; diff --git a/htdocs/includes/modules/modService.class.php b/htdocs/includes/modules/modService.class.php index 9d08ec1ac5b..28a1171e08a 100644 --- a/htdocs/includes/modules/modService.class.php +++ b/htdocs/includes/modules/modService.class.php @@ -59,7 +59,7 @@ class modService extends DolibarrModules $this->revision = explode(" ","$Revision$"); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_SERVICE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='service'; diff --git a/htdocs/includes/modules/modSociete.class.php b/htdocs/includes/modules/modSociete.class.php index 3fdccf076e5..f2263291f69 100644 --- a/htdocs/includes/modules/modSociete.class.php +++ b/htdocs/includes/modules/modSociete.class.php @@ -60,7 +60,7 @@ class modSociete extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_SOCIETE'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->config_page_url = array("societe.php"); $this->picto='company'; diff --git a/htdocs/includes/modules/modStock.class.php b/htdocs/includes/modules/modStock.class.php index c378d5f8f9d..e5c2d4f93e9 100644 --- a/htdocs/includes/modules/modStock.class.php +++ b/htdocs/includes/modules/modStock.class.php @@ -57,7 +57,7 @@ class modStock extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_STOCK'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='stock'; diff --git a/htdocs/includes/modules/modSyslog.class.php b/htdocs/includes/modules/modSyslog.class.php index b7b109f49c2..644de66c799 100644 --- a/htdocs/includes/modules/modSyslog.class.php +++ b/htdocs/includes/modules/modSyslog.class.php @@ -52,7 +52,7 @@ class modSyslog extends DolibarrModules $this->name = eregi_replace('^mod','',get_class($this)); $this->description = "Activation des traces debug (syslog)"; $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version - $this->const_name = 'MAIN_MODULE_SYSLOG'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; //$this->picto='phoning'; diff --git a/htdocs/includes/modules/modTax.class.php b/htdocs/includes/modules/modTax.class.php index bd73dca0fe1..28821575813 100644 --- a/htdocs/includes/modules/modTax.class.php +++ b/htdocs/includes/modules/modTax.class.php @@ -60,7 +60,7 @@ class modTax extends DolibarrModules $this->revision = explode(" ","$Revision$"); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_TAX'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='bill'; diff --git a/htdocs/includes/modules/modTelephonie.class.php b/htdocs/includes/modules/modTelephonie.class.php index 286b55892ed..127fe44aef3 100644 --- a/htdocs/includes/modules/modTelephonie.class.php +++ b/htdocs/includes/modules/modTelephonie.class.php @@ -59,7 +59,7 @@ class modTelephonie extends DolibarrModules $this->revision = explode(" ","$Revision$"); $this->version = $this->revision[1]; - $this->const_name = "MAIN_MODULE_TELEPHONIE"; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 2; $this->picto='phoning'; diff --git a/htdocs/includes/modules/modUser.class.php b/htdocs/includes/modules/modUser.class.php index 0510d74054c..ac4f2091b5b 100644 --- a/htdocs/includes/modules/modUser.class.php +++ b/htdocs/includes/modules/modUser.class.php @@ -58,7 +58,7 @@ class modUser extends DolibarrModules $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; - $this->const_name = 'MAIN_MODULE_USER'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; $this->picto='group'; diff --git a/htdocs/includes/modules/modWebcalendar.class.php b/htdocs/includes/modules/modWebcalendar.class.php index 2c263847945..55a012a22bd 100644 --- a/htdocs/includes/modules/modWebcalendar.class.php +++ b/htdocs/includes/modules/modWebcalendar.class.php @@ -61,7 +61,7 @@ class modWebcalendar extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (XXX is id value) - $this->const_name = 'MAIN_MODULE_WEBCALENDAR'; + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=other) $this->special = 1; // Name of png file (without png) used for this module -- GitLab