diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 6547b98471a..7cc51bfecb9 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -343,7 +343,7 @@ class Notify $sql = ''; // Check notification per third party - if ($object->socid > 0) + if (!empty($object->socid) && $object->socid > 0) { $sql .= "SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,"; $sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type"; @@ -576,7 +576,7 @@ class Notify $i++; } } else { - dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".$object->socid); + dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".(empty($object->socid) ? '' : $object->socid)); } } else { $error++; diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index 299b31ad85c..e6e60741628 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -122,7 +122,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport global $db, $conf; // For backward compatibility and restore old behavior to get ref of expense report - if ($conf->global->EXPENSEREPORT_USE_OLD_NUMBERING_RULE) + if (!empty($conf->global->EXPENSEREPORT_USE_OLD_NUMBERING_RULE)) { $fuser = null; if ($object->fk_user_author > 0) diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 497c0b5f95e..f784d88a3da 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -217,7 +217,7 @@ class modReception extends DolibarrModules $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'reception as c'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'reception_extrafields as extra ON c.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s'; - if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch as ed'; @@ -231,7 +231,7 @@ class modReception extends DolibarrModules } $this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid'; $this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('reception').')'; - if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; + if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 3ecba5d5286..55096c411fa 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -80,12 +80,16 @@ class ExpenseReport extends CommonObject */ public $fk_statut; + public $vat_src_code; + public $fk_c_paiement; public $paid; public $user_author_infos; public $user_validator_infos; + public $rule_warning_message; + // ACTIONS // Create @@ -539,7 +543,7 @@ class ExpenseReport extends CommonObject { global $conf; - $sql = "SELECT d.rowid, d.ref, d.note_public, d.note_private,"; // DEFAULT + $sql = "SELECT d.rowid, d.entity, d.ref, d.note_public, d.note_private,"; // DEFAULT $sql .= " d.detail_refuse, d.detail_cancel, d.fk_user_refuse, d.fk_user_cancel,"; // ACTIONS $sql .= " d.date_refuse, d.date_cancel,"; // ACTIONS $sql .= " d.total_ht, d.total_ttc, d.total_tva,"; // TOTAUX (int) @@ -561,6 +565,9 @@ class ExpenseReport extends CommonObject { $this->id = $obj->rowid; $this->ref = $obj->ref; + + $this->entity = $obj->entity; + $this->total_ht = $obj->total_ht; $this->total_tva = $obj->total_tva; $this->total_ttc = $obj->total_ttc; @@ -802,6 +809,7 @@ class ExpenseReport extends CommonObject $this->id = 0; $this->ref = 'SPECIMEN'; $this->specimen = 1; + $this->entity = 1; $this->date_create = $now; $this->date_debut = $now; $this->date_fin = $now; @@ -2637,7 +2645,7 @@ class ExpenseReportLine } /** - * insert + * Insert a line of expense report * * @param int $notrigger 1=No trigger * @param bool $fromaddline false=keep default behavior, true=exclude the update_price() of parent object @@ -2649,11 +2657,11 @@ class ExpenseReportLine $error = 0; - dol_syslog("ExpenseReportLine::Insert rang=".$this->rang, LOG_DEBUG); + dol_syslog("ExpenseReportLine::Insert", LOG_DEBUG); // Clean parameters $this->comments = trim($this->comments); - if (!$this->value_unit_HT) $this->value_unit_HT = 0; + if (empty($this->value_unit)) $this->value_unit = 0; $this->qty = price2num($this->qty); $this->vatrate = price2num($this->vatrate); if (empty($this->fk_c_exp_tax_cat)) $this->fk_c_exp_tax_cat = 0; @@ -2665,9 +2673,9 @@ class ExpenseReportLine $sql .= ' tva_tx, vat_src_code, comments, qty, value_unit, total_ht, total_tva, total_ttc, date, rule_warning_message, fk_c_exp_tax_cat, fk_ecm_files)'; $sql .= " VALUES (".$this->db->escape($this->fk_expensereport).","; $sql .= " ".$this->db->escape($this->fk_c_type_fees).","; - $sql .= " ".$this->db->escape($this->fk_project > 0 ? $this->fk_project : ($this->fk_projet > 0 ? $this->fk_projet : 'null')).","; + $sql .= " ".$this->db->escape((!empty($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : ((!empty($this->fk_projet) && $this->fk_projet > 0) ? $this->fk_projet : 'null')).","; $sql .= " ".$this->db->escape($this->vatrate).","; - $sql .= " '".$this->db->escape($this->vat_src_code)."',"; + $sql .= " '".$this->db->escape(empty($this->vat_src_code) ? '' : $this->vat_src_code)."',"; $sql .= " '".$this->db->escape($this->comments)."',"; $sql .= " ".$this->db->escape($this->qty).","; $sql .= " ".$this->db->escape($this->value_unit).","; @@ -2675,7 +2683,7 @@ class ExpenseReportLine $sql .= " ".$this->db->escape($this->total_tva).","; $sql .= " ".$this->db->escape($this->total_ttc).","; $sql .= " '".$this->db->idate($this->date)."',"; - $sql .= " '".$this->db->escape($this->rule_warning_message)."',"; + $sql .= " ".(empty($this->rule_warning_message) ? 'null' : "'".$this->db->escape($this->rule_warning_message)."'").","; $sql .= " ".$this->db->escape($this->fk_c_exp_tax_cat).","; $sql .= " ".($this->fk_ecm_files > 0 ? $this->fk_ecm_files : 'null'); $sql .= ")"; diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index b29bb0e6d70..15df6371891 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -64,91 +64,99 @@ if (GETPOST('dol_use_jmobile', 'alpha') || !empty($_SESSION['dol_use_jmobile'])) * Actions */ -// Validate new password -if ($action == 'validatenewpassword' && $username && $passwordhash) -{ - $edituser = new User($db); - $result = $edituser->fetch('', $_GET["username"]); - if ($result < 0) - { - $message = '
'.dol_escape_htmltag($langs->trans("ErrorLoginDoesNotExists", $username)).'
'; - } else { - if (dol_verifyHash($edituser->pass_temp, $passwordhash)) - { - // Clear session - unset($_SESSION['dol_login']); - $_SESSION['dol_loginmesg'] = $langs->trans('NewPasswordValidated'); // Save message for the session page - - $newpassword = $edituser->setPassword($user, $edituser->pass_temp, 0); - dol_syslog("passwordforgotten.php new password for user->id=".$edituser->id." validated in database"); - header("Location: ".DOL_URL_ROOT.'/'); - exit; - } else { - $langs->load("errors"); - $message = '
'.$langs->trans("ErrorFailedToValidatePasswordReset").'
'; - } - } +$parameters = array('username' => $username); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + $message = $hookmanager->error; } -// Action modif mot de passe -if ($action == 'buildnewpassword' && $username) -{ - $sessionkey = 'dol_antispam_value'; - $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code']))); - // Verify code - if (!$ok) - { - $message = '
'.$langs->trans("ErrorBadValueForCode").'
'; - } else { - $isanemail = preg_match('/@/', $username); +if (empty($reshook)) { + // Validate new password + if ($action == 'validatenewpassword' && $username && $passwordhash) + { + $edituser = new User($db); + $result = $edituser->fetch('', $_GET["username"]); + if ($result < 0) + { + $message = '
'.dol_escape_htmltag($langs->trans("ErrorLoginDoesNotExists", $username)).'
'; + } else { + if (dol_verifyHash($edituser->pass_temp, $passwordhash)) + { + // Clear session + unset($_SESSION['dol_login']); + $_SESSION['dol_loginmesg'] = $langs->trans('NewPasswordValidated'); // Save message for the session page - $edituser = new User($db); - $result = $edituser->fetch('', $username, '', 1); - if ($result == 0 && $isanemail) - { - $result = $edituser->fetch('', '', '', 1, -1, $username); - } + $newpassword = $edituser->setPassword($user, $edituser->pass_temp, 0); + dol_syslog("passwordforgotten.php new password for user->id=".$edituser->id." validated in database"); + header("Location: ".DOL_URL_ROOT.'/'); + exit; + } else { + $langs->load("errors"); + $message = '
'.$langs->trans("ErrorFailedToValidatePasswordReset").'
'; + } + } + } + // Action modif mot de passe + if ($action == 'buildnewpassword' && $username) + { + $sessionkey = 'dol_antispam_value'; + $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code']))); - if ($result <= 0 && $edituser->error == 'USERNOTFOUND') - { - $message = '
'; - if (!$isanemail) { - $message .= $langs->trans("IfLoginExistPasswordRequestSent"); - } else { - $message .= $langs->trans("IfEmailExistPasswordRequestSent"); - } - $message .= '
'; - $username = ''; - } else { - if (!$edituser->email) - { - $message = '
'.$langs->trans("ErrorLoginHasNoEmail").'
'; - } else { - $newpassword = $edituser->setPassword($user, '', 1); - if ($newpassword < 0) - { - // Failed - $message = '
'.$langs->trans("ErrorFailedToChangePassword").'
'; - } else { - // Success - if ($edituser->send_password($user, $newpassword, 1) > 0) - { - $message = '
'; - if (!$isanemail) { - $message .= $langs->trans("IfLoginExistPasswordRequestSent"); - } else { - $message .= $langs->trans("IfEmailExistPasswordRequestSent"); - } - //$message .= $langs->trans("PasswordChangeRequestSent", $edituser->login, dolObfuscateEmail($edituser->email)); - $message .= '
'; - $username = ''; - } else { - $message .= '
'.$edituser->error.'
'; - } - } - } - } - } + // Verify code + if (!$ok) + { + $message = '
'.$langs->trans("ErrorBadValueForCode").'
'; + } else { + $isanemail = preg_match('/@/', $username); + + $edituser = new User($db); + $result = $edituser->fetch('', $username, '', 1); + if ($result == 0 && $isanemail) + { + $result = $edituser->fetch('', '', '', 1, -1, $username); + } + + if ($result <= 0 && $edituser->error == 'USERNOTFOUND') + { + $message = '
'; + if (!$isanemail) { + $message .= $langs->trans("IfLoginExistPasswordRequestSent"); + } else { + $message .= $langs->trans("IfEmailExistPasswordRequestSent"); + } + $message .= '
'; + $username = ''; + } else { + if (!$edituser->email) + { + $message = '
'.$langs->trans("ErrorLoginHasNoEmail").'
'; + } else { + $newpassword = $edituser->setPassword($user, '', 1); + if ($newpassword < 0) + { + // Failed + $message = '
'.$langs->trans("ErrorFailedToChangePassword").'
'; + } else { + // Success + if ($edituser->send_password($user, $newpassword, 1) > 0) + { + $message = '
'; + if (!$isanemail) { + $message .= $langs->trans("IfLoginExistPasswordRequestSent"); + } else { + $message .= $langs->trans("IfEmailExistPasswordRequestSent"); + } + //$message .= $langs->trans("PasswordChangeRequestSent", $edituser->login, dolObfuscateEmail($edituser->email)); + $message .= '
'; + $username = ''; + } else { + $message .= '
'.$edituser->error.'
'; + } + } + } + } + } + } } diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index a62d362a972..189ef10ecdc 100644 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -244,7 +244,7 @@ class CategorieTest extends PHPUnit\Framework\TestCase /** * testCategorieUpdate * - * @param Category $localobject Category + * @param Categorie $localobject Category * @return int * @depends testCategorieFetch @@ -269,7 +269,7 @@ class CategorieTest extends PHPUnit\Framework\TestCase /** * testCategorieOther * - * @param Category $localobject Category + * @param Categorie $localobject Category * @return int * * @depends testCategorieUpdate