From 6267f55cce24cf7e0a6273c4a3340c4a8a382582 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Charl=C3=A8ne=20Benke?=
<1179011+defrance@users.noreply.github.com>
Date: Thu, 16 Apr 2026 19:37:57 +0200
Subject: [PATCH 1/4] Fix some expense report warning (#37903)
* Change file upload check to use isset
warning message when we have already upload the file an attemps to select it
* Add check for num_rows before fetching project data
* Refactor project information selection logic
---
.../class/expensereport.class.php | 25 +++++++++++--------
.../tpl/expensereport_linktofile.tpl.php | 2 +-
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php
index f4fda67037d..eaa3edec23e 100644
--- a/htdocs/expensereport/class/expensereport.class.php
+++ b/htdocs/expensereport/class/expensereport.class.php
@@ -2321,18 +2321,21 @@ class ExpenseReport extends CommonObject
$this->db->free($resql);
}
- // Select des information du projet
- $sql = "SELECT p.ref as ref_projet, p.title as title_projet";
- $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
- $sql .= " WHERE p.rowid = ".((int) $projet_id);
- $resql = $this->db->query($sql);
- if ($resql) {
- $objp_projet = $this->db->fetch_object($resql);
- $this->line->projet_ref = $objp_projet->ref_projet;
- $this->line->projet_title = $objp_projet->title_projet;
- $this->db->free($resql);
+ if ($projet_id > 0) {
+ // Select des information du projet
+ $sql = "SELECT p.ref as ref_projet, p.title as title_projet";
+ $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
+ $sql .= " WHERE p.rowid = ".((int) $projet_id);
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ if ($this->db->num_rows($resql) > 0) {
+ $objp_projet = $this->db->fetch_object($resql);
+ $this->line->projet_ref = $objp_projet->ref_projet;
+ $this->line->projet_title = $objp_projet->title_projet;
+ }
+ $this->db->free($resql);
+ }
}
-
$this->applyOffset();
$this->checkRules();
diff --git a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php
index 134a9f5948c..4783ad3dd06 100644
--- a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php
+++ b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php
@@ -139,7 +139,7 @@ if (!getDolGlobalString('EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES')) {
//var_dump($file['relativename']);
//var_dump($_FILES['userfile']['name']);
// If a file was just uploaded, we check to preselect it
- if (is_array($_FILES['userfile']) && is_array($_FILES['userfile']['name'])) {
+ if (isset($_FILES['userfile']) && is_array($_FILES['userfile']['name'])) {
foreach ($_FILES['userfile']['name'] as $tmpfile) {
if ($file['relativename'] == (GETPOST('savingdocmask', 'alpha') ? dol_sanitizeFileName($object->ref.'-') : '').$tmpfile) {
$checked = ' checked';
From 79d5da0846ebbee63e74d16285ba96406fc845f3 Mon Sep 17 00:00:00 2001
From: atm-corentin <165782689+atm-corentin@users.noreply.github.com>
Date: Thu, 16 Apr 2026 19:38:56 +0200
Subject: [PATCH 2/4] fix: restore supplier proposal hover in linked objects
block (#37905)
---
htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php
index d0fd0e7217a..c106e266212 100644
--- a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php
@@ -58,7 +58,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
} ?>
| ">trans("SupplierProposal")); ?> |
- trans("ShowSupplierProposal"), "supplier_proposal").' '.$objectlink->ref; ?> |
+ getNomUrl(1); ?> |
|
date_creation, 'day'); ?> |
Date: Thu, 16 Apr 2026 21:11:48 +0200
Subject: [PATCH 3/4] QUAL documentation (#37899)
* QUAL documentation
* FIX doc
* Clarify comment about module enabling permissions
* Update modMyModule.class.php
---------
Co-authored-by: Laurent Destailleur
---
.../core/modules/modMyModule.class.php | 23 +++++++++++++++----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
index c5f27da8e80..aab4a4f4edb 100644
--- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
+++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
@@ -70,6 +70,10 @@ class modMyModule extends DolibarrModules
// Used only if file README.md and README-LL.md not found.
$this->descriptionlong = "MyModuleDescription";
+ // Enables the module for all entities (Multicompany)
+ // Can be enabled / disabled only from the main company with superadmin account
+ // $this->core_enabled = 1;
+
// Author
$this->editor_name = 'Editor name';
$this->editor_url = 'https://www.example.com'; // Must be an external online web site
@@ -90,6 +94,18 @@ class modMyModule extends DolibarrModules
$this->picto = 'generic';
// Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
+ // If your module use the parameter "core_enabled" and you would like to activate the parts in all entities (Multicompany):
+ // 'xxxxxx' => array(
+ // 'data' => 1 or '/mymodule/xxx/mymodule.xxx.php',
+ // 'entity' => '0'
+ // ),
+ // 'hooks' => array(
+ // 'data' => array(
+ // 'hookcontext1',
+ // 'hookcontext2',
+ // )
+ // 'entity' => '0'
+ // )
$this->module_parts = array(
// Set this to 1 if module has its own trigger directory (core/triggers)
'triggers' => 0,
@@ -120,11 +136,8 @@ class modMyModule extends DolibarrModules
// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
/* BEGIN MODULEBUILDER HOOKSCONTEXTS */
'hooks' => array(
- // 'data' => array(
- // 'hookcontext1',
- // 'hookcontext2',
- // ),
- // 'entity' => '0',
+ // 'hookcontext1',
+ // 'hookcontext2',
),
/* END MODULEBUILDER HOOKSCONTEXTS */
// Set this to 1 if features of module are opened to external users
From fe2e311101312eb0dd92249a9312cf0a4b057f33 Mon Sep 17 00:00:00 2001
From: John BOTELLA <68917336+thersane-john@users.noreply.github.com>
Date: Thu, 16 Apr 2026 21:12:03 +0200
Subject: [PATCH 4/4] New: Complete context tab isolation for QuickMemo module
(#37901)
* complette context tab isolation
* fix string type
* fix string type
* fix string type
* fix string type
* fix string type
* re-remove useless test
* return int
* php stan
* php stan
* php stan
* php stan
* php stan
---------
Co-authored-by: Laurent Destailleur
---
htdocs/contrat/document.php | 2 +-
htdocs/core/modules/DolibarrModules.class.php | 2 +-
htdocs/core/modules/modQuickMemo.class.php | 20 ++-
.../class/actions_quickmemo.class.php | 2 +-
htdocs/quickmemo/class/memo.class.php | 131 ++++++++++++++++--
5 files changed, 138 insertions(+), 19 deletions(-)
diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php
index cc715d1df00..9aeaec27fbf 100644
--- a/htdocs/contrat/document.php
+++ b/htdocs/contrat/document.php
@@ -92,7 +92,7 @@ $upload_dir = $conf->contrat->multidir_output[$object->entity ?? $conf->entity].
$modulepart = 'contract';
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
-$hookmanager->initHooks(array('contractcard', 'globalcard'));
+$hookmanager->initHooks(array('contractcard', 'contractdocument', 'globalcard'));
$permissiontoadd = $user->hasRight('contrat', 'creer'); // Used by the include of actions_dellink.inc.php
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index 02beab709c3..612352257b0 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -156,7 +156,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
public $menu = array();
/**
- * @var array{triggers?:int<0,1>,login?:int<0,1>,substitutions?:int<0,1>,menus?:int<0,1>,theme?:int<0,1>,tpl?:int<0,1>,barcode?:int<0,1>,models?:int<0,1>,printing?:int<0,1>,css?:string[],js?:string[],hooks?:array{data?:string[],entity?:string},moduleforexternal?:int<0,1>,websitetemplates?:int<0,1>,contactelement?:int<0,1>} Module parts
+ * @var array{triggers?:int<0,1>,login?:int<0,1>,substitutions?:int<0,1>,menus?:int<0,1>,theme?:int<0,1>,tpl?:int<0,1>,barcode?:int<0,1>,models?:int<0,1>,printing?:int<0,1>,css?:string[],js?:string[],hooks?:array{data?:string[],entity?:string}|string[],moduleforexternal?:int<0,1>,websitetemplates?:int<0,1>,contactelement?:int<0,1>} Module parts
* array(
* // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers)
* 'triggers' => 0,
diff --git a/htdocs/core/modules/modQuickMemo.class.php b/htdocs/core/modules/modQuickMemo.class.php
index 86878fa4032..6aebd38cd54 100644
--- a/htdocs/core/modules/modQuickMemo.class.php
+++ b/htdocs/core/modules/modQuickMemo.class.php
@@ -27,6 +27,7 @@
* \brief Description and activation file for module QuickMemo
*/
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
+require_once DOL_DOCUMENT_ROOT.'/quickmemo/class/memo.class.php';
/**
@@ -87,6 +88,20 @@ class modQuickMemo extends DolibarrModules
// To use a supported fa-xxx css style of font awesome, use this->picto='xxx'
$this->picto = 'fa-sticky-note_far_#9bdb07';
+ // Define hooks
+ $contextTabMapping = Memo::getAvailableMemoContextMapping(null, false);
+ $compatibleHooks = [];
+ foreach ($contextTabMapping as $values) {
+ foreach ((array) $values as $value) {
+ $compatibleHooks[] = (string) $value;
+ }
+ }
+ $compatibleHooks = array_unique($compatibleHooks);
+ // Security check
+ $compatibleHooks = array_filter($compatibleHooks, function (string $k) {
+ return preg_match('/^[a-zA-Z0-9_]+$/', $k);
+ });
+
// Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
$this->module_parts = array(
// Set this to 1 if module has its own trigger directory (core/triggers)
@@ -117,10 +132,7 @@ class modQuickMemo extends DolibarrModules
),
// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
- 'hooks' => array(
- 'globalcard',
- 'index'
- ),
+ 'hooks' => $compatibleHooks,
// Set this to 1 if features of module are opened to external users
'moduleforexternal' => 0,
diff --git a/htdocs/quickmemo/class/actions_quickmemo.class.php b/htdocs/quickmemo/class/actions_quickmemo.class.php
index ddb7c28b50f..e1b5a01c949 100644
--- a/htdocs/quickmemo/class/actions_quickmemo.class.php
+++ b/htdocs/quickmemo/class/actions_quickmemo.class.php
@@ -136,7 +136,7 @@ class ActionsQuickMemo extends CommonHookActions
'archivesUrlParams' => '&search_fk_element='. (int) $object->id .'&search_element_type='.$object->element,
'elementId' => (int) $object->id,
'elementType' => $object->element,
- 'context' => Memo::getMemoContext($parameters['context']??''),
+ 'context' => Memo::getMemoContext($parameters['context']??'', $object),
];
Memo::loadQuickMemoJsInterface($jsConfVars);
diff --git a/htdocs/quickmemo/class/memo.class.php b/htdocs/quickmemo/class/memo.class.php
index 8ea92d08041..356d6ff197a 100644
--- a/htdocs/quickmemo/class/memo.class.php
+++ b/htdocs/quickmemo/class/memo.class.php
@@ -1279,23 +1279,33 @@ class Memo extends CommonObject
* Get memo context
*
* @param string|array $context Context
+ * @param CommonObject|null $object the common Dolibarr object
+ *
* @return mixed|string
*/
- public static function getMemoContext($context)
+ public static function getMemoContext($context, $object = null)
{
global $db,$action, $hookmanager;
+ if (!isModEnabled('quickmemo')) {
+ return '';
+ }
+
if (!is_array($context)) {
$context = explode(':', $context);
}
- $memoContext = '';
- if (in_array('index', $context)) {
- $memoContext = 'index';
- } elseif (in_array('globalcard', $context)) {
- $memoContext = 'card';
- }
+ $contextMapping = self::getAvailableMemoContextMapping();
+ $memoContext = '';
+ foreach ($contextMapping as $key => $values) {
+ $values = (array) $values;
+
+ if (array_intersect($context, $values)) {
+ $memoContext = $key;
+ break;
+ }
+ }
$staticMemo = new self($db);
@@ -1303,7 +1313,7 @@ class Memo extends CommonObject
$parameters = array(
'memoContext' =>& $memoContext
);
- $object = null;
+
$reshook = $hookmanager->executeHooks('getMemoContext', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
return $hookmanager->resPrint;
@@ -1315,13 +1325,97 @@ class Memo extends CommonObject
/**
* Get available memo context
*
- * @return mixed|mixed[]|string[]
+ * @param null $object the common Dolibarr object
+ * @param bool $onlyActiveModules on true return only
+ *
+ * @return array|string[]
+ */
+ public static function getAvailableMemoContextMapping($object = null, $onlyActiveModules = true)
+ {
+ global $db,$action, $hookmanager;
+
+ $contextTabMapping = [];
+
+ $commonCardContext = ['document', 'agenda', 'contactcard', 'stats'];
+ foreach ($commonCardContext as $context) {
+ // init common contexts
+ $contextTabMapping[$context] = [];
+ }
+
+ // Start Correction of no standard Dolibarr context and special context
+ if (isModEnabled('propal') || !$onlyActiveModules) {
+ $contextTabMapping['contactcard'][] = 'proposalcontactcard';
+ }
+
+ if (isModEnabled('supplier_order') || !$onlyActiveModules) {
+ $contextTabMapping['contactcard'][] = 'ordersuppliercontactcard';
+ $contextTabMapping['document'][] = 'ordersuppliercarddocument';
+ $contextTabMapping['agenda'][] = 'ordersuppliercardinfo';
+ $contextTabMapping['ordersupplierdispatch'][] = 'ordersupplierdispatch';
+ }
+
+ if (isModEnabled('contract') || !$onlyActiveModules) {
+ $contextTabMapping['agenda'][] = 'agendacontract';
+ }
+
+ if (isModEnabled('order') || !$onlyActiveModules) {
+ $contextTabMapping['ordershipmentcard'][] = 'ordershipmentcard';
+ }
+
+ // End of corrections
+
+ // Generate standard context
+ foreach (['order', 'propal', 'invoice', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'contract'] as $module) {
+ if (!isModEnabled($module) && $onlyActiveModules) {
+ continue;
+ }
+
+ $moduleClean = str_replace('_', '', $module);
+
+ foreach ($commonCardContext as $context) {
+ $contextTabMapping[$context][] = $moduleClean.$context;
+ }
+ }
+
+ if (!empty($object) && !empty($object->element)) {
+ foreach ($commonCardContext as $context) {
+ $contextTabMapping[$context][] = $object->element.$context;
+ }
+ }
+
+ $contextTabMapping = array_replace_recursive($contextTabMapping, [
+ // Need to by at end of tests
+ 'index' => 'index',
+ 'card' => 'globalcard'
+ ]);
+
+ $staticMemo = new self($db);
+ $hookmanager->initHooks(array($staticMemo->element.'dao'));
+ $parameters = array(
+ 'contextTabMapping' =>& $contextTabMapping,
+ 'onlyActiveModules' => $onlyActiveModules
+ );
+
+ $reshook = $hookmanager->executeHooks('getAvailableMemoContextMapping', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) {
+ return $hookmanager->resArray;
+ }
+
+ return $contextTabMapping;
+ }
+
+
+ /**
+ * Get available memo context
+ *
+ * @return string[]
*/
public static function getAvailableMemoContext()
{
global $db,$action, $hookmanager;
- $list = ['card', 'index'];
+ $contextMapping = self::getAvailableMemoContextMapping();
+ $list = array_keys($contextMapping);
$staticMemo = new self($db);
$hookmanager->initHooks(array($staticMemo->element.'dao'));
@@ -1331,10 +1425,19 @@ class Memo extends CommonObject
$object = null;
$reshook = $hookmanager->executeHooks('getAvailableMemoContext', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) {
- return $hookmanager->resArray;
+ $list = $hookmanager->resArray;
}
- return $list;
+ // Security check
+ $result = [];
+ foreach ($list as $k => $v) {
+ if (!is_string($v)) { continue; }
+ if (strlen($v) > 64) { continue; }
+ if (preg_match('/^[a-zA-Z0-9_]+$/', $k) !== 1) { continue; }
+ $result[] = $v;
+ }
+
+ return $result;
}
@@ -1486,6 +1589,10 @@ class Memo extends CommonObject
{
global $user;
+ if (!isModEnabled('quickmemo')) {
+ return false;
+ }
+
// DO NOT LOAD TWICE
if (defined('QUICKMEMOJS')) {
return false;
|