diff --git a/ChangeLog b/ChangeLog index a0988a8e5c1..b4f470fbf52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1019,6 +1019,7 @@ FIX: when qty is not an integer, apply price() (#31138) FIX: Wrong default PDF model when creating the second situation invoice (#30843) FIX: wrong subprice if price base type is TTC (#30887) + ***** ChangeLog for 19.0.3 compared to 19.0.2 ***** FIX: #29403 HRM - Unable to delete a skill in a job Profile (#29779) FIX: #29439 incomplete API return (#29796) @@ -1583,7 +1584,39 @@ The following changes may create regressions for some external modules, but were * The load of hook context productdao has been removed before calling loadvirtualstock. Modules must use the context of main parent page or 'all' for all cases. +***** ChangeLog for 18.0.8 compared to 18.0.7 ***** +35 files changed, 647 insertions(+), 298 deletions(-) + +FIX: #34746 - More complete fix for CVE-2024-40137 +FIX: Correct the calculation of the amount of the current period between the period provided (#35083) +FIX: Add security test for show terminal selection if no terminal selected when invoice.php is call (#34717) +FIX: Add security test for show terminal selection if no terminal selected when invoice.php is call +FIX: missing quick edit for extrafields (baclport commit 4fc66c6) (#35160) +FIX: Missing sentence part (#35144) +FIX: set global mysoc and load langs in API access (#35041) +FIX: set global mysoc and load langs in API access +FIX: reset mysoc and langs only if entity of API has changed +FIX: accountancy general ledger: bad handling of hook return (#34029) +FIX: accountancy general ledger: bad handling of hook return +FIX: accountancy balance: bad handling of hook return +FIX: - Fix missing token for disable custom group category for compta report (page /htdocs/accountancy/admin/categories_list.php) (#35084) +FIX: The combo of custom groups has disappeared (backport v19) (#35016) +FIX: #34893 (#34897) +FIX: #34893 +FIX: change error code to USERNOTALLOWEDTOCHANGEPASS +FIX: asset: could not select invoice in disposal pop-in (#34725) +FIX: 17.0 SQL syntax error and/or constraint error when calling Facture::update() after a clone (e.g. in a trigger) (#34778) +FIX: 17.0: when you clone an invoice that was created from a template invoice, the clone should not be linked to the template invoice (#34777) +FIX: pre-send mail mass action: keep __EMAIL__ substitution (#34522) +FIX: pre-send mail mass action: keep __EMAIL__ substitution +FIX: comment +FIX: massaction email tpl: keep preset +FIX: loop interrupt if an error occurs in sendEmailsRemindersOnInvoiceDueDate (#34657) +FIX: #34654 + ***** ChangeLog for 18.0.7 compared to 18.0.6 ***** +138 files changed, 1622 insertions(+), 530 deletions(-) + FIX: 17.0 API endpoints "PUT": prevent overwriting all extrafields if only some are supplied in the request cf. PR #29237 FIX: 17.0 - collisions in cache for dol_getIdFromCode FIX: 17.0 - missing error handling for FactureRec::fetch in card-rec.php diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index c97194efa18..a5dfff8a970 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -173,7 +173,7 @@ $files = new RegexIterator($iterator1, '#^(?:[A-Z]:)?(?:/(?!(?:'.($includecustom */ // Define qualified files (must be same than into generate_filelist_xml.php and in api_setup.class.php) $regextoinclude = '\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|bak|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$'; -$regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs +$regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|escpos-php\/doc|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs $files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname'); $dir = ''; diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 6636f7b82b1..0374442c092 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -2547,7 +2547,7 @@ class Setup extends DolibarrApi // Define qualified files (must be same than into generate_filelist_xml.php and in api_setup.class.php) $regextoinclude = '\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|bak|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$'; - $regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs + $regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|escpos-php\/doc|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); // Fill file_list with files in signature, new files, modified files diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 5c5fb2bfbbe..39561ca9d10 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -290,7 +290,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes' && !empty($permissionto $langs->load("errors"); // lang must be loaded because we can't rely on loading during output, we need var substitution to be done now. setEventMessages($langs->trans("ErrorFilenameCantStartWithDot", $filenameto), null, 'errors'); } elseif (!file_exists($destpath)) { - $result = dol_move($srcpath, $destpath); + $result = dol_move($srcpath, $destpath, '0', 1, 0, 1, [], $object->entity ?? 0); if ($result) { // Define if we have to generate thumbs or not $generatethumbs = 1; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1c2e3c1c742..8d82ea46f9f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1028,11 +1028,12 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep * @param int<0,1> $overwriteifexists Overwrite file if exists (1 by default) * @param int<0,1> $testvirus Do an antivirus test. Move is canceled if a virus is found. * @param int<0,1> $indexdatabase Index new file into database. - * @param array $moreinfo Array with more information to set in index table + * @param array $moreinfo Array with more information to set in index table + * @param int $entity Entity * @return boolean True if OK, false if KO * @see dol_move_uploaded_file() */ -function dol_move($srcfile, $destfile, $newmask = '0', $overwriteifexists = 1, $testvirus = 0, $indexdatabase = 1, $moreinfo = array()) +function dol_move($srcfile, $destfile, $newmask = '0', $overwriteifexists = 1, $testvirus = 0, $indexdatabase = 1, $moreinfo = array(), $entity = 0) { global $user, $db; $result = false; @@ -1106,13 +1107,13 @@ function dol_move($srcfile, $destfile, $newmask = '0', $overwriteifexists = 1, $ include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; $ecmfiletarget = new EcmFiles($db); - $resultecmtarget = $ecmfiletarget->fetch(0, '', $rel_filetorenameafter); + $resultecmtarget = $ecmfiletarget->fetch(0, '', $rel_filetorenameafter, '', '', '', 0, $entity); if ($resultecmtarget > 0) { // An entry for target name already exists for target, we delete it, a new one will be created. $ecmfiletarget->delete($user); } $ecmfile = new EcmFiles($db); - $resultecm = $ecmfile->fetch(0, '', $rel_filetorenamebefore); + $resultecm = $ecmfile->fetch(0, '', $rel_filetorenamebefore, '', '', '', 0, $entity); if ($resultecm > 0) { // If an entry was found for src file, we use it to move entry $filename = basename($rel_filetorenameafter); $rel_dir = dirname($rel_filetorenameafter); @@ -1166,6 +1167,9 @@ function dol_move($srcfile, $destfile, $newmask = '0', $overwriteifexists = 1, $ if (!empty($moreinfo) && !empty($moreinfo['cover'])) { $ecmfile->cover = $moreinfo['cover']; } + if (! empty($entity)) { + $ecmfile->entity = $entity; + } $resultecm = $ecmfile->create($user); if ($resultecm < 0) { @@ -1585,7 +1589,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; $ecmfile = new EcmFiles($db); - $result = $ecmfile->fetch(0, '', $rel_filetodelete); + $result = $ecmfile->fetch(0, '', $rel_filetodelete, '', '', '', 0, $object->entity ?? 0); if ($result >= 0 && $ecmfile->id > 0) { $result = $ecmfile->delete($user); } @@ -2038,7 +2042,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $updatesessionor // If we allow overwrite, we may need to also overwrite index, so we delete index first so insert can work if ($allowoverwrite) { - deleteFilesIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), ''); + deleteFilesIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), '', $object); } $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', $sharefile, $object, $forceFullTextIndexation); @@ -2208,6 +2212,9 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo if (isset($object->src_object_keywords)) { $ecmfile->keywords = $object->src_object_keywords; } + if (isset($object->entity)) { + $ecmfile->entity = $object->entity; + } } if (getDolGlobalString('MAIN_FORCE_SHARING_ON_ANY_UPLOADED_FILE')) { @@ -2322,9 +2329,10 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo * @param string $dir Directory name (full real path without ending /) * @param string $file File name * @param string $mode How file was created ('uploaded', 'generated', ...) + * @param Object $object object used for entity * @return int Return integer <0 if KO, 0 if nothing done, >0 if OK */ -function deleteFilesIntoDatabaseIndex($dir, $file, $mode = 'uploaded') +function deleteFilesIntoDatabaseIndex($dir, $file, $mode = 'uploaded', $object = null) { global $conf, $db; @@ -2348,7 +2356,11 @@ function deleteFilesIntoDatabaseIndex($dir, $file, $mode = 'uploaded') if (!$error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'ecm_files'; - $sql .= ' WHERE entity = '.((int) $conf->entity); + if (isset($object->entity)) { + $sql .= ' WHERE entity = ' . ((int) $object->entity); + } else { + $sql .= ' WHERE entity = ' . ((int) $conf->entity); + } $sql .= " AND filepath = '".$db->escape($rel_dir)."'"; if ($file) { $sql .= " AND filename = '".$db->escape($file)."'"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6843b630484..7d6bd6598e5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13475,7 +13475,7 @@ function getElementProperties($elementType) $classname = 'CommandeFournisseurLigne'; $table_element = 'commande_fournisseurdet'; $parent_element = 'commande_fournisseur'; - } elseif ($elementType == 'invoice_supplier') { + } elseif ($elementType == 'invoice_supplier' || $elementType == 'facture_fourn') { $classpath = 'fourn/class'; $module = 'fournisseur'; $classfile = 'fournisseur.facture'; diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index ec1a5fca746..debd3a2efbf 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -408,9 +408,10 @@ class EcmFiles extends CommonObject * @param string $hashforshare Hash of file sharing, or 'shared' * @param string $src_object_type src_object_type to search (value of object->table_element) * @param int $src_object_id src_object_id to search + * @param int $entity entity * @return int Return integer <0 if KO, 0 if not found, >0 if OK */ - public function fetch($id, $ref = '', $relativepath = '', $hashoffile = '', $hashforshare = '', $src_object_type = '', $src_object_id = 0) + public function fetch($id, $ref = '', $relativepath = '', $hashoffile = '', $hashforshare = '', $src_object_type = '', $src_object_id = 0, $entity = 0) { global $conf; @@ -457,17 +458,29 @@ class EcmFiles extends CommonObject if ($filename != '*') { $sql .= " AND t.filename = '".$this->db->escape($filename)."'"; } - $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index + if (! empty($entity)) { + $sql .= " AND t.entity = " . (int) $entity; + } else { + $sql .= " AND t.entity = " . $conf->entity; // unique key include the entity so each company has its own index + } $filterfound++; } if (!empty($ref)) { // hash of file path $sql .= " AND t.ref = '".$this->db->escape($ref)."'"; - $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index + if (! empty($entity)) { + $sql .= " AND t.entity = " . (int) $entity; + } else { + $sql .= " AND t.entity = " . $conf->entity; // unique key include the entity so each company has its own index + } $filterfound++; } if (!empty($hashoffile)) { // hash of content $sql .= " AND t.label = '".$this->db->escape($hashoffile)."'"; - $sql .= " AND t.entity = ".$conf->entity; // unique key include the entity so each company has its own index + if (! empty($entity)) { + $sql .= " AND t.entity = " . (int) $entity; + } else { + $sql .= " AND t.entity = " . $conf->entity; // unique key include the entity so each company has its own index + } $filterfound++; } if (!empty($hashforshare)) { @@ -481,7 +494,11 @@ class EcmFiles extends CommonObject } if ($src_object_type && $src_object_id) { $sql .= " AND t.src_object_type = '".$this->db->escape($src_object_type)."' AND t.src_object_id = ".((int) $src_object_id); - $sql .= " AND t.entity = ".((int) $conf->entity); + if (! empty($entity)) { + $sql .= " AND t.entity = " . (int) $entity; + } else { + $sql .= " AND t.entity = " . $conf->entity; // unique key include the entity so each company has its own index + } $filterfound++; } if ($id > 0 || empty($filterfound)) { @@ -766,7 +783,6 @@ class EcmFiles extends CommonObject $sql .= ' src_object_id = '.($this->src_object_id > 0 ? $this->src_object_id : "null").','; $sql .= ' src_object_type = '.(isset($this->src_object_type) ? "'".$this->db->escape($this->src_object_type)."'" : "null"); $sql .= ' WHERE rowid='.((int) $this->id); - $this->db->begin(); $resql = $this->db->query($sql); diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 1c7d90d763c..a3ac3204942 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -935,6 +935,7 @@ class Productlot extends CommonObject } $sql .= " WHERE cf.entity IN (".getEntity('expedition').")"; $sql .= " AND cfdi.batch = '".($this->db->escape($this->batch))."'"; + $sql .= " AND cfdi.fk_product = " . (int) $this->fk_product; if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php index ce07ee4a3de..cd03daeb4d6 100644 --- a/htdocs/product/stock/stats/commande_fournisseur.php +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -240,6 +240,7 @@ if ($id > 0 || !empty($ref)) { } $sql .= " WHERE cf.entity IN (".getEntity('product').")"; $sql .= " AND cfdi.batch = '".($db->escape($object->batch))."'"; + $sql .= " AND cfdi.fk_product = " . (int) $object->fk_product; if (!empty($search_month)) { $sql .= ' AND MONTH(cf.date_commande) IN ('.$db->sanitize($search_month).')'; } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 861caa5e7e1..1c88d8a8409 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -783,7 +783,7 @@ if (empty($reshook)) { if (getDolGlobalString('THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir - deleteFilesIntoDatabaseIndex(dirname($newfile), '', ''); + deleteFilesIntoDatabaseIndex(dirname($newfile), '', '', $object); // now we index the uploaded logo file addFileIntoDatabaseIndex(dirname($newfile), basename($newfile), '', 'uploaded', 1); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 376ac87b836..75c48472322 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -5014,10 +5014,12 @@ class Societe extends CommonObject $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); */ + $today = dol_get_first_hour(dol_now('tzuser')); // Returns today at 00:00 in the user's time zone + $sql = "SELECT rowid, ref, total_ht, total_ttc, paye, type, fk_statut as status, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; $sql .= " WHERE fk_soc = ".((int) $this->id); if (!empty($late)) { - $sql .= " AND date_lim_reglement < '".$this->db->idate(dol_now())."'"; + $sql .= " AND date_lim_reglement < '".$this->db->idate($today)."'"; } if ($mode == 'supplier') { $sql .= " AND entity IN (".getEntity('facture_fourn').")";