diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php
index 9bd9600d1c0..a9fad1c14b4 100644
--- a/htdocs/comm/action/list.php
+++ b/htdocs/comm/action/list.php
@@ -294,9 +294,9 @@ $nav .= ' ref_client = '';
- $object->ref_customer = '';
+ if (!getDolGlobalString('MAIN_KEEP_REF_CUSTOMER_ON_CLONING')) {
+ $object->ref_client = '';
+ $object->ref_customer = '';
+ }
// TODO Change product price if multi-prices
} else {
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 08485ad9896..f5ae26357a2 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -8246,6 +8246,9 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = '
}
}
+ // Clear ZERO WIDTH NO-BREAK SPACE, ZERO WIDTH SPACE, ZERO WIDTH JOINER
+ $out = preg_replace('/[\x{200B}-\x{200D}\x{FEFF}]/u', ' ', $out);
+
// Clean some html entities that are useless so text is cleaner
$out = preg_replace('/&(tab|newline);/i', ' ', $out);
@@ -8356,6 +8359,7 @@ function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom = 'UT
if ($removelasteolbr) {
$newstring = preg_replace('/ $/i', '', $newstring); // Remove last (remove only last one)
}
+ $newstring = preg_replace('/[\x{200B}-\x{200D}\x{FEFF}]/u', ' ', $newstring);
$newstring = strtr($newstring, array('&' => '__and__', '<' => '__lt__', '>' => '__gt__', '"' => '__dquot__'));
$newstring = dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom); // Make entity encoding
$newstring = strtr($newstring, array('__and__' => '&', '__lt__' => '<', '__gt__' => '>', '__dquot__' => '"'));
diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
index 732b92d1b9f..d0c891e7dc4 100644
--- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
@@ -858,11 +858,11 @@ class pdf_espadon extends ModelePdfExpedition
$object->volume_units = (float) $object->size_units * 3;
}
- if ($totalWeight != '') {
- $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
+ if (!empty($totalWeight)) {
+ $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
}
- if ($totalVolume != '') {
- $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
+ if (!empty($totalVolume)) {
+ $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
}
if (!empty($object->trueWeight)) {
$totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index 05372549673..c41e1e83f0f 100644
--- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -750,11 +750,11 @@ class pdf_rouget extends ModelePdfExpedition
$object->volume_units = (float) $object->size_units * 3;
}
- if ($totalWeight != '') {
- $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
+ if (!empty($totalWeight)) {
+ $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
}
- if ($totalVolume != '') {
- $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
+ if (!empty($totalVolume)) {
+ $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
}
if (!empty($object->trueWeight)) {
$totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 43a43a63e9c..ed8c7863754 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -1572,8 +1572,8 @@ if (!function_exists("llxHeader")) {
* Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage
* For other external page: http://server/url
* @param string $target Target to use on links
- * @param int $disablejs More content into html header
- * @param int $disablehead More content into html header
+ * @param int<0,1> $disablejs More content into html header
+ * @param int<0,1> $disablehead More content into html header
* @param array|string $arrayofjs Array of complementary js files
* @param array|string $arrayofcss Array of complementary css files
* @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails)
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index 8621d3ebbe4..0e49df28f56 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -1635,7 +1635,7 @@ class Project extends CommonObject
* @param int $mode 0=All project I have permission on (assigned to me or public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts
* @param int $list 0=Return array, 1=Return string list
* @param int $socid 0=No filter on third party, id of third party
- * @param string $filter additional filter on project (statut, ref, ...)
+ * @param string $filter additional filter on project (statut, ref, ...). TODO Use USF syntax here.
* @return array|string Array of projects id, or string with projects id separated with "," if list is 1
*/
public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '')
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index b65dce3385e..3ad45eb8068 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -9,6 +9,7 @@
* Copyright (C) 2023 Gauthier VERDOL
* Copyright (C) 2024 MDW
* Copyright (C) 2024 Vincent de Grandpré
+ * Copyright (C) 2024 Solution Libre SAS
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1599,6 +1600,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$sql .= $hookmanager->resPrint;
$sql .= " WHERE elementtype = 'task'";
$sql .= " AND p.entity IN (".getEntity('project').")";
+ if (!$user->hasRight('projet', 'all', 'lire')) {
+ // Get list of project id allowed to user (in a string list separated by comma)
+ // TODO This may generate performance trouble when list of project is very large. Solution can be to complete $filterproj with filters on project.
+ $filterproj = '';
+ $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $user->socid > 0 ? $user->socid : 0, $filterproj);
+ $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
+ }
if (empty($projectidforalltimes) && empty($allprojectforuser)) {
// Limit on one task
$sql .= " AND t.fk_element =".((int) $object->id);
diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php
index bc779cfa388..1c0380b475c 100644
--- a/htdocs/public/project/new.php
+++ b/htdocs/public/project/new.php
@@ -214,7 +214,7 @@ if (empty($reshook) && $action == 'add') {
if (!$error) {
// Search thirdparty and set it if found to the new created project
- $result = $thirdparty->fetch(0, '', '', '', '', '', '', '', '', '', $object->email);
+ $result = $thirdparty->fetch(0, '', '', '', '', '', '', '', '', '', GETPOST('email'));
if ($result > 0) {
$proj->socid = $thirdparty->id;
} else {
diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php
index c96380bdcc5..9eb4e51e7fa 100644
--- a/test/phpunit/AllTests.php
+++ b/test/phpunit/AllTests.php
@@ -24,6 +24,7 @@
* \brief This file is a test suite to run all unit tests
* \remarks To run this script as CLI: phpunit filename.php
*/
+
print "PHP Version: ".phpversion()."\n";
print "Memory limit: ". ini_get('memory_limit')."\n";
@@ -32,6 +33,10 @@ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$_SERVER['PHP_SELF'] = "phpunit";
}
+if (! defined('NOREQUIREUSER')) {
+ define('PHPUNIT_MODE', 1);
+}
+
global $conf,$user,$langs,$db;
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
//require_once 'PHPUnit/Autoload.php';
diff --git a/test/phpunit/JsonLibTest.php b/test/phpunit/JsonLibTest.php
index e792276fcd3..4f4b5968213 100644
--- a/test/phpunit/JsonLibTest.php
+++ b/test/phpunit/JsonLibTest.php
@@ -24,7 +24,9 @@
* \remarks To run this script as CLI: phpunit filename.php
*/
-define('PHPUNIT_MODE', 1);
+if (! defined('NOREQUIREUSER')) {
+ define('PHPUNIT_MODE', 1);
+}
global $conf,$user,$langs,$db;
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver