Automated merge from 18.0 to 19.0 by tool pullmerge.sh

This commit is contained in:
Laurent Destailleur 2026-04-10 13:28:26 +02:00
commit 0bbc3da4d0
6 changed files with 93 additions and 30 deletions

View file

@ -104,6 +104,23 @@ class Documents extends DolibarrApi
throw new RestException(401);
}
if (DolibarrApiAccess::$user->socid > 0) {
if ($sqlprotectagainstexternals) {
$resql = $this->db->query($sqlprotectagainstexternals);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
if (DolibarrApiAccess::$user->socid != $obj->fk_soc) {
throw new RestException(403, 'Not allowed to download documents with such a ref');
}
$i++;
}
}
}
}
$filename = basename($original_file);
$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
@ -181,6 +198,23 @@ class Documents extends DolibarrApi
throw new RestException(401);
}
if (DolibarrApiAccess::$user->socid > 0) {
if ($sqlprotectagainstexternals) {
$resql = $this->db->query($sqlprotectagainstexternals);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
if (DolibarrApiAccess::$user->socid != $obj->fk_soc) {
throw new RestException(403, 'Not allowed to download documents with such a ref');
}
$i++;
}
}
}
}
// --- Generates the document
$hidedetails = !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 0 : 1;
$hidedesc = !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 0 : 1;
@ -974,6 +1008,23 @@ class Documents extends DolibarrApi
throw new RestException(401);
}
if (DolibarrApiAccess::$user->socid > 0) {
if ($sqlprotectagainstexternals) {
$resql = $this->db->query($sqlprotectagainstexternals);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
if (DolibarrApiAccess::$user->socid != $obj->fk_soc) {
throw new RestException(403, 'Not allowed to download documents with such a ref');
}
$i++;
}
}
}
}
$filename = basename($original_file);
$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset

View file

@ -95,7 +95,6 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
$value = ($type == 'ckeditor' ? GETPOST('value', '', 2) : GETPOST('value', 'alpha', 2));
$loadmethod = GETPOST('loadmethod', 'alpha', 2);
$savemethod = GETPOST('savemethod', 'alpha', 2);
$savemethodname = (!empty($savemethod) ? $savemethod : 'setValueFrom');
$newelement = $element;
$view = '';
@ -218,11 +217,7 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
}
}
if (!$error) {
if ((isset($object) && !is_object($object)) || empty($savemethod)) {
$object = new GenericObject($db);
}
if (!$error && isset($object) && is_object($object)) {
// Specific for add_object_linked()
// TODO add a function for variable treatment
$object->ext_fk_element = $newvalue;
@ -230,7 +225,7 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
$object->fk_element = $fk_element;
$object->element = $element;
$ret = $object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format);
$ret = $object->setValueFrom($field, $newvalue, $object->table_element, $fk_element, $format);
if ($ret > 0) {
if ($type == 'numeric') {
$value = price($newvalue);

View file

@ -215,7 +215,7 @@ if (empty($modulepart)) {
}
// Check security and set return info with full path of file
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $user, '');
$check_access = dol_check_secure_access_document($modulepart, $original_file, (int) $entity, $user, '', 'read');
$accessallowed = $check_access['accessallowed'];
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
$fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name

View file

@ -296,6 +296,13 @@ if (!empty($_SERVER['DOCUMENT_ROOT']) && substr($_SERVER['DOCUMENT_ROOT'], -6) !
// Include the conf.php and functions.lib.php and security.lib.php. This defined the constants like DOL_DOCUMENT_ROOT, DOL_DATA_ROOT, DOL_URL_ROOT...
require_once 'filefunc.inc.php';
/**
* @var ?string $php_session_save_handler
* @var ?string $dolibarr_main_force_https
* @var ?string $dolibarr_main_restrict_ip
* @var ?string $dolibarr_nocsrfcheck
* @var ?string $dolibarr_main_demo
*/
// If there is a POST parameter to tell to save automatically some POST parameters into cookies, we do it.
// This is used for example by form of boxes to save personalization of some options.
@ -640,33 +647,38 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt(
// Note: There is another CSRF protection into the filefunc.inc.php
}
// Disable modules (this must be after session_start and after conf has been loaded)
if (GETPOSTISSET('disablemodules')) {
$_SESSION["disablemodules"] = GETPOST('disablemodules', 'alpha');
}
if (!empty($_SESSION["disablemodules"])) {
$modulepartkeys = array('css', 'js', 'tabs', 'triggers', 'login', 'substitutions', 'menus', 'theme', 'sms', 'tpl', 'barcode', 'models', 'societe', 'hooks', 'dir', 'syslog', 'tpllinkable', 'contactelement', 'moduleforexternal');
$disabled_modules = explode(',', $_SESSION["disablemodules"]);
foreach ($disabled_modules as $module) {
if ($module) {
if (empty($conf->$module)) {
$conf->$module = new stdClass(); // To avoid warnings
}
$conf->$module->enabled = false;
foreach ($modulepartkeys as $modulepartkey) {
unset($conf->modules_parts[$modulepartkey][$module]);
}
if ($module == 'fournisseur') { // Special case
$conf->supplier_order->enabled = 0;
$conf->supplier_invoice->enabled = 0;
if (!empty($dolibarr_main_demo)) {
// Disable modules (this must be after session_start and after conf has been loaded)
if (GETPOSTISSET('disablemodules')) {
$_SESSION["disablemodules"] = GETPOST('disablemodules', 'alpha');
}
if (!empty($_SESSION["disablemodules"])) {
$modulepartkeys = array('css', 'js', 'tabs', 'triggers', 'login', 'substitutions', 'menus', 'theme', 'sms', 'tpl', 'barcode', 'models', 'societe', 'hooks', 'dir', 'syslog', 'tpllinkable', 'contactelement', 'moduleforexternal');
$disabled_modules = explode(',', $_SESSION["disablemodules"]);
foreach ($disabled_modules as $module) {
if ($module) {
if (empty($conf->$module)) {
$conf->$module = new stdClass(); // To avoid warnings
}
$conf->$module->enabled = false; // Old usage
foreach ($modulepartkeys as $modulepartkey) {
unset($conf->modules_parts[$modulepartkey][$module]);
}
if ($module == 'fournisseur') { // Special case
$conf->supplier_order->enabled = 0;
$conf->supplier_invoice->enabled = 0;
}
}
}
}
}
// Set current modulepart
$modulepart = explode("/", $_SERVER["PHP_SELF"]);
// Set current modulepart
$modulepart = explode("/", $_SERVER["PHP_SELF"]);
if (is_array($modulepart) && count($modulepart) > 0) {
foreach ($conf->modules as $module) {
if (in_array($module, $modulepart)) {

View file

@ -742,6 +742,11 @@ if ($action == 'create' || $action == 'presend') {
print load_fiche_titre($langs->trans('NewTicket'), '', 'ticket');
$formticket->trackid = ''; // TODO Use a unique key 'tic' to avoid conflict in upload file feature
if (GETPOST("mode", "aZ09") == 'init' && empty($_POST)) {
$formticket->clear_attached_files();
}
$formticket->withfromsocid = $socid ? $socid : $user->socid;
$formticket->withfromcontactid = $contactid ? $contactid : '';
$formticket->withtitletopic = 1;

View file

@ -769,7 +769,7 @@ if ($projectid) {
print '<input type="hidden" name="projectid" value="'.$projectid.'" >';
}
$url = DOL_URL_ROOT.'/ticket/card.php?action=create'.($socid ? '&socid='.$socid : '').($projectid ? '&origin=projet_project&originid='.$projectid : '');
$url = DOL_URL_ROOT.'/ticket/card.php?action=create&mode=init'.($socid ? '&socid='.$socid : '').($projectid ? '&origin=projet_project&originid='.$projectid : '');
if (!empty($socid)) {
$url .= '&socid='.$socid;
}