From d76802630a71267c681363d8985d0d93462817a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Mar 2012 09:26:14 +0100 Subject: [PATCH 1/5] Doxygen --- .../modules/contract/modules_contract.php | 3 ++ htdocs/core/modules/dons/modules_don.php | 2 +- .../modules/export/export_csv.modules.php | 35 +++++++++++++++++ .../modules/export/export_excel.modules.php | 39 ++++++++++++++++++- .../export/export_excel2007.modules.php | 39 ++++++++++++++++++- .../modules/export/export_tsv.modules.php | 35 +++++++++++++++++ htdocs/core/modules/export/modules_export.php | 30 +++++++++++--- 7 files changed, 172 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/contract/modules_contract.php b/htdocs/core/modules/contract/modules_contract.php index 768785f090c..9b501f4529c 100755 --- a/htdocs/core/modules/contract/modules_contract.php +++ b/htdocs/core/modules/contract/modules_contract.php @@ -27,6 +27,9 @@ * \brief File of class to manage contract numbering */ +/** + * Parent class for all contract numbering modules + */ class ModelNumRefContracts { var $error=''; diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index 98976087f92..079c22afa92 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -156,7 +156,7 @@ function don_create($db, $id, $message, $modele, $outputlangs) $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/"; - // Positionne modele sur le nom du modele � utiliser + // Set template to use if (! dol_strlen($modele)) { if ($conf->global->DON_ADDON_MODEL) diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php index 36e4e91115b..a7cd25c270a 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csv.modules.php @@ -72,36 +72,71 @@ class ExportCsv extends ModeleExports } + /** + * getDriverId + * + * @return int + */ function getDriverId() { return $this->id; } + /** + * getDriverLabel + * + * @return string + */ function getDriverLabel() { return $this->label; } + /** + * getDriverDesc + * + * @return string + */ function getDriverDesc() { return $this->desc; } + /** + * getDriverExtension + * + * @return string + */ function getDriverExtension() { return $this->extension; } + /** + * getDriverVersion + * + * @return string + */ function getDriverVersion() { return $this->version; } + /** + * getLabelLabel + * + * @return string + */ function getLibLabel() { return $this->label_lib; } + /** + * getLibVersion + * + * @return string + */ function getLibVersion() { return $this->version_lib; diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php index ba8df1e61c7..c63dbe63cc5 100644 --- a/htdocs/core/modules/export/export_excel.modules.php +++ b/htdocs/core/modules/export/export_excel.modules.php @@ -71,36 +71,71 @@ class ExportExcel extends ModeleExports $this->row=0; } + /** + * getDriverId + * + * @return int + */ function getDriverId() { return $this->id; } + /** + * getDriverLabel + * + * @return string + */ function getDriverLabel() { return $this->label; } - function getDriverDesc() + /** + * getDriverDesc + * + * @return string + */ + function getDriverDesc() { return $this->desc; } - function getDriverExtension() + /** + * getDriverExtension + * + * @return string + */ + function getDriverExtension() { return $this->extension; } + /** + * getDriverVersion + * + * @return string + */ function getDriverVersion() { return $this->version; } + /** + * getLibLabel + * + * @return string + */ function getLibLabel() { return $this->label_lib; } + /** + * getLibVersion + * + * @return string + */ function getLibVersion() { return $this->version_lib; diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index 393a05d1530..19316e61e2b 100755 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -72,36 +72,71 @@ class ExportExcel2007 extends ExportExcel $this->row=0; } + /** + * getDriverLabel + * + * @return int + */ function getDriverId() { return $this->id; } + /** + * getDriverLabel + * + * @return string + */ function getDriverLabel() { return $this->label; } - function getDriverDesc() + /** + * getDriverDesc + * + * @return string + */ + function getDriverDesc() { return $this->desc; } - function getDriverExtension() + /** + * getDriverExtension + * + * @return string + */ + function getDriverExtension() { return $this->extension; } + /** + * getDriverVersion + * + * @return string + */ function getDriverVersion() { return $this->version; } + /** + * getLibLabel + * + * @return string + */ function getLibLabel() { return $this->label_lib; } + /** + * getLibVersion + * + * @return string + */ function getLibVersion() { return $this->version_lib; diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index 8e807aa2fcd..b8ef3ba491c 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -66,36 +66,71 @@ class ExportTsv extends ModeleExports $this->version_lib=DOL_VERSION; } + /** + * getDriverId + * + * @return int + */ function getDriverId() { return $this->id; } + /** + * getDriverLabel + * + * @return string + */ function getDriverLabel() { return $this->label; } + /** + * getDriverDesc + * + * @return string + */ function getDriverDesc() { return $this->desc; } + /** + * getDriverExtension + * + * @return string + */ function getDriverExtension() { return $this->extension; } + /** + * getDriverVersion + * + * @return string + */ function getDriverVersion() { return $this->version; } + /** + * getLibLabel + * + * @return string + */ function getLibLabel() { return $this->label_lib; } + /** + * getLibVersion + * + * @return string + */ function getLibVersion() { return $this->version_lib; diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index c4f879f1fbc..2a7cbbea609 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -92,7 +92,10 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac /** - * \brief Return picto of export driver + * Return picto of export driver + * + * @param string $key Key of driver + * @return string Picto string */ function getPicto($key) { @@ -100,7 +103,10 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac } /** - * \brief Renvoi libelle d'un driver export + * Renvoi libelle d'un driver export + * + * @param string $key Key of driver + * @return string Label */ function getDriverLabel($key) { @@ -108,7 +114,10 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac } /** - * \brief Renvoi le descriptif d'un driver export + * Renvoi le descriptif d'un driver export + * + * @param string $key Key of driver + * @return string Description */ function getDriverDesc($key) { @@ -116,7 +125,10 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac } /** - * \brief Renvoi version d'un driver export + * Renvoi version d'un driver export + * + * @param string $key Key of driver + * @return string Driver version */ function getDriverVersion($key) { @@ -124,7 +136,10 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac } /** - * \brief Renvoi libelle de librairie externe du driver + * Renvoi libelle de librairie externe du driver + * + * @param string $key Key of driver + * @return string Label of library */ function getLibLabel($key) { @@ -132,7 +147,10 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac } /** - * \brief Renvoi version de librairie externe du driver + * Renvoi version de librairie externe du driver + * + * @param string $key Key of driver + * @return string Version of library */ function getLibVersion($key) { From 3a8885eea65f75c4faa156b9f81923dbaca4cf4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Mar 2012 09:36:39 +0100 Subject: [PATCH 2/5] Fix: If a project must be linked to any companies (suppliers or not), project must be not be set as limited to customer but must be not linked to any particular thirdparty --- htdocs/fichinter/fiche.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index c381fe14b94..e618463fef9 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -693,13 +693,15 @@ if ($action == 'create') if ($conf->projet->enabled) { $langs->load("project"); - + print ''.$langs->trans("Project").''; + /* Fix: If a project must be linked to any companies (suppliers or not), project must be not be set as limited to customer but must be not linked to any particular thirdparty if ($societe->fournisseur==1) $numprojet=select_projects(-1,$_POST["projectid"],'projectid'); else $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid'); - //$numprojet=select_projects($soc->id,GETPOST('projectid','int'),'projectid'); + */ + $numprojet=select_projects($soc->id,GETPOST('projectid','int'),'projectid'); if ($numprojet==0) { print '   '.$langs->trans("AddProject").''; From 62e0814041f3f212cddadee20033ea1aaf97f5fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Mar 2012 09:46:44 +0100 Subject: [PATCH 3/5] Fix: Removed not standard/compatible SQL. External module should not have foreign keys with standard tables. This creates dependencies and instabilities of core code. Integrity must be checked by applications for external modules, not by database. --- htdocs/install/mysql/migration/3.1.0-3.2.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql index f2b9a4bbe7f..80606c4f6ac 100755 --- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql +++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql @@ -272,7 +272,7 @@ ALTER TABLE llx_product_extrafields ADD COLUMN import_key varchar(14); ALTER TABLE llx_societe_extrafields ADD COLUMN import_key varchar(14); -- Disable foreign key checks for external modules constraints -SET FOREIGN_KEY_CHECKS=0; +--SET FOREIGN_KEY_CHECKS=0; DROP TABLE llx_c_currencies; create table llx_c_currencies @@ -425,7 +425,7 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'XEU' INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'ARP', NULL, 0, 'Pesos argentins'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MXP', NULL, 0, 'Pesos Mexicans'); -SET FOREIGN_KEY_CHECKS=1; +--SET FOREIGN_KEY_CHECKS=1; ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_currency FOREIGN KEY (fk_currency) REFERENCES llx_c_currencies (code_iso); ALTER TABLE llx_commande ADD CONSTRAINT fk_commande_fk_currency FOREIGN KEY (fk_currency) REFERENCES llx_c_currencies (code_iso); From 5edcc198207e3877e6f40032396bdb5d4a508f42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Mar 2012 15:47:01 +0100 Subject: [PATCH 4/5] Add a protection for duplicate modules --- htdocs/admin/modules.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 40b736596a5..636b7ee1c85 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -105,6 +105,7 @@ $categ = array(); $dirmod = array(); $i = 0; // is a sequencer of modules found $j = 0; // j is module number. Automatically affected if module number not defined. +$modNameLoaded=array(); foreach ($modulesdir as $dir) { @@ -123,10 +124,18 @@ foreach ($modulesdir as $dir) if ($modName) { + if (in_array($modName,$modNameLoaded)) + { + $mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; + dol_syslog($mesg, LOG_ERR); + continue; + } + try { $res=include_once($dir.$file); $objMod = new $modName($db); + $modNameLoaded[$modName]=$dir; if ($objMod->numero > 0) { From 62801532a7a086967abb7928c7c2758c9b5e288e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Mar 2012 16:01:56 +0100 Subject: [PATCH 5/5] Add a protection for duplicate modules --- htdocs/admin/modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 636b7ee1c85..184e679e1fc 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -124,7 +124,7 @@ foreach ($modulesdir as $dir) if ($modName) { - if (in_array($modName,$modNameLoaded)) + if (! empty($modNameLoaded[$modName])) { $mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; dol_syslog($mesg, LOG_ERR);