diff --git a/.travis.yml b/.travis.yml index 709feaeaa37..0aa5594790a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,10 +35,6 @@ addons: php: - '5.6' -- '7.0' -- '7.1' -- '7.2' -- '7.3' - '7.4' - nightly @@ -304,12 +300,13 @@ script: echo - | - echo "Checking coding style (excluding Pull Requests builds)" + echo "Checking coding style (excluding Pull Requests builds to not overload travis, excluding also for some jobs to avoid duplicate tests)" # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - #phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi + if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4" ] && [ "$DB" = "mysql" ]; then + phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; + fi set +e echo diff --git a/htdocs/adherents/vcard.php b/htdocs/adherents/vcard.php index 32b4a6de2d6..dbdbbc687ea 100644 --- a/htdocs/adherents/vcard.php +++ b/htdocs/adherents/vcard.php @@ -107,7 +107,9 @@ if ($company->id) { } // Si adherent lie a un tiers non de type "particulier" - if ($adherent->typent_code != 'TE_PRIVATE') $v->setOrg($company->name); + if ($company->typent_code != 'TE_PRIVATE') { + $v->setOrg($company->name); + } } // Personal informations diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index a959aee2e54..2f0978ed266 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -66,14 +66,29 @@ print "PHP safe_mode = ".(ini_get('safe_mode') ? ini_get('safe_ print "PHP open_basedir = ".(ini_get('open_basedir') ? ini_get('open_basedir') : yn(0))."
\n"; print '
'; +// XDebug +print ''.$langs->trans("XDebug").': '; +$test = !function_exists('xdebug_is_enabled'); +if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis"); +else { + print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedMayExposeInformation", $langs->transnoentities("XDebug")); + print ' - '.$langs->trans("MoreInformation").' XDebug admin page'; +} +print '
'; + print '
'; print load_fiche_titre($langs->trans("ConfigFile"), '', ''); print ''.$langs->trans("dolibarr_main_prod").': '.$dolibarr_main_prod; if (empty($dolibarr_main_prod)) { - print img_picto('', 'warning').'   '.$langs->trans("IfYouAreOnAProductionSetThis"); + print '   '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 1); +} +print '
'; + +print ''.$langs->trans("dolibarr_nocsrfcheck").': '.$dolibarr_nocsrfcheck; +if (!empty($dolibarr_nocsrfcheck)) { + print img_picto('', 'warning').'   '.$langs->trans("IfYouAreOnAProductionSetThis", 0); } -// dolibarr_main_prod print '
'; @@ -94,20 +109,9 @@ print '
'; print '
'; print '
'; -print load_fiche_titre($langs->trans("Modules"), '', ''); - -// XDebug -print ''.$langs->trans("XDebug").': '; -$test = !function_exists('xdebug_is_enabled'); -if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis"); -else { - print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedMayExposeInformation", $langs->transnoentities("XDebug")); - print ' - '.$langs->trans("MoreInformation").' XDebug admin page'; -} -print '
'; +print load_fiche_titre($langs->trans("DolibarrModules"), '', ''); // Module log -print '
'; print ''.$langs->trans("Syslog").': '; $test = empty($conf->syslog->enabled); if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis"); @@ -118,7 +122,6 @@ else { print '
'; // Module debugbar -print '
'; print ''.$langs->trans("DebugBar").': '; $test = empty($conf->debugbar->enabled); if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis"); @@ -130,7 +133,7 @@ print '
'; print '
'; print '
'; -print load_fiche_titre($langs->trans("SecuritySetup"), '', ''); +print load_fiche_titre($langs->trans("Menu").' '.$langs->trans("SecuritySetup"), '', ''); //print ''.$langs->trans("PasswordEncryption").': '; print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."   (Recommanded value: 'password_hash')
"; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 12759b9fbf2..cb7944e1cac 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -753,7 +753,7 @@ abstract class CommonInvoice extends CommonObject if (!$error) { // Force payment mode of invoice to withdraw - $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1); + $payment_mode_id = dol_getIdFromCode($this->db, ($type == 'bank-transfer' ? 'VIR' : 'PRE'), 'c_paiement', 'code', 'id', 1); if ($payment_mode_id > 0) { $result = $this->setPaymentMethods($payment_mode_id); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5d6771d88df..2bd32df1f05 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5009,7 +5009,7 @@ abstract class CommonObject { $value_arr = GETPOST($postfieldkey, 'array'); // check if an array if (!empty($value_arr)) { - $value_key = implode($value_arr, ','); + $value_key = implode(',', $value_arr); } else { $value_key = ''; } @@ -5801,7 +5801,7 @@ abstract class CommonObject * * @param array $val Array of properties for field to show (used only if ->fields not defined) * @param string $key Key of attribute - * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) + * @param string|array $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value, for array type must be array) * @param string $moreparam To add more parameters on html input tag * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 43588ba0d0e..f8087dc396e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2490,7 +2490,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli // Clean phone parameter $phone = preg_replace("/[\s.-]/", "", trim($phone)); if (empty($phone)) { return ''; } - if ($conf->global->MAIN_PHONE_SEPAR) $separ = $conf->global->MAIN_PHONE_SEPAR; + if (!empty($conf->global->MAIN_PHONE_SEPAR)) $separ = $conf->global->MAIN_PHONE_SEPAR; if (empty($countrycode)) $countrycode = $mysoc->country_code; // Short format for small screens diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index e070985fbfb..959cb45a77e 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -416,8 +416,7 @@ class ImportCsv extends ModeleImports $newval = preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref //print 'Val is now '.$newval.' and is type '.$isidorref."
\n"; - if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor - { + if ($isidorref == 'ref') { // If value into input import file is a ref, we apply the function defined into descriptor $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); $class = $objimport->array_import_convertvalue[0][$val]['class']; $method = $objimport->array_import_convertvalue[0][$val]['method']; @@ -472,8 +471,7 @@ class ImportCsv extends ModeleImports } } } - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeandlabel') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeandlabel') { $isidorref = 'id'; if (!is_numeric($newval) && $newval != '' && !preg_match('/^id:/i', $newval)) $isidorref = 'ref'; $newval = preg_replace('/^(id|ref):/i', '', $newval); @@ -509,11 +507,9 @@ class ImportCsv extends ModeleImports } } } - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'zeroifnull') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'zeroifnull') { if (empty($newval)) $newval = '0'; - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeunits' || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchscalefromcodeunits') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeunits' || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchscalefromcodeunits') { $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); $class = $objimport->array_import_convertvalue[0][$val]['class']; $method = $objimport->array_import_convertvalue[0][$val]['method']; @@ -545,8 +541,7 @@ class ImportCsv extends ModeleImports $error++; } } - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codeclient(0, 0); @@ -554,8 +549,7 @@ class ImportCsv extends ModeleImports //print 'code_client='.$newval; } if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') { if (strtolower($newval) == 'auto') { $newval = $this->thirpartyobject->get_codefournisseur(0, 1); @@ -563,8 +557,7 @@ class ImportCsv extends ModeleImports //print 'code_fournisseur='.$newval; } if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('customer'); @@ -572,8 +565,7 @@ class ImportCsv extends ModeleImports //print 'code_compta='.$newval; } if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('supplier'); @@ -582,8 +574,7 @@ class ImportCsv extends ModeleImports //print 'code_compta_fournisseur='.$newval; } if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getrefifauto') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getrefifauto') { $defaultref = ''; // TODO provide the $modTask (module of generation of ref) as parameter of import_insert function $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; @@ -595,8 +586,7 @@ class ImportCsv extends ModeleImports } if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; $newval = $defaultref; - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'compute') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'compute') { $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); $class = $objimport->array_import_convertvalue[0][$val]['class']; $method = $objimport->array_import_convertvalue[0][$val]['method']; @@ -614,9 +604,10 @@ class ImportCsv extends ModeleImports $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; + } else { + $newval = $arrayrecord[($key - 1)]['val']; //We get new value computed. } - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { $newval = price2num($newval); } diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 14c78087e8c..5502508d350 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -450,8 +450,7 @@ class ImportXlsx extends ModeleImports $newval = preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref //print 'Val is now '.$newval.' and is type '.$isidorref."
\n"; - if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor - { + if ($isidorref == 'ref') { // If value into input import file is a ref, we apply the function defined into descriptor $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); $class = $objimport->array_import_convertvalue[0][$val]['class']; $method = $objimport->array_import_convertvalue[0][$val]['method']; @@ -506,8 +505,7 @@ class ImportXlsx extends ModeleImports } } } - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeandlabel') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeandlabel') { $isidorref = 'id'; if (!is_numeric($newval) && $newval != '' && !preg_match('/^id:/i', $newval)) $isidorref = 'ref'; $newval = preg_replace('/^(id|ref):/i', '', $newval); @@ -543,11 +541,9 @@ class ImportXlsx extends ModeleImports } } } - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'zeroifnull') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'zeroifnull') { if (empty($newval)) $newval = '0'; - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeunits' || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchscalefromcodeunits') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeunits' || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchscalefromcodeunits') { $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); $class = $objimport->array_import_convertvalue[0][$val]['class']; $method = $objimport->array_import_convertvalue[0][$val]['method']; @@ -579,8 +575,7 @@ class ImportXlsx extends ModeleImports $error++; } } - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codeclient(0, 0); @@ -588,8 +583,7 @@ class ImportXlsx extends ModeleImports //print 'code_client='.$newval; } if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') { if (strtolower($newval) == 'auto') { $newval = $this->thirpartyobject->get_codefournisseur(0, 1); @@ -597,8 +591,7 @@ class ImportXlsx extends ModeleImports //print 'code_fournisseur='.$newval; } if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('customer'); @@ -606,8 +599,7 @@ class ImportXlsx extends ModeleImports //print 'code_compta='.$newval; } if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') { if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('supplier'); @@ -616,8 +608,7 @@ class ImportXlsx extends ModeleImports //print 'code_compta_fournisseur='.$newval; } if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getrefifauto') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getrefifauto') { $defaultref = ''; // TODO provide the $modTask (module of generation of ref) as parameter of import_insert function $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; @@ -629,8 +620,7 @@ class ImportXlsx extends ModeleImports } if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; $newval = $defaultref; - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'compute') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'compute') { $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); $class = $objimport->array_import_convertvalue[0][$val]['class']; $method = $objimport->array_import_convertvalue[0][$val]['method']; @@ -648,9 +638,10 @@ class ImportXlsx extends ModeleImports $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; + } else { + $newval = $arrayrecord[($key - 1)]['val']; //We get new value computed. } - } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') - { + } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { $newval = price2num($newval); } diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index de837b16edf..dea5ce60d6e 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -80,7 +80,12 @@ $(document).ready(function(){ console.log("tableDND end of ajax call"); if (reloadpage == 1) { //console.log(''); - location.href = ''; + + location.href = ''; } else { $("# .drag").each( function( intIndex ) { diff --git a/htdocs/install/mysql/data/llx_c_type_contact.sql b/htdocs/install/mysql/data/llx_c_type_contact.sql index d7ec13f5833..f16cf5ca5df 100644 --- a/htdocs/install/mysql/data/llx_c_type_contact.sql +++ b/htdocs/install/mysql/data/llx_c_type_contact.sql @@ -74,13 +74,13 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (150, 'dolresource','internal', 'USERINCHARGE', 'In charge of resource', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (151, 'dolresource','external', 'THIRDINCHARGE', 'In charge of resource', 1); --- All project code must start with 'PROJECT' +-- All project code can start with 'PROJECT' insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (160, 'project', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (161, 'project', 'internal', 'PROJECTCONTRIBUTOR', 'Intervenant', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (170, 'project', 'external', 'PROJECTLEADER', 'Chef de Projet', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (171, 'project', 'external', 'PROJECTCONTRIBUTOR', 'Intervenant', 1); --- All task code must start with 'TASK' +-- All task code can start with 'TASK' insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (180, 'project_task', 'internal', 'TASKEXECUTIVE', 'Responsable', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (181, 'project_task', 'internal', 'TASKCONTRIBUTOR', 'Intervenant', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (190, 'project_task', 'external', 'TASKEXECUTIVE', 'Responsable', 1); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0309706312f..3da5c3aff62 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1679,11 +1679,11 @@ StockSetup=Stock module setup IfYouUsePointOfSaleCheckModule=If you use the Point of Sale module (POS) provided by default or an external module, this setup may be ignored by your POS module. Most POS modules are designed by default to create an invoice immediately and decrease stock irrespective of the options here. So if you need or not to have a stock decrease when registering a sale from your POS, check also your POS module setup. ##### Menu ##### MenuDeleted=Menu deleted +Menu=Menu Menus=Menus TreeMenuPersonalized=Personalized menus NotTopTreeMenuPersonalized=Personalized menus not linked to a top menu entry NewMenu=New menu -Menu=Selection of menu MenuHandler=Menu handler MenuModule=Source module HideUnauthorizedMenu= Hide unauthorized menus (gray) @@ -2037,7 +2037,7 @@ UseDebugBar=Use the debug bar DEBUGBAR_LOGS_LINES_NUMBER=Number of last log lines to keep in console WarningValueHigherSlowsDramaticalyOutput=Warning, higher values slows dramaticaly output ModuleActivated=Module %s is activated and slows the interface -IfYouAreOnAProductionSetThis=If you are on a production environment, you should set this property. +IfYouAreOnAProductionSetThis=If you are on a production environment, you should set this property to %s. AntivirusEnabledOnUpload=Antivirus enabled on uploaded files EXPORTS_SHARE_MODELS=Export models are share with everybody ExportSetup=Setup of module Export diff --git a/htdocs/product/list.php b/htdocs/product/list.php index cce41367024..0142e38698e 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1103,7 +1103,7 @@ if ($resql) // Label if (!empty($arrayfields['p.label']['checked'])) { - print ''.dol_trunc($obj->label, 80).''; + print ''.$obj->label.''; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index b1d5982ead1..29a648acf46 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1233,7 +1233,7 @@ class Project extends CommonObject * @param string $mode Type of permission we want to know: 'read', 'write' * @return int >0 if user has permission, <0 if user has no permission */ - public function restrictedProjectArea($user, $mode = 'read') + public function restrictedProjectArea(User $user, $mode = 'read') { // To verify role of users $userAccess = 0; @@ -1243,7 +1243,7 @@ class Project extends CommonObject } elseif ($this->public && (($mode == 'read' && !empty($user->rights->projet->lire)) || ($mode == 'write' && !empty($user->rights->projet->creer)) || ($mode == 'delete' && !empty($user->rights->projet->supprimer)))) { $userAccess = 1; - } else { + } else { // No access due to permission to read all projects, so we check if we are a contact of project foreach (array('internal', 'external') as $source) { $userRole = $this->liste_contact(4, $source); @@ -1252,7 +1252,13 @@ class Project extends CommonObject $nblinks = 0; while ($nblinks < $num) { - if ($source == 'internal' && preg_match('/^PROJECT/', $userRole[$nblinks]['code']) && $user->id == $userRole[$nblinks]['id']) + if ($source == 'internal' && $user->id == $userRole[$nblinks]['id']) // $userRole[$nblinks]['id'] is id of user (llx_user) for internal contacts + { + if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; + if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; + if ($mode == 'delete' && $user->rights->projet->supprimer) $userAccess++; + } + if ($source == 'external' && $user->socid > 0 && $user->socid == $userRole[$nblinks]['socid']) // $userRole[$nblinks]['id'] is id of contact (llx_socpeople) or external contacts { if ($mode == 'read' && $user->rights->projet->lire) $userAccess++; if ($mode == 'write' && $user->rights->projet->creer) $userAccess++; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 4d3cab8f16a..e67a0f1583d 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -649,6 +649,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). $filteronthirdpartyid = $socid; $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, $extrafields, 1, $search_array_options); + // We load also tasks limited to a particular user $tmpuser = new User($db); if ($search_user_id > 0) $tmpuser->fetch($search_user_id); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index b2c382cdcac..f965b2317bd 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -93,13 +93,13 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) if (empty($task_parent)) $task_parent = 0; // If task_parent is '' $object->ref = $taskref ? $taskref : GETPOST("ref", 'alpha', 2); - $object->label = $_POST["label"]; - $object->description = $_POST['description']; + $object->label = GETPOST("label", "alphanohtml"); + $object->description = GETPOST('description', "alphanohtml"); $object->fk_task_parent = $task_parent; $object->planned_workload = $planned_workload; - $object->date_start = dol_mktime($_POST['dateohour'], $_POST['dateomin'], 0, $_POST['dateomonth'], $_POST['dateoday'], $_POST['dateoyear']); - $object->date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'], $_POST['dateeyear']); - $object->progress = $_POST['progress']; + $object->date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int')); + $object->date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int')); + $object->progress = price2num(GETPOST('progress', 'alphanohtml')); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -182,7 +182,7 @@ if ($action == 'remove_file' && $user->rights->projet->creer) { $langs->load("other"); $upload_dir = $conf->projet->dir_output; - $file = $upload_dir.'/'.GETPOST('file'); + $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file')); $ret = dol_delete_file($file); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); @@ -190,11 +190,11 @@ if ($action == 'remove_file' && $user->rights->projet->creer) } } + /* * View */ - llxHeader('', $langs->trans("Task")); $form = new Form($db); @@ -214,7 +214,7 @@ if ($id > 0 || !empty($ref)) $object->project = clone $projectstatic; - $userWrite = $projectstatic->restrictedProjectArea($user, 'write'); + //$userWrite = $projectstatic->restrictedProjectArea($user, 'write'); if (!empty($withproject)) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f20c246e458..f992c9cd195 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -64,6 +64,9 @@ class User extends CommonObject */ public $ismultientitymanaged = 1; + /** + * @var string picto + */ public $picto = 'user'; public $id = 0; @@ -73,7 +76,15 @@ class User extends CommonObject public $employee; public $gender; public $birth; + + /** + * @var string email + */ public $email; + + /** + * @var string personal email + */ public $personal_email; @@ -90,7 +101,14 @@ class User extends CommonObject */ public $address; + /** + * @var string zip code + */ public $zip; + + /** + * @var string town + */ public $town; public $state_id; // The state/department public $state_code; @@ -108,11 +126,19 @@ class User extends CommonObject */ public $entity; - //! Clear password in memory + /** + * @var string Clear password in memory + */ public $pass; - //! Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) + + /** + * @var string Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) + */ public $pass_indatabase; - //! Encrypted password in database (always defined) + + /** + * @var string Encrypted password in database (always defined) + */ public $pass_indatabase_crypted; /** @@ -140,9 +166,10 @@ class User extends CommonObject public $fk_member; /** - * @var int User ID + * @var int User ID of supervisor */ public $fk_user; + public $fk_user_expense_validator; public $fk_user_holiday_validator; @@ -290,8 +317,8 @@ class User extends CommonObject } else { $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database } - } else // The fetch was forced on an entity - { + } else { + // The fetch was forced on an entity if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database } else { diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 245a7869811..3e065bb141c 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -170,7 +170,7 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase $filecontent = str_replace('`rank`', '_rank_', $filecontent); $result=strpos($filecontent, '`'); - print __METHOD__." Result for checking we don't have back quote = ".$result."\n"; + //print __METHOD__." Result for checking we don't have back quote = ".$result."\n"; $this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.'); $result=strpos($filecontent, '"'); @@ -178,27 +178,27 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase { $result=(! strpos($filecontent, '["') && ! strpos($filecontent, '{"')); } - print __METHOD__." Result for checking we don't have double quote = ".$result."\n"; + //print __METHOD__." Result for checking we don't have double quote = ".$result."\n"; $this->assertTrue($result===false, 'Found double quote that is not [" neither {" (used for json content) into '.$file.'. Bad.'); $result=strpos($filecontent, 'int('); - print __METHOD__." Result for checking we don't have 'int(' instead of 'integer' = ".$result."\n"; + //print __METHOD__." Result for checking we don't have 'int(' instead of 'integer' = ".$result."\n"; $this->assertTrue($result===false, 'Found int(x) or tinyint(x) instead of integer or tinyint into '.$file.'. Bad.'); $result=strpos($filecontent, 'ON DELETE CASCADE'); - print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n"; + //print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n"; $this->assertTrue($result===false, 'Found ON DELETE CASCADE into '.$file.'. Bad.'); $result=strpos($filecontent, 'NUMERIC('); - print __METHOD__." Result for checking we don't have 'NUMERIC(' = ".$result."\n"; + //print __METHOD__." Result for checking we don't have 'NUMERIC(' = ".$result."\n"; $this->assertTrue($result===false, 'Found NUMERIC( into '.$file.'. Bad.'); $result=strpos($filecontent, 'NUMERIC('); - print __METHOD__." Result for checking we don't have 'curdate(' = ".$result."\n"; + //print __METHOD__." Result for checking we don't have 'curdate(' = ".$result."\n"; $this->assertTrue($result===false, 'Found curdate( into '.$file.'. Bad. Current date must be generated with PHP.'); $result=strpos($filecontent, 'integer('); - print __METHOD__." Result for checking we don't have 'integer(' = ".$result."\n"; + //print __METHOD__." Result for checking we don't have 'integer(' = ".$result."\n"; $this->assertTrue($result===false, 'Found value in parenthesis after the integer. It must be integer not integer(x) into '.$file.'. Bad.'); if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration') @@ -214,11 +214,11 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase } else { // Test for non key files only $result=(strpos($filecontent, 'KEY ') && strpos($filecontent, 'PRIMARY KEY') == 0); - print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n"; + //print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n"; $this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.'); $result=stripos($filecontent, 'ENGINE=innodb'); - print __METHOD__." Result for checking we have the ENGINE=innodb string = ".$result."\n"; + //print __METHOD__." Result for checking we have the ENGINE=innodb string = ".$result."\n"; $this->assertGreaterThan(0, $result, 'The ENGINE=innodb was not found into '.$file.'. Add it or just fix syntax to match case.'); } }