From d3e0e1f6958f44d6430d6849a4080748bdedfaaa Mon Sep 17 00:00:00 2001 From: atm-steve Date: Mon, 4 Jul 2022 17:14:01 +0200 Subject: [PATCH 01/37] fix ndf validate with main entity --- htdocs/expensereport/class/expensereport.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 9eaa2f96cb5..1d63ce997d3 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1256,7 +1256,7 @@ class ExpenseReport extends CommonObject // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'expensereport/".$this->db->escape($this->newref)."'"; - $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$this->db->escape($this->ref)."' and entity = ".$this->entity; $resql = $this->db->query($sql); if (!$resql) { $error++; $this->error = $this->db->lasterror(); @@ -1265,15 +1265,15 @@ class ExpenseReport extends CommonObject // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); - $dirsource = $conf->expensereport->dir_output.'/'.$oldref; - $dirdest = $conf->expensereport->dir_output.'/'.$newref; + $dirsource = $conf->expensereport->multidir_output[$this->entity].'/'.$oldref; + $dirdest = $conf->expensereport->multidir_output[$this->entity].'/'.$newref; if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::setValidate() rename dir ".$dirsource." into ".$dirdest); if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->expensereport->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + $listoffiles = dol_dir_list($dirdest, 'files', 1, '^'.preg_quote($oldref, '/')); foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); From fe7c71d1c23cbefe700a74418ebaa8e82a9e63ba Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Tue, 29 Aug 2023 11:45:26 +0200 Subject: [PATCH 02/37] FIX product list accounting length --- htdocs/product/list.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index b2f7489cbfe..017a2cf8200 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -43,6 +43,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +if (!empty($conf->accounting->enabled)) + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'suppliers', 'companies', 'margins')); @@ -410,12 +412,12 @@ if ($fourn_id > 0) $sql .= " AND pfp.fk_soc = ".((int) $fourn_id); if ($search_country) $sql .= " AND p.fk_country = ".$search_country; if ($search_state) $sql .= " AND p.fk_state = ".$search_state; if ($search_finished >= 0 && $search_finished !== '') $sql .= " AND p.finished = ".$search_finished; -if ($search_accountancy_code_sell) $sql .= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); -if ($search_accountancy_code_sell_intra) $sql .= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); -if ($search_accountancy_code_sell_export) $sql .= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); -if ($search_accountancy_code_buy) $sql .= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); -if ($search_accountancy_code_buy_intra) $sql .= natural_search('p.accountancy_code_buy_intra', $search_accountancy_code_buy_intra); -if ($search_accountancy_code_buy_export) $sql .= natural_search('p.accountancy_code_buy_export', $search_accountancy_code_buy_export); +if ($search_accountancy_code_sell) $sql .= natural_search('p.accountancy_code_sell', clean_account($search_accountancy_code_sell)); +if ($search_accountancy_code_sell_intra) $sql .= natural_search('p.accountancy_code_sell_intra', clean_account($search_accountancy_code_sell_intra)); +if ($search_accountancy_code_sell_export) $sql .= natural_search('p.accountancy_code_sell_export', clean_account($search_accountancy_code_sell_export)); +if ($search_accountancy_code_buy) $sql .= natural_search('p.accountancy_code_buy', clean_account($search_accountancy_code_buy)); +if ($search_accountancy_code_buy_intra) $sql .= natural_search('p.accountancy_code_buy_intra', clean_account($search_accountancy_code_buy_intra)); +if ($search_accountancy_code_buy_export) $sql .= natural_search('p.accountancy_code_buy_export', clean_account($search_accountancy_code_buy_export)); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -1481,33 +1483,33 @@ if ($resql) // Accountancy code sell if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) { - print ''.$obj->accountancy_code_sell.''; + print ''.length_accountg($obj->accountancy_code_sell).''; if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { - print ''.$obj->accountancy_code_sell_intra.''; + print ''.length_accountg($obj->accountancy_code_sell_intra).''; if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { - print ''.$obj->accountancy_code_sell_export.''; + print ''.length_accountg($obj->accountancy_code_sell_export).''; if (!$i) $totalarray['nbfield']++; } // Accountancy code buy if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { - print ''.$obj->accountancy_code_buy.''; + print ''.length_accountg($obj->accountancy_code_buy).''; if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) { - print ''.$obj->accountancy_code_buy_intra.''; + print ''.length_accountg($obj->accountancy_code_buy_intra).''; if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) { - print ''.$obj->accountancy_code_buy_export.''; + print ''.length_accountg($obj->accountancy_code_buy_export).''; if (!$i) $totalarray['nbfield']++; } // Extra fields From bbca5118b7a613a06df0aca6afc895a37ea200dd Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Tue, 29 Aug 2023 12:12:21 +0200 Subject: [PATCH 03/37] FIX export FEC --- htdocs/accountancy/class/accountancyexport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 0c698c5059c..08ced92348f 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -882,7 +882,7 @@ class AccountancyExport print $date_document . $separator; // FEC:CompteNum - print $line->numero_compte . $separator; + print length_accountg($line->numero_compte) . $separator; // FEC:CompteLib print dol_string_unaccent($line->label_compte) . $separator; From 5001cc6de541d605e9896b0ad5e0b2522f860a9f Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Wed, 6 Sep 2023 14:23:16 +0200 Subject: [PATCH 04/37] same fix for fec2 --- htdocs/accountancy/class/accountancyexport.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 08ced92348f..f48be1fc238 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -888,7 +888,7 @@ class AccountancyExport print dol_string_unaccent($line->label_compte) . $separator; // FEC:CompAuxNum - print $line->subledger_account . $separator; + print length_accounta($line->subledger_account) . $separator; // FEC:CompAuxLib print dol_string_unaccent($line->subledger_label) . $separator; @@ -983,13 +983,13 @@ class AccountancyExport print $date_creation . $separator; // FEC:CompteNum - print $line->numero_compte . $separator; + print length_accountg($line->numero_compte) . $separator; // FEC:CompteLib print dol_string_unaccent($line->label_compte) . $separator; // FEC:CompAuxNum - print $line->subledger_account . $separator; + print length_accounta($line->subledger_account) . $separator; // FEC:CompAuxLib print dol_string_unaccent($line->subledger_label) . $separator; From 03272b12b03ffc8e88019f7f7bb53db0c0570d74 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 11 Sep 2023 11:01:00 +0200 Subject: [PATCH 05/37] FIX right access on salary card and tabs --- htdocs/salaries/card.php | 3 +-- htdocs/salaries/document.php | 13 +++++++++++++ htdocs/salaries/info.php | 13 +++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index f5ebbcf0ec6..20ce8578305 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -85,8 +85,7 @@ if ($id > 0 || !empty($ref)) { $canread = 0; if (!empty($user->rights->salaries->readall)) { $canread = 1; - } - if (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) { + } elseif (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) { $canread = 1; } if (!$canread) { diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php index ea21b49159c..6e316ca9cce 100644 --- a/htdocs/salaries/document.php +++ b/htdocs/salaries/document.php @@ -63,8 +63,21 @@ if (!$sortfield) { } $object = new Salary($db); +$childids = $user->getAllChildIds(1); if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); + + // Check current user can read this salary + $canread = 0; + if (!empty($user->rights->salaries->readall)) { + $canread = 1; + } elseif (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) { + $canread = 1; + } + + if (!$canread) { + accessforbidden(); + } } $upload_dir = $conf->salaries->dir_output.'/'.dol_sanitizeFileName($object->id); diff --git a/htdocs/salaries/info.php b/htdocs/salaries/info.php index 0f94f405fa1..764f221c84c 100644 --- a/htdocs/salaries/info.php +++ b/htdocs/salaries/info.php @@ -37,8 +37,21 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $object = new Salary($db); +$childids = $user->getAllChildIds(1); if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); + + // Check current user can read this salary + $canread = 0; + if (!empty($user->rights->salaries->readall)) { + $canread = 1; + } elseif (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) { + $canread = 1; + } + + if (!$canread) { + accessforbidden(); + } } // Security check From 1ead990e9fce6773b143e2ac4bba8bab150084d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2023 12:41:39 +0200 Subject: [PATCH 06/37] Fix phpcs --- htdocs/public/payment/newpayment.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index df57986505b..e6d5554fc5d 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -2111,7 +2111,6 @@ if ($action != 'dopayment') { } if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) { - if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) { $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral'; } From df4df7ab1b471849333c4bb6f3aa2cc8c6001438 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2023 17:51:38 +0200 Subject: [PATCH 07/37] Update expensereport.class.php --- htdocs/expensereport/class/expensereport.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index f8b19c14b13..c34d1171125 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1234,9 +1234,9 @@ class ExpenseReport extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref = '".$this->db->escape($num)."',"; $sql .= " fk_statut = ".self::STATUS_VALIDATED.","; - $sql .= " date_valid='".$this->db->idate($this->date_valid)."',"; - $sql .= " fk_user_valid = ".$user->id; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " date_valid = '".$this->db->idate($this->date_valid)."',"; + $sql .= " fk_user_valid = ".((int) $user->id); + $sql .= " WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { @@ -1258,7 +1258,7 @@ class ExpenseReport extends CommonObject // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'expensereport/".$this->db->escape($this->newref)."'"; - $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$this->db->escape($this->ref)."' and entity = ".$this->entity; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$this->db->escape($this->ref)."' AND entity = ".((int) $this->entity); $resql = $this->db->query($sql); if (!$resql) { $error++; $this->error = $this->db->lasterror(); From 8547648ac8d793fe480d252119863047d6708dd4 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 12 Sep 2023 15:44:36 +0200 Subject: [PATCH 08/37] fix addupdatedelete action for update_extras --- htdocs/core/actions_addupdatedelete.inc.php | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 71901f8db44..5ed517b1237 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -349,26 +349,26 @@ if (preg_match('/^set(\w+)$/', $action, $reg) && GETPOST('id', 'int') > 0 && !em if ($action == "update_extras" && GETPOST('id', 'int') > 0 && !empty($permissiontoadd)) { $object->fetch(GETPOST('id', 'int')); - $attributekey = GETPOST('attribute', 'alpha'); - $attributekeylong = 'options_'.$attributekey; + $error = 0; - if (GETPOSTISSET($attributekeylong.'day') && GETPOSTISSET($attributekeylong.'month') && GETPOSTISSET($attributekeylong.'year')) { - // This is properties of a date - $object->array_options['options_'.$attributekey] = dol_mktime(GETPOST($attributekeylong.'hour', 'int'), GETPOST($attributekeylong.'min', 'int'), GETPOST($attributekeylong.'sec', 'int'), GETPOST($attributekeylong.'month', 'int'), GETPOST($attributekeylong.'day', 'int'), GETPOST($attributekeylong.'year', 'int')); - //var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit; - } else { - $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, 'alpha'); - } + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); + if ($ret < 0) { + $error++; + setEventMessages($extrafields->error, $object->errors, 'errors'); + $action = 'edit_extras'; + } + else { + $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); + if ($result > 0) { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + $action = 'view'; + } else { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit_extras'; + } + } - $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); - if ($result > 0) { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - $action = 'view'; - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit_extras'; - } } // Action to delete From 0046d031efb5ed580a821149dec3515412d3c3e4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 13 Sep 2023 06:44:54 +0200 Subject: [PATCH 09/37] FIX wrong test + is_int is better for negative integer --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/contact/card.php | 6 +++--- htdocs/user/card.php | 6 +++--- htdocs/user/class/user.class.php | 6 +++--- htdocs/user/passwordforgotten.php | 2 +- htdocs/webservices/server_user.php | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 9b6e36ba4cc..8717ecd010a 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1255,7 +1255,7 @@ class Adherent extends CommonObject if ($result >= 0) { $result = $luser->setPassword($user, $this->pass, 0, 0, 1); - if (is_numeric($result) && $result < 0) { + if (is_int($result) && $result < 0) { $this->error = $luser->error; dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR); $error++; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 994a9bd9a63..e7dfdd4128b 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -156,11 +156,11 @@ if (empty($reshook)) { if ($result > 0) { $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha) - if ($result2) { - $db->commit(); - } else { + if (is_int($result2) && $result2 < 0) { $error = $nuser->error; $errors = $nuser->errors; $db->rollback(); + } else { + $db->commit(); } } else { $error = $nuser->error; $errors = $nuser->errors; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 241bfdb5a1c..c6056a0f848 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -350,7 +350,7 @@ if (empty($reshook)) { if (GETPOST('password', 'none')) { $resPass = $object->setPassword($user, GETPOST('password', 'none')); } - if ($resPass < 0) { + if (is_int($resPass) && $resPass < 0) { $langs->load("errors"); $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); @@ -663,7 +663,7 @@ if (empty($reshook)) { $object->oldcopy = clone $object; $ret = $object->setPassword($user, GETPOST("password", "none")); - if ($ret < 0) { + if (is_int($ret) && $ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -678,7 +678,7 @@ if (empty($reshook)) { $object->fetch($id); $newpassword = $object->setPassword($user, ''); // This will generate a new password - if ($newpassword < 0) { + if (is_int($newpassword) && $newpassword < 0) { // Echec setEventMessages($langs->trans("ErrorFailedToSetNewPassword"), null, 'errors'); } else { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f2a01dd0342..433d39fef8b 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1754,7 +1754,7 @@ class User extends CommonObject if ($result > 0) { if (!empty($this->pass)) { // If a clear password was received (this situation should not happen anymore now), we use it to save it into database $newpass = $this->setPassword($user, $this->pass); - if (is_numeric($newpass) && $newpass < 0) { + if (is_int($newpass) && $newpass < 0) { $result = -2; } } elseif (!empty($this->pass_crypted)) { // If a crypted password is already known, we save it directly into database because the previous create did not save it. @@ -2029,7 +2029,7 @@ class User extends CommonObject if ($this->pass != $this->pass_indatabase && !dol_verifyHash($this->pass, $this->pass_indatabase_crypted)) { // If a new value for password is set and different than the one crypted into database $result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncmemberpass, 0, 1); - if (is_numeric($result) && $result < 0) { + if (is_int($result) && $result < 0) { return -5; } } @@ -2321,7 +2321,7 @@ class User extends CommonObject if ($result >= 0) { $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent - if (is_numeric($result) && $result < 0) { + if (is_int($result) && $result < 0) { $this->error = $adh->error; dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR); $error++; diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index ad66bc5987a..2a711208e8b 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -151,7 +151,7 @@ if (empty($reshook)) { $message .= $messagewarning; } else { $newpassword = $edituser->setPassword($user, '', 1); - if (is_numeric($newpassword) && $newpassword < 0) { + if (is_int($newpassword) && $newpassword < 0) { // Technical failure $message = '
'.$langs->trans("ErrorFailedToChangePassword").'
'; } else { diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index 21a9bbd23d4..5ef9055af8f 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -709,7 +709,7 @@ function setUserPassword($authentication, $shortuser) $res = $userstat->fetch('', $shortuser['login']); if ($res) { $res = $userstat->setPassword($userstat, $shortuser['password']); - if (is_numeric($res) && $res < 0) { + if (is_int($res) && $res < 0) { $error++; $errorcode = 'NOT_MODIFIED'; $errorlabel = 'Error when changing password'; } else { From dc5cc079233279d9ad8200c2c429eb984f016c50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2023 10:49:44 +0200 Subject: [PATCH 10/37] Fix phpcs --- htdocs/core/actions_addupdatedelete.inc.php | 36 ++++++++++----------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 5ed517b1237..086b37aa501 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -349,26 +349,24 @@ if (preg_match('/^set(\w+)$/', $action, $reg) && GETPOST('id', 'int') > 0 && !em if ($action == "update_extras" && GETPOST('id', 'int') > 0 && !empty($permissiontoadd)) { $object->fetch(GETPOST('id', 'int')); - $error = 0; - - $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); - if ($ret < 0) { - $error++; - setEventMessages($extrafields->error, $object->errors, 'errors'); - $action = 'edit_extras'; - } - else { - $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); - if ($result > 0) { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - $action = 'view'; - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit_extras'; - } - } + $error = 0; + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); + if ($ret < 0) { + $error++; + setEventMessages($extrafields->error, $object->errors, 'errors'); + $action = 'edit_extras'; + } else { + $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); + if ($result > 0) { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + $action = 'view'; + } else { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit_extras'; + } + } } // Action to delete From 814f95c5e7162a731cf58417f164b7bd3a1ac23a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 13 Sep 2023 13:25:44 +0200 Subject: [PATCH 11/37] back port fix from issue #24429 --- htdocs/core/js/lib_head.js.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index ab4b39ec872..eb0759ad109 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1302,14 +1302,14 @@ $(document).ready(function() { global->MAIN_DISABLE_SELECT2_FOCUS_PROTECTION) && !defined('DISABLE_SELECT2_FOCUS_PROTECTION')) { ?> -$(document).on('select2:open', () => { +$(document).on('select2:open', (e) => { console.log("Execute the focus (click on combo or use space when on component"); - let allFound = document.querySelectorAll('.select2-container--open .select2-search__field'); - $(this).one('mouseup keyup',()=>{ - setTimeout(()=>{ - allFound[allFound.length - 1].focus(); - },0); - }); + const target = $(e.target); + if (target && target.length) { + let id = target[0].id || target[0].name; + if (id.substr(-2) == "[]") id = id.substr(0,id.length-2); + document.querySelector('input[aria-controls*='+id+']').focus(); + } }); Date: Thu, 14 Sep 2023 06:09:12 +0200 Subject: [PATCH 12/37] FIX same broken feature as v18 (Multicompany) --- htdocs/user/perms.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 17bd708f2e0..9bf54f65561 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -222,23 +222,8 @@ $permsgroupbyentity = array(); $sql = "SELECT DISTINCT gr.fk_id, gu.entity"; // fk_id are permission id and entity is entity of the group $sql .= " FROM ".MAIN_DB_PREFIX."usergroup_rights as gr,"; $sql .= " ".MAIN_DB_PREFIX."usergroup_user as gu"; // all groups of a user -$sql .= " WHERE 1 = 1"; -// A very strange business rules. Must be same than into user->getrights() user/perms.php and user/group/perms.php -if (!empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) { - if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql .= " AND gu.entity IN (0,".$conf->entity.")"; - } else { - //$sql .= " AND r.entity = ".((int) $conf->entity); - } -} else { - $sql .= " AND gr.entity = ".((int) $conf->entity); // Only groups created in current entity - // The entity on the table usergroup_user should be useless and should never be used because it is alreay into gr and r. - // but when using MULTICOMPANY_TRANSVERSE_MODE, we may insert record that make rubbish result due to duplicate record of - // other entities, so we are forced to add a filter here - $sql .= " AND gu.entity IN (0,".$conf->entity.")"; - //$sql .= " AND r.entity = ".((int) $conf->entity); // Only permission of modules enabled in current entity -} -// End of strange business rule +$sql .= " WHERE gr.entity = ".((int) $entity); +$sql .= " AND gu.entity =".((int) $entity); $sql .= " AND gr.fk_usergroup = gu.fk_usergroup"; $sql .= " AND gu.fk_user = ".((int) $object->id); From 3dad9d0899c63fad1ed2536945d4a36b6794b653 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Thu, 14 Sep 2023 10:03:28 +0200 Subject: [PATCH 13/37] FIX : bad check return for sendfile --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b323b4b3e01..e6606eb152b 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -508,7 +508,7 @@ if (!$error && $massaction == 'confirm_presend') { $resaction .= '
'.$mailfile->error.'
'; } else { $result = $mailfile->sendfile(); - if ($result) { + if ($result > 0) { $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'
'; // Must not contain " $error = 0; From ed4a8e88c0773fe98579237bfe31b7ff086bf0f7 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Thu, 14 Sep 2023 10:21:16 +0200 Subject: [PATCH 14/37] FIX : bad from and to --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index e6606eb152b..225e118b2a0 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -509,7 +509,7 @@ if (!$error && $massaction == 'confirm_presend') { } else { $result = $mailfile->sendfile(); if ($result > 0) { - $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'
'; // Must not contain " + $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).'
'; // Must not contain " $error = 0; From e84c2eeee6b753586c3bfb0df64baa8fd63cbe9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Thu, 14 Sep 2023 10:57:43 +0200 Subject: [PATCH 15/37] FIX: Missing error message on CommandeFourn creation --- htdocs/fourn/commande/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index ad9a204aef7..247a3633b14 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1372,6 +1372,7 @@ if (empty($reshook)) { ); if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); $error++; break; } From db299ee66a986fdba2130597c22c1206b146bc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina=20JOUM?= Date: Thu, 14 Sep 2023 12:07:28 +0200 Subject: [PATCH 16/37] Fix translation --- htdocs/comm/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 15d1a0b2dcd..a432edfc1c8 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1594,7 +1594,7 @@ if ($object->id > 0) { print ''; } } else { - print ''; + print ''; } } From 48a2fd3c615a46f86c2c29f60f1eb1ef09b3bb2a Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Thu, 14 Sep 2023 14:03:23 +0200 Subject: [PATCH 17/37] FIX include --- htdocs/product/list.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 017a2cf8200..218d260bfe7 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -43,8 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (!empty($conf->accounting->enabled)) - require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'suppliers', 'companies', 'margins')); From 2dce1162964438ba1449abd02964d129929c1430 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2023 15:01:28 +0200 Subject: [PATCH 18/37] Fix missing close --- htdocs/public/notice.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/public/notice.php b/htdocs/public/notice.php index a682abd78c8..9f9f9c7c96d 100644 --- a/htdocs/public/notice.php +++ b/htdocs/public/notice.php @@ -60,3 +60,5 @@ if (!GETPOST('transkey', 'alphanohtml') && !GETPOST('transphrase', 'alphanohtml' print dol_escape_htmltag($langs->trans(GETPOST('transkey', 'alphanohtml'))); } } + +$db->close(); From ad1047c7c342a545f326f66932dad1b63833b057 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2023 20:55:33 +0200 Subject: [PATCH 19/37] FIX #25919 --- htdocs/comm/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 15d1a0b2dcd..512d525c17d 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1582,6 +1582,7 @@ if ($object->id > 0) { if (isModEnabled('facture') && $object->status == 1) { if (empty($user->rights->facture->creer)) { + $langs->load("bills"); print ''; } else { $langs->loadLangs(array("orders", "bills")); From 4e58a34c7854bf54864073d15cad2b2b469d05a7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 15:04:40 +0200 Subject: [PATCH 20/37] Fix css --- htdocs/core/class/html.formother.class.php | 2 +- htdocs/core/class/html.formprojet.class.php | 2 +- htdocs/projet/tasks.php | 10 ++++++---- htdocs/projet/tasks/time.php | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 0485b3ef296..084fce1f955 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -363,7 +363,7 @@ class FormOther public function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0) { // phpcs:enable - $return = ''; if ($showempty) { $return .= ''; } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 7b20fa125bb..ad1299c91c1 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -384,7 +384,7 @@ class FormProjets include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); $out .= $comboenhancement; - $morecss .= ' minwidth150'; + $morecss .= ' minwidth150imp'; } if (empty($option_only)) { diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 196bc2d4582..5c1f9a0c805 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -723,6 +723,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print dol_get_fiche_head(''); + print '
'; print ''; $defaultref = ''; @@ -749,7 +750,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // Label print ''; // Project @@ -768,12 +769,12 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; @@ -813,7 +814,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; } - $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows); + $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows, '90%'); print $doleditor->Create(); print ''; @@ -833,6 +834,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third } print '
'.$langs->trans("Label").''; - print ''; + print ''; print '
'.$langs->trans("AffectedTo").''; print img_picto('', 'user', 'class="pictofixedwidth"'); if (is_array($contactsofproject) && count($contactsofproject)) { - print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300'); + print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth500 widthcentpercentminusx'); } else { if ((isset($projectid) && $projectid > 0) || $object->id > 0) { print ''.$langs->trans("NoUserAssignedToTheProject").''; } else { - print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth500 widthcentpercentminusx'); } } print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 52f68b11b08..d2b1d64188e 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1794,7 +1794,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($projectstatic->public) { $contactsofproject = array(); } - print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); + print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'minwidth150imp maxwidth200'); } else { if ($nboftasks) { print img_error($langs->trans('FirstAddRessourceToAllocateTime')).' '.$langs->trans('FirstAddRessourceToAllocateTime'); From 2391a5da6fc69015e65607b82b27fc8c9ab550f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 15:58:43 +0200 Subject: [PATCH 21/37] FIX Filter on partnership status FIX Kanban view --- .../template/class/myobject.class.php | 3 +++ htdocs/modulebuilder/template/myobject_list.php | 15 +++++++++++++++ htdocs/partnership/class/partnership.class.php | 5 ++++- htdocs/partnership/partnership_list.php | 17 ++++++++++++++++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index f2b7056f56b..4d91cdaedf1 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -922,6 +922,9 @@ class MyObject extends CommonObject if (property_exists($this, 'label')) { $return .= '
'.$this->label.'
'; } + if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) { + $return .= '
'.$this->thirdparty->getNomUrl(1).'
'; + } if (property_exists($this, 'amount')) { $return .= '
'; $return .= ''.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).''; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index b484dae1c49..bbf37125bfb 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -696,6 +696,20 @@ while ($i < $imaxinloop) { // Store properties in $object $object->setVarsFromFetchObj($obj); + /* + $object->thirdparty = null; + if ($obj->fk_soc > 0) { + if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) { + $companyobj = $conf->cache['thirdparty'][$obj->fk_soc]; + } else { + $companyobj = new Societe($db); + $companyobj->fetch($obj->fk_soc); + $conf->cache['thirdparty'][$obj->fk_soc] = $companyobj; + } + + $object->thirdparty = $companyobj; + }*/ + if ($mode == 'kanban') { if ($i == 0) { print ''; @@ -709,6 +723,7 @@ while ($i < $imaxinloop) { $selected = 1; } } + //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected)); print $object->getKanbanView('', array('selected' => $selected)); if ($i == ($imaxinloop - 1)) { print ''; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index b20cea56c2e..55e5fc3d187 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -125,7 +125,7 @@ class Partnership extends CommonObject 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), 'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), - 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '8'=>'Suspended', '9'=>'Terminated'),), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'Approved', '3'=>'Refused', '9'=>'Terminated'),), ); public $rowid; public $ref; @@ -1352,6 +1352,9 @@ class Partnership extends CommonObject if (property_exists($this, 'label')) { $return .= '
'.$this->label.'
'; } + if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) { + $return .= '
'.$this->thirdparty->getNomUrl(1).'
'; + } if (method_exists($this, 'getLibStatut')) { $return .= '
'.$this->getLibStatut(3).'
'; } diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 98d78e0a2b2..bcfabe92e71 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; @@ -286,6 +287,7 @@ if (empty($reshook)) { */ $form = new Form($db); +$companystatic = new Societe($db); $now = dol_now(); @@ -863,13 +865,26 @@ while ($i < $imaxinloop) { // Store properties in $object $object->setVarsFromFetchObj($obj); + $object->thirdparty = null; + if ($obj->fk_soc > 0) { + if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) { + $companyobj = $conf->cache['thirdparty'][$obj->fk_soc]; + } else { + $companyobj = new Societe($db); + $companyobj->fetch($obj->fk_soc); + $conf->cache['thirdparty'][$obj->fk_soc] = $companyobj; + } + + $object->thirdparty = $companyobj; + } + if ($mode == 'kanban') { if ($i == 0) { print ''; print '
'; } // Output Kanban - print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected))); + print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => in_array($object->id, $arrayofselected))); if ($i == ($imaxinloop - 1)) { print '
'; print ''; From 818b1193b10a72402fd55d23ca91331167489de3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 16:19:05 +0200 Subject: [PATCH 22/37] Fix escapesql --- htdocs/core/db/Database.interface.php | 3 ++- htdocs/modulebuilder/template/class/myobject.class.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 3ebc3023f36..7e0efa222db 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -190,7 +190,8 @@ interface Database public function escape($stringtoencode); /** - * Escape a string to insert data into a like + * Escape a string to insert data into a like. + * Can be used this way: LIKE '%".$this->db->escapeforlike($this->db->escape(...))."%' * * @param string $stringtoencode String to escape * @return string String escaped diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 4d91cdaedf1..240ebd2b052 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -467,7 +467,7 @@ class MyObject extends CommonObject } elseif (strpos($value, '%') === false) { $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")"; } else { - $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + $sqlwhere[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($value))."%'"; } } } From cc8996fe3ed7a6afa08a11624dea75963b845c35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 16:44:18 +0200 Subject: [PATCH 23/37] FIX batch to update non valid backlink check --- .../partnership/class/partnership.class.php | 4 +- .../class/partnershiputils.class.php | 89 ++++++++++--------- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 55e5fc3d187..b7b9f2b6b41 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -1309,8 +1309,6 @@ class Partnership extends CommonObject */ public function doScheduledJob() { - global $conf, $langs; - //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; $error = 0; @@ -1319,7 +1317,7 @@ class Partnership extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $now = dol_now(); + //$now = dol_now(); $this->db->begin(); diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index c73bc4230d4..f8589adab89 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -305,51 +305,58 @@ class PartnershipUtils if (!$backlinkfound) { $tmpcount = $object->count_last_url_check_error + 1; - if ($tmpcount > 2 && $tmpcount <= 4) { // Send Warning Email - if (!empty($obj->email)) { - $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; - } else { - $labeltemplate = '(SendingEmailOnPartnershipWillSoonBeCanceled)'; + $nbminbacklinkerrorforcancel = getDolGlobalString('PARTNERSHIP_MIN_BACKLINK_ERROR_FOR_CANCEL', 2); + $nbmaxbacklinkerrorforcancel = getDolGlobalString('PARTNERSHIP_MAX_BACKLINK_ERROR_FOR_CANCEL', $nbminbacklinkerrorforcancel + 2); - dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); + // If $nbminbacklinkerrorforemail = 0, no autoemail + if ($nbminbacklinkerrorforcancel > 0) { + if ($tmpcount > $nbminbacklinkerrorforcancel && $tmpcount <= $nbmaxbacklinkerrorforcancel) { // Send Warning Email + if (!empty($obj->email)) { + $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; + } else { + // Example: 'SendingEmailOnPartnershipWillSoonBeCanceled' + $labeltemplate = '('.getDolGlobalString('PARTNERSHIP_SENDMAIL_IF_NO_LINK', 'SendingEmailOnPartnershipWillSoonBeCanceled').')'; - // Send deployment email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $formmail = new FormMail($this->db); + dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); - // Define output language - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - $outputlangs->loadLangs(array('main', 'member', 'partnership')); - } - - $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); - - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - - $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); - $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); - $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - - $to = $obj->email; - - $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); - $result = $cmail->sendfile(); - if (!$result || $cmail->error) { - $erroremail .= ($erroremail ? ', ' : '').$cmail->error; - $this->errors[] = $cmail->error; - if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail = new FormMail($this->db); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main', 'member', 'partnership')); + } + + $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + + $to = $obj->email; + + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $result = $cmail->sendfile(); + if (!$result || $cmail->error) { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } } + } elseif ($tmpcount > $nbmaxbacklinkerrorforcancel) { // Cancel Partnership + $object->status = $object::STATUS_CANCELED; + $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite'); } - } elseif ($tmpcount > 4) { // Cancel Partnership - $object->status = $object::STATUS_CANCELED; - $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite'); } $object->count_last_url_check_error = $tmpcount; @@ -394,7 +401,7 @@ class PartnershipUtils */ private function checkDolibarrBacklink($website = null) { - global $conf, $langs, $user; + global $conf; $found = 0; $error = 0; From 44d3985a9511e0b669a8ad49e234568b4de3722b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 18:41:20 +0200 Subject: [PATCH 24/37] Fix max nb of record processed --- htdocs/partnership/class/partnershiputils.class.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index f8589adab89..f93ae291701 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -215,16 +215,19 @@ class PartnershipUtils * * CAN BE A CRON TASK * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + * @param int $maxpercall Max per call + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - public function doWarningOfPartnershipIfDolibarrBacklinkNotfound() + public function doWarningOfPartnershipIfDolibarrBacklinkNotfound($maxpercall = 0) { global $conf, $langs, $user; $managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR'); $partnership = new Partnership($this->db); - $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call + if (empty($maxpercall)) { + $maxpercall = getDolGlobalInt('PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL', 10); + } $langs->loadLangs(array("partnership", "member")); @@ -278,8 +281,8 @@ class PartnershipUtils if ($obj) { if (!empty($partnershipsprocessed[$obj->rowid])) continue; - if ($somethingdoneonpartnership >= $MAXPERCALL) { - dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); + if ($somethingdoneonpartnership >= $maxpercall) { + dol_syslog("We reach the limit of ".$maxpercall." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); break; } From ae264ec0fe3267329e59f9a1e76604d4869a1779 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 18:53:16 +0200 Subject: [PATCH 25/37] Fix warning --- htdocs/partnership/class/partnershiputils.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index f93ae291701..3c953cb9583 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -239,7 +239,7 @@ class PartnershipUtils $emailnotfound = ''; $websitenotfound = ''; - $gracedelay = $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + $gracedelay = getDolGlobalInt('PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL', 0); if ($gracedelay < 1) { $this->error = 'BadValueForDelayBeforeCancelCheckSetup'; return -1; @@ -279,7 +279,9 @@ class PartnershipUtils $obj = $this->db->fetch_object($resql); if ($obj) { - if (!empty($partnershipsprocessed[$obj->rowid])) continue; + if (!empty($partnershipsprocessed[$obj->rowid])) { + continue; + } if ($somethingdoneonpartnership >= $maxpercall) { dol_syslog("We reach the limit of ".$maxpercall." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); From 26b6fa98befc4c291c60b9a006af444e8dfab27e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 19:40:23 +0200 Subject: [PATCH 26/37] Fix field last check not visible --- htdocs/partnership/class/partnership.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index b7b9f2b6b41..969bb3886e4 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -122,7 +122,7 @@ class Partnership extends CommonObject 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax100'), 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), - 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), + 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-4,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), 'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'Approved', '3'=>'Refused', '9'=>'Terminated'),), From 5723c4562a4c6c5dedb6095369d1ca574154052e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 19:47:17 +0200 Subject: [PATCH 27/37] Fix setup of fields for partnership --- htdocs/partnership/class/partnership.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 969bb3886e4..a1244d00c3b 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -120,9 +120,9 @@ class Partnership extends CommonObject 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), - 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax100'), - 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), - 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-4,), + 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax100'), + 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), + 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>72, 'notnull'=>0, 'visible'=>-4,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), 'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'Approved', '3'=>'Refused', '9'=>'Terminated'),), From cb09d138678843d6ddc32e058ebf5a4bfdcf7aae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 20:08:32 +0200 Subject: [PATCH 28/37] Fix id of event --- htdocs/partnership/class/partnershiputils.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 3c953cb9583..b9daf1959cf 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -349,8 +349,13 @@ class PartnershipUtils $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; $to = $obj->email; + if ($managedfor == 'member') { + $trackid = 'mem'.$fk_partner; + } else { + $trackid = 'thi'.$fk_partner; + } - $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid); $result = $cmail->sendfile(); if (!$result || $cmail->error) { $erroremail .= ($erroremail ? ', ' : '').$cmail->error; From dd7c09bb153793723313cc2270bdf525c75008fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 20:16:44 +0200 Subject: [PATCH 29/37] Fix min --- htdocs/partnership/class/partnershiputils.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index b9daf1959cf..c129eb644fa 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -310,7 +310,7 @@ class PartnershipUtils if (!$backlinkfound) { $tmpcount = $object->count_last_url_check_error + 1; - $nbminbacklinkerrorforcancel = getDolGlobalString('PARTNERSHIP_MIN_BACKLINK_ERROR_FOR_CANCEL', 2); + $nbminbacklinkerrorforcancel = getDolGlobalString('PARTNERSHIP_MIN_BACKLINK_ERROR_FOR_CANCEL', 3); $nbmaxbacklinkerrorforcancel = getDolGlobalString('PARTNERSHIP_MAX_BACKLINK_ERROR_FOR_CANCEL', $nbminbacklinkerrorforcancel + 2); // If $nbminbacklinkerrorforemail = 0, no autoemail From 2a8c4dfb6a0f0db30f245829f6b87e8532c9372b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 22:38:19 +0200 Subject: [PATCH 30/37] Fix name of debug constant --- htdocs/core/class/hookmanager.class.php | 4 ++-- htdocs/core/lib/geturl.lib.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 611aabe42e9..d05cd8db8c7 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -241,7 +241,7 @@ class HookManager $actionclassinstance->error = 0; $actionclassinstance->errors = array(); - if (getDolGlobalInt('MAIN_DEBUG_HOOK')) { + if (getDolGlobalInt('MAIN_HOOK_DEBUG')) { // This his too much verbose, enabled if const enabled only dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".get_class($actionclassinstance).'->'.$method.", context=".$context.", module=".$module.", action=".$action.((is_object($object) && property_exists($object, 'id')) ? ', object id='.$object->id : '').((is_object($object) && property_exists($object, 'element')) ? ', object element='.$object->element : ''), LOG_DEBUG); } @@ -283,7 +283,7 @@ class HookManager continue; } - if (getDolGlobalInt('MAIN_DEBUG_HOOK')) { + if (getDolGlobalInt('MAIN_HOOK_DEBUG')) { dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG); } diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 6255bd81710..b628a74589d 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -238,9 +238,10 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request dol_syslog("getURLContent request=".$request); - if (!empty($conf->global->MAIN_GETURLCONTENT_OUTPUT_RESPONSE)) { + if (getDolGlobalInt('MAIN_CURL_DEBUG')) { // This may contains binary data, so we dont output reponse by default. - dol_syslog("getURLContent response =".$response); + dol_syslog("getURLContent request=".$request, LOG_DEBUG, '_curl'); + dol_syslog("getURLContent response =".$response, LOG_DEBUG, '_curl'); } dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it From bc96128b599014b87b4142216b8213779f06055a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 22:41:35 +0200 Subject: [PATCH 31/37] Fix data format --- htdocs/partnership/class/partnershiputils.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index c129eb644fa..121e2465135 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -377,7 +377,7 @@ class PartnershipUtils $partnershipsprocessed[$object->id] = $object->ref; - $object->last_check_backlink = $this->db->idate($now); + $object->last_check_backlink = $now; $object->update($user); } From 85aad3fdca491e3329c9d1fdf93351a9e175f615 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 22:59:15 +0200 Subject: [PATCH 32/37] Fix can reset max nb of url check in partnership module --- htdocs/partnership/class/partnership.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index a1244d00c3b..8696117b187 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -121,7 +121,7 @@ class Partnership extends CommonObject 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax100'), - 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), + 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>71, 'notnull'=>0, 'visible'=>-4, 'default'=>'0',), 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>72, 'notnull'=>0, 'visible'=>-4,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), 'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), From 9fe16d9e76465863557e5812995c970e84282f8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 23:08:21 +0200 Subject: [PATCH 33/37] Fix ident log --- htdocs/core/lib/geturl.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index b628a74589d..9f19233dcad 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -240,8 +240,8 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = dol_syslog("getURLContent request=".$request); if (getDolGlobalInt('MAIN_CURL_DEBUG')) { // This may contains binary data, so we dont output reponse by default. - dol_syslog("getURLContent request=".$request, LOG_DEBUG, '_curl'); - dol_syslog("getURLContent response =".$response, LOG_DEBUG, '_curl'); + dol_syslog("getURLContent request=".$request, LOG_DEBUG, 0, '_curl'); + dol_syslog("getURLContent response =".$response, LOG_DEBUG, 0, '_curl'); } dol_syslog("getURLContent response size=".strlen($response)); // This may contains binary data, so we dont output it From fbf23b4cbb553ef04a66a7ee65f8769bae708766 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2023 23:18:07 +0200 Subject: [PATCH 34/37] Fix bad url to check for backlink --- htdocs/partnership/class/partnershiputils.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 121e2465135..67be54b4de3 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -255,7 +255,7 @@ class PartnershipUtils $this->db->begin(); $sql = "SELECT p.rowid, p.status, p.".$fk_partner; - $sql .= ", p.last_check_backlink"; + $sql .= ", p.url_to_check, p.last_check_backlink"; $sql .= ', partner.url, partner.email'; $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; if ($managedfor == 'member') { @@ -299,7 +299,7 @@ class PartnershipUtils $fk_partner = $object->fk_soc; } - $website = $obj->url; + $website = (empty($obj->url_to_check) ? $obj->url : $obj->url_to_check); if (empty($website)) { $websitenotfound .= ($websitenotfound ? ', ' : '').'Website not found for id="'.$fk_partner.'"'."\n"; From 58ea4239b8cf7d204e62e9cca9038892c843cc01 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2023 11:41:36 +0200 Subject: [PATCH 35/37] Fix dead code --- htdocs/partnership/class/partnershiputils.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index c73bc4230d4..6c97d8a1b6b 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -236,18 +236,18 @@ class PartnershipUtils $emailnotfound = ''; $websitenotfound = ''; - $gracedelay = $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + /*$gracedelay = getDolGlobalInt('PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL'); if ($gracedelay < 1) { $this->error = 'BadValueForDelayBeforeCancelCheckSetup'; return -1; - } + }*/ $fk_partner = ($managedfor == 'member') ? 'fk_member' : 'fk_soc'; dol_syslog(get_class($this)."::doWarningOfPartnershipIfDolibarrBacklinkNotfound Warning of partnership"); $now = dol_now(); - $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); + //$datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); $this->db->begin(); @@ -276,7 +276,9 @@ class PartnershipUtils $obj = $this->db->fetch_object($resql); if ($obj) { - if (!empty($partnershipsprocessed[$obj->rowid])) continue; + if (!empty($partnershipsprocessed[$obj->rowid])) { + continue; + } if ($somethingdoneonpartnership >= $MAXPERCALL) { dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); From 0d2d68dfc777285d6a9143155a3ade55846c8023 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2023 13:23:11 +0200 Subject: [PATCH 36/37] FIX #25934 #25929 --- htdocs/comm/propal/class/api_proposals.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index cc6bfb2aa2f..bbdc3cab71d 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -283,7 +283,7 @@ class Proposals extends DolibarrApi /** * Get lines of a commercial proposal * - * @param int $id Id of commercial proposal + * @param int $id Id of commercial proposal * @param string $sqlfilters Other criteria to filter answers separated by a comma. d is the alias for proposal lines table, p is the alias for product table. "Syntax example "(p.ref:like:'SO-%') and (d.date_start:<:'20220101')" * * @url GET {id}/lines @@ -292,8 +292,6 @@ class Proposals extends DolibarrApi */ public function getLines($id, $sqlfilters = '') { - $filters = ""; - if (!DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } @@ -307,6 +305,7 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + $sql = ''; if (!empty($sqlfilters)) { $errormessage = ''; $sql = forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage); From 5e0bd9bb71e29c2b9c2d11285e19f4293c5f49ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2023 13:53:29 +0200 Subject: [PATCH 37/37] Avoid warning --- htdocs/core/db/Database.interface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 7e0efa222db..f689df2a70d 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -191,7 +191,7 @@ interface Database /** * Escape a string to insert data into a like. - * Can be used this way: LIKE '%".$this->db->escapeforlike($this->db->escape(...))."%' + * Can be used this way: LIKE '%".dbhandler->escapeforlike(dbhandler->escape(...))."%' * * @param string $stringtoencode String to escape * @return string String escaped