diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index a8f38ccb9d5..be9df9fe313 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -537,7 +537,7 @@ class PaymentVAT extends CommonObject $this->id = 0; $this->fk_tva = 0; $this->datec = dol_now(); - $this->tms = ''; + $this->tms = dol_now(); $this->datep = ''; $this->amount = ''; $this->fk_typepaiement = 0; diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 52b8cb65504..b84e74dfe18 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -50,7 +50,7 @@ class box_activity extends ModeleBoxes $this->db = $db; // FIXME: Pb into some status - $this->enabled = (getDolGlobalString('MAIN_FEATURES_LEVEL')); // Not enabled by default due to bugs (see previous comments) + $this->enabled = getDolGlobalInt('MAIN_FEATURES_LEVEL'); // Not enabled by default due to bugs (see previous comments) $this->hidden = !( (isModEnabled('facture') && $user->hasRight('facture', 'read')) diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index e99f4660a30..1bfd9688e2c 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -64,7 +64,7 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo public $max = 5; /** - * @var int Condition to have widget enabled + * @var bool|int Condition to have widget enabled */ public $enabled = 1; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c8f8a31b1dc..d3f619d19b6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -206,6 +206,28 @@ function getDolUserInt($key, $default = 0, $tmpuser = null) return (int) (empty($tmpuser->conf->$key) ? $default : $tmpuser->conf->$key); } +define( + 'DEPRECATED_MODULE_MAPPING', + array( + 'actioncomm' => 'agenda', + 'adherent' => 'member', + 'adherent_type' => 'member_type', + 'banque' => 'bank', + 'categorie' => 'category', + 'commande' => 'order', + 'contrat' => 'contract', + 'entrepot' => 'stock', + 'expedition' => 'delivery_note', + 'facture' => 'invoice', + 'fichinter' => 'intervention', + 'product_fournisseur_price' => 'productsupplierprice', + 'product_price' => 'productprice', + 'projet' => 'project', + 'propale' => 'propal', + 'socpeople' => 'contact', + ) +); + /** * Is Dolibarr module enabled * @@ -217,17 +239,7 @@ function isModEnabled($module) global $conf; // Fix old names (map to new names) - $arrayconv = array( - 'adherent' => 'member', - 'banque' => 'bank', - 'categorie' => 'category', - 'commande' => 'order', - 'contrat' => 'contract', - 'expedition' => 'delivery_note', - 'facture' => 'invoice', - 'projet' => 'project', - 'propale' => 'propal', - ); + $arrayconv = DEPRECATED_MODULE_MAPPING; if (!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) { // Special cases: both use the same module. diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 1b3b4b62d09..1604e31760e 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -397,7 +397,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it public $enabled_bydefault; /** - * @var bool Whether to hide the module. + * @var bool|int Whether to hide the module. */ public $hidden = false; diff --git a/htdocs/core/modules/modCollab.class.php b/htdocs/core/modules/modCollab.class.php index d08a8438954..be1edcb8c62 100644 --- a/htdocs/core/modules/modCollab.class.php +++ b/htdocs/core/modules/modCollab.class.php @@ -65,7 +65,7 @@ class modCollab extends DolibarrModules // Dependencies //------------- - $this->hidden = getDolGlobalString('MODULE_COLLAB_DISABLED'); // A condition to disable module + $this->hidden = getDolGlobalInt('MODULE_COLLAB_DISABLED'); // A condition to disable module $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 44d9962ef6c..29daa7d61bf 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -66,7 +66,7 @@ class modCron extends DolibarrModules // Dependencies //------------- - $this->hidden = getDolGlobalString('MODULE_CRON_DISABLED'); // A condition to disable module + $this->hidden = getDolGlobalInt('MODULE_CRON_DISABLED'); // A condition to disable module $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with diff --git a/htdocs/core/modules/modSocialNetworks.class.php b/htdocs/core/modules/modSocialNetworks.class.php index 4f007a0d9e3..a62b249f410 100644 --- a/htdocs/core/modules/modSocialNetworks.class.php +++ b/htdocs/core/modules/modSocialNetworks.class.php @@ -64,7 +64,7 @@ class modSocialNetworks extends DolibarrModules $this->config_page_url = array(DOL_URL_ROOT.'/admin/dict.php?id=38'); // Dependencies - $this->hidden = getDolGlobalString('MODULE_SOCIALNETWORKS_DISABLED'); // A condition to hide module + $this->hidden = getDolGlobalInt('MODULE_SOCIALNETWORKS_DISABLED'); // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index ed237feadf6..d61b3ba3628 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -281,8 +281,8 @@ class modTakePos extends DolibarrModules if ($searchcompanyid == 0) { $societe->name = $nametouse; $societe->client = 1; - $societe->code_client = -1; - $societe->code_fournisseur = -1; + $societe->code_client = '-1'; + $societe->code_fournisseur = '-1'; $societe->note_private = "Default customer automatically created by Point Of Sale module activation. Can be used as the default generic customer in the Point Of Sale setup. Can also be edited or removed if you don't need a generic customer."; $searchcompanyid = $societe->create($user); diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index f75acbf713b..d7afc7921b7 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -61,7 +61,7 @@ class modWebsite extends DolibarrModules $this->config_page_url = array('website.php'); // Dependencies - $this->hidden = getDolGlobalString('MODULE_WEBSITE_DISABLED'); // A condition to disable module + $this->hidden = getDolGlobalInt('MODULE_WEBSITE_DISABLED'); // A condition to disable module $this->depends = array('modFckeditor'); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 38a880f1d6c..687d484283c 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -720,10 +720,10 @@ class Dolresource extends CommonObject $this->element_type = trim($this->element_type); } if (isset($this->busy)) { - $this->busy = trim($this->busy); + $this->busy = (int) $this->busy; } if (isset($this->mandatory)) { - $this->mandatory = trim($this->mandatory); + $this->mandatory = (int) $this->mandatory; } // Update request diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 7290d9562d6..f39e2540ef3 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -633,6 +633,7 @@ class CodingPhpTest extends CommonClassTest 'commande' => 'order', 'contrat' => 'contract', 'entrepot' => 'stock', + 'expedition' => 'delivery_note', 'facture' => 'invoice', 'fichinter' => 'intervention', 'product_fournisseur_price' => 'productsupplierprice', @@ -647,6 +648,7 @@ class CodingPhpTest extends CommonClassTest 'member_type' => 1, 'bank' => 1, 'category' => 1, + 'delivery_note' => 1, 'order' => 1, 'contract' => 1, 'stock' => 1, @@ -680,7 +682,6 @@ class CodingPhpTest extends CommonClassTest 'ecotax' => 1, 'emailcollector' => 1, 'eventorganization' => 1, - 'expedition' => 1, 'expensereport' => 1, 'export' => 1, 'externalsite' => 1,