From 7f209f7cc720cb66e995a97d80d9f2f9752dd94e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Mar 2021 02:55:24 +0100 Subject: [PATCH] Clean code --- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 19 +++++++++++-------- htdocs/core/class/dolgeoip.class.php | 2 +- htdocs/install/upgrade2.php | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 375ba4a53ff..84a7d2376c1 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -490,7 +490,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'classifyunbilled' && $usercancreate) { - $ret = $object->classifyUnBilled(); + $ret = $object->classifyUnBilled($user); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index aac06dc4775..4d5f75c7c24 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2962,11 +2962,12 @@ class Commande extends CommonOrder /** * Classify the order as not invoiced * - * @return int <0 if ko, >0 if ok + * @param User $user Object user making the change + * @param int $notrigger 1=Does not execute triggers, 0=execute triggers + * @return int <0 if ko, >0 if ok */ - public function classifyUnBilled() + public function classifyUnBilled(User $user, $notrigger = 0) { - global $conf, $user, $langs; $error = 0; $this->db->begin(); @@ -2981,12 +2982,14 @@ class Commande extends CommonOrder $this->billed = 1; } - // Call trigger - $result = $this->call_trigger('ORDER_CLASSIFY_UNBILLED', $user); - if ($result < 0) { - $error++; + if (!$notrigger && empty($error)) { + // Call trigger + $result = $this->call_trigger('ORDER_CLASSIFY_UNBILLED', $user); + if ($result < 0) { + $error++; + } + // End call triggers } - // End call triggers if (!$error) { $this->billed = 0; diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 0eecbbf6d36..e7b48286e29 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -129,7 +129,7 @@ class DolGeoIP } } else { if (!function_exists('geoip_country_code_by_addr')) { - return strtolower(geoip_country_code_by_name($this->gi, $ip)); + return strtolower(geoip_country_code_by_name($ip)); } return strtolower(geoip_country_code_by_addr($this->gi, $ip)); } diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index f3ae7df6ed3..d613e4a18b0 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4169,7 +4169,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod = new modBlockedLog($db); // For this module we only reload menus. $mod->delete_menus(); - $mod->insert_menus($reloadmode); + $mod->insert_menus(); } } elseif ($moduletoreload == 'MAIN_MODULE_CRON') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module");