From 1c523abbd838cbd454f83e8015e8a2d49364e716 Mon Sep 17 00:00:00 2001 From: "DEMAREST Maxime (Indelog)" Date: Sat, 12 Sep 2020 08:51:58 +0200 Subject: [PATCH 1/8] Fix: getLabelOfUnit() for Product, CommonObjectline to print long label Also add $type = 'code' for return unit code in form 'unitXX' (where XX is the code of unit). for get return like unitXX where XX is the code of unit --- htdocs/core/class/commonobjectline.class.php | 17 ++++++++--------- htdocs/product/class/product.class.php | 12 ++++++------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 4874dded08d..5d03c91ca4b 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -54,7 +54,7 @@ abstract class CommonObjectLine extends CommonObject * Returns the translation key from units dictionary. * A langs->trans() must be called on result to get translated value. * - * @param string $type Label type (long or short). This can be a translation key. + * @param string $type Label type (long, short or code). This can be a translation key. * @return string|int <0 if ko, label if ok */ public function getLabelOfUnit($type = 'long') @@ -69,17 +69,16 @@ abstract class CommonObjectLine extends CommonObject $label_type = 'label'; - if ($type == 'short') - { - $label_type = 'short_label'; - } + $label_type = 'label'; + if ($type == 'short') $label_type = 'short_label'; + elseif ($type == 'code') $label_type = 'code'; - $sql = 'select '.$label_type.',code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit; + $sql = 'select '.$label_type.', code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit; $resql = $this->db->query($sql); - if ($resql && $this->db->num_rows($resql) > 0) - { + if ($resql && $this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); - $label = ($label_type == 'short' ? $res[$label_type] : 'unit'.$res['code']); + if ($label_type == 'code') $label = 'unit'.$res['code']; + else $label = $res[$label_type]; $this->db->free($resql); return $label; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d1f36ca055d..b5f278bcf61 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5368,8 +5368,9 @@ class Product extends CommonObject /** * Returns the text label from units dictionary + * A langs->trans() must be called on result to get translated value. * - * @param string $type Label type (long or short) + * @param string $type Label type (long, short or code) * @return string|int <0 if ko, label if ok */ public function getLabelOfUnit($type = 'long') @@ -5383,16 +5384,15 @@ class Product extends CommonObject $langs->load('products'); $label_type = 'label'; - - if ($type == 'short') { - $label_type = 'short_label'; - } + if ($type == 'short') $label_type = 'short_label'; + elseif ($type == 'code') $label_type = 'code'; $sql = 'select '.$label_type.', code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit; $resql = $this->db->query($sql); if ($resql && $this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); - $label = ($label_type == 'short_label' ? $res[$label_type] : 'unit'.$res['code']); + if ($label_type == 'code') $label = 'unit'.$res['code']; + else $label = $res[$label_type]; $this->db->free($resql); return $label; } From 76fc8330a31ed7b2418c356efbb13276e88591db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Sep 2020 13:45:28 +0200 Subject: [PATCH 2/8] Fix for wampserver3_64 Conflicts: build/exe/doliwamp/doliwamp.iss --- build/exe/doliwamp/doliwamp.iss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 4a6dca3af01..ed8e07d7468 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -104,8 +104,8 @@ Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversi ; Value OK: apache 2.2.6, php 5.2.5 (5.2.11, 5.3.0 and 5.3.1 fails if php_exif, php_pgsql, php_zip is on), mysql 5.0.45 ; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45 ; Value OK: apache 2.4.9, php 5.5.12, mysql 5.0.45 instead of 5.6.17 (wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe) -; Value To test: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe) -Source: "C:\Program Files\Wamp\apps\phpmyadmin4.1.14\*.*"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" +; Value OK: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe) +Source: "C:\wamp64\apps\phpmyadmin4.9.2\*.*"; DestDir: "{app}\apps\phpmyadmin4.9.2"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" ;Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" Source: "C:\wamp64\bin\apache\apache2.4.41\*.*"; DestDir: "{app}\bin\apache\apache2.4.41"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" ;Source: "C:\Program Files\Wamp\bin\php\php5.5.12\*.*"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log" From a4fb16b4f30277c263dc8086b11655289b8c3294 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 00:03:49 +0200 Subject: [PATCH 3/8] Add a warning to warn about security leak --- htdocs/admin/system/dolibarr.php | 18 ++++++++++-------- htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 0796d934a74..97e7370a148 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -376,8 +376,7 @@ foreach ($configfileparameters as $key => $value) print ""; if ($newkey == 'dolibarr_main_db_pass') print preg_replace('/./i', '*', ${$newkey}); elseif ($newkey == 'dolibarr_main_url_root' && preg_match('/__auto__/', ${$newkey})) print ${$newkey}.' => '.constant('DOL_MAIN_URL_ROOT'); - elseif ($newkey == 'dolibarr_main_document_root_alt') - { + elseif ($newkey == 'dolibarr_main_document_root_alt') { $tmparray = explode(',', ${$newkey}); $i = 0; foreach ($tmparray as $value2) @@ -391,9 +390,7 @@ foreach ($configfileparameters as $key => $value) } ++$i; } - } - elseif ($newkey == 'dolibarr_main_instance_unique_id') - { + } elseif ($newkey == 'dolibarr_main_instance_unique_id') { //print $conf->file->instance_unique_id; global $dolibarr_main_cookie_cryptkey; $valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey @@ -402,9 +399,14 @@ foreach ($configfileparameters as $key => $value) print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); } print '   ('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')'; - } - else - { + } elseif ($newkey == 'dolibarr_main_prod') { + print ${$newkey}; + + $valuetoshow = ${$newkey}; + if (empty($valuetoshow)) { + print img_warning($langs->trans('SwitchThisForABetterSecurity')); + } + } else { print ${$newkey}; } if ($newkey == 'dolibarr_main_url_root' && ${$newkey} != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 482f89b30e7..ed10332352c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2022,3 +2022,4 @@ MeasuringScaleDesc=The scale is the number of places you have to move the decima TemplateAdded=Template added TemplateUpdated=Template updated TemplateDeleted=Template deleted +SwitchThisForABetterSecurity=Switching this value to 1 is recommended for more security From 0d9d9498e2623e2d850767d109c071dbdaae02fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 00:13:12 +0200 Subject: [PATCH 4/8] Update commonobjectline.class.php --- htdocs/core/class/commonobjectline.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 5d03c91ca4b..a68d5c22002 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -51,7 +51,7 @@ abstract class CommonObjectLine extends CommonObject /** - * Returns the translation key from units dictionary. + * Returns the label, shot_label or code found in units dictionary from ->fk_unit. * A langs->trans() must be called on result to get translated value. * * @param string $type Label type (long, short or code). This can be a translation key. From d0698735d61969ce96474de6b78de5e5ed94c6f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 00:14:25 +0200 Subject: [PATCH 5/8] Update product.class.php --- htdocs/product/class/product.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index b5f278bcf61..99590e27a36 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5367,11 +5367,12 @@ class Product extends CommonObject } /** - * Returns the text label from units dictionary - * A langs->trans() must be called on result to get translated value. + * Returns the label, shot_label or code found in units dictionary from ->fk_unit. + * A langs->trans() must be called on result to get translated value. * * @param string $type Label type (long, short or code) * @return string|int <0 if ko, label if ok + * @see getLabelOfUnit() in CommonObjectLine */ public function getLabelOfUnit($type = 'long') { From c3ba8f7843461fe26a5c90a69c0eb5ddf19a109b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 02:13:27 +0200 Subject: [PATCH 6/8] Better translation --- htdocs/core/tpl/objectline_title.tpl.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index f04bfc50da8..88a8d69cdf7 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -59,7 +59,13 @@ if ($this->element == 'supplier_proposal' || $this->element == 'order_supplier' } // VAT -print ''.$langs->trans('VAT').''; +print ''; +if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FACTURE_LOCAL_TAX1_OPTION)) { + print $langs->trans('Taxes'); +} else { + print $langs->trans('VAT'); +} +print ''; // Price HT print ''.$langs->trans('PriceUHT').''; From a891211f78d804bf92dc22c3fc8ac2d064602aa0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 02:32:30 +0200 Subject: [PATCH 7/8] Fix bad link --- htdocs/adherents/stats/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 10eca32ac13..762a7d666c7 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -183,9 +183,9 @@ foreach ($data as $val) $oldyear--; print ''; print ''; - print ''; + //print ''; print $oldyear; - print ''; + //print ''; print ''; print '0'; print '0'; From 701b83db3851d442c2411a304ef52fd7cd9f9726 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 02:38:12 +0200 Subject: [PATCH 8/8] FIX Bad number of subscription (forgotten when member was resiliated) --- htdocs/adherents/class/adherentstats.class.php | 2 +- htdocs/adherents/stats/byproperties.php | 6 +++--- htdocs/adherents/stats/geo.php | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index bdb174cc0bd..eff42f92a43 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -68,7 +68,7 @@ class AdherentStats extends Stats $this->field = 'subscription'; - $this->where .= " m.statut != 0"; + $this->where .= " m.statut != -1"; $this->where .= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")"; //if (!$user->rights->societe->client->voir && !$user->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($this->memberid) diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 7927c2e3f00..3a6a7eb0342 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -108,19 +108,19 @@ dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'use // Print title if (!count($data)) { - print $langs->trans("NoValidatedMemberYet").'
'; + print ''.$langs->trans("NoValidatedMemberYet").'
'; print '
'; } else { - print $langs->trans("MembersByNature").'
'; + print ''.$langs->trans("MembersByNature").'
'; print '
'; } // Print array print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 5b51008a9a2..db556c0eea7 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -221,13 +221,13 @@ if ($mode && !count($data)) } else { - if ($mode == 'memberbycountry') print $langs->trans("MembersByCountryDesc").'
'; - elseif ($mode == 'memberbystate') print $langs->trans("MembersByStateDesc").'
'; - elseif ($mode == 'memberbytown') print $langs->trans("MembersByTownDesc").'
'; - elseif ($mode == 'memberbyregion') print $langs->trans("MembersByRegion").'
'; //+ + if ($mode == 'memberbycountry') print ''.$langs->trans("MembersByCountryDesc").'
'; + elseif ($mode == 'memberbystate') print ''.$langs->trans("MembersByStateDesc").'
'; + elseif ($mode == 'memberbytown') print ''.$langs->trans("MembersByTownDesc").'
'; + elseif ($mode == 'memberbyregion') print ''.$langs->trans("MembersByRegion").'
'; //+ else { - print $langs->trans("MembersStatisticsDesc").'
'; + print ''.$langs->trans("MembersStatisticsDesc").'
'; print '
'; print ''.$langs->trans("MembersStatisticsByCountries").'
'; print '
';
'.$langs->trans("Nature").''.$langs->trans("MemberNature").''.$langs->trans("NbOfMembers").''.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'