Compare commits

...

5 Commits
23.0.1 ... 23.0

Author SHA1 Message Date
Laurent Destailleur
992731c8ca FIX extrafield on pdf must not appears on doc if option off 2026-03-13 12:56:25 +01:00
Laurent Destailleur
138c1bf5b3 Fix CI 2026-03-13 11:50:21 +01:00
Laurent Destailleur
99bc406c49 Fix restore compatibility with filter on category 2026-03-13 11:08:43 +01:00
Laurent Destailleur
934123eef5 FIX restore use of user->id in dynamics conditions 2026-03-13 09:48:18 +01:00
Laurent Destailleur
c531628ae3 Fix spellcheck 2026-03-13 08:55:00 +01:00
4 changed files with 42 additions and 10 deletions

View File

@@ -1741,7 +1741,7 @@ abstract class CommonDocGenerator
/**
* display extrafields columns content
* Display extrafields columns content on documents
*
* @param CommonObject|CommonObjectLine $object line of common object
* @param Translate $outputlangs Output language
@@ -1819,6 +1819,10 @@ abstract class CommonDocGenerator
}
}
if (empty($extrafields->attributes[$object->table_element]['printable'][$key])) {
continue;
}
if (empty($enabled)) {
continue;
}

View File

@@ -1752,15 +1752,22 @@ class ExtraFields
$tmpparamoptions = array_keys($param['options']);
$paramoptions = preg_split('/[\r\n]+/', $tmpparamoptions[0]);
$InfoFieldList = explode(":", $paramoptions[0], 5);
$InfoFieldList = explode(":", $paramoptions[0], 5); // We will extract field at position 6,7... later from the 5th one.
// 0 : tableName
// 1 : label field name
// 2 : key fields name (if different of rowid)
// optional parameters...
// 2 : rowid field name (if different of rowid)
// Optional parameters...
// 3 : key field parent (for dependent lists). How this is used ?
// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value. Or use USF on the second line.
// 5 : string category type. This replace the filter.
// 6 : ids categories list separated by comma for category root. This replace the filter.
// To add a filter on category (not possible with USF restricted to table)
// 5 : string category type ('product', 'customer', ...). This is added to the filter.
// 6 : list of parent categories ids. This replace the filter.
// 7 : sort field (not used here but used into format for commobject)
// For backward compatibility when tableName = 'category', so when we want a list of categories
// 5 : string category type ('product', 'customer', ...). This replace the filter.
// 6 : list of parent categories ids. This replace the filter.
// 7 : sort field (not used here but used into format for commobject)
// Example with extrafield value = "societe:nom:rowid" or "categorie:label:rowid:::product"
@@ -1797,6 +1804,7 @@ class ExtraFields
//$Usf = empty($paramoptions[1]) ? '' :$paramoptions[1];
$parentName = '';
$parentField = '';
$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid');
@@ -1813,13 +1821,18 @@ class ExtraFields
}
}
$InfoFieldList[5] = (string) $InfoFieldList[5];
$filter_categorie = false;
if (count($InfoFieldList) > 5 && ((string) $InfoFieldList[5] != '')) {
if (count($InfoFieldList) > 5 && ($InfoFieldList[5] != '')) {
if ($InfoFieldList[0] == 'categorie') {
$filter_categorie = true;
$filter_categorie = true; // The combo list is a list of categories
} else {
$filter_categorie = false; // We have a filter on category for another table
}
}
if (!$filter_categorie) {
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label)) {
@@ -1871,6 +1884,20 @@ class ExtraFields
$sqlwhere .= ' WHERE 1=1';
}
if ($InfoFieldList[5] != '') {
// We have a filter on category for another table
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$tmpcategory = new Categorie($this->db);
$tablesuffixcategory = empty($tmpcategory->MAP_CAT_TABLE[$InfoFieldList[5]]) ? $InfoFieldList[5] : $tmpcategory->MAP_CAT_TABLE[$InfoFieldList[5]];
$fksuffixcategory = empty($tmpcategory->MAP_CAT_FK[$InfoFieldList[5]]) ? $InfoFieldList[5] : $tmpcategory->MAP_CAT_FK[$InfoFieldList[5]];
$sqlwhere .= ' AND EXISTS (SELECT fk_categorie as categid FROM '.MAIN_DB_PREFIX.'categorie_'.$this->db->sanitize($tablesuffixcategory);
$sqlwhere .= ' WHERE fk_categorie IN ('.$this->db->sanitize($InfoFieldList[6]).')';
$sqlwhere .= ' AND fk_'.$this->db->sanitize($fksuffixcategory).' = rowid)';
//var_dump($sqlwhere);exit;
}
// Add Usf filter on second line
/*
if ($Usf) {

View File

@@ -318,7 +318,7 @@ class Form
}
if (preg_match('/^(string|safehtmlstring|email|phone|url)/', $typeofdata)) {
$tmp = explode(':', $typeofdata);
$ret .= '<input type="text" id="' . $htmlname . '" name="' . $htmlname . '" value="' . ($editvalue ? $editvalue : $value) . '"' . (empty($tmp[1]) ? '' : ' size="' . $tmp[1] . '"') . ' autofocus>';
$ret .= '<input type="text" id="' . $htmlname . '" name="' . $htmlname . '" value="' . ($editvalue ? $editvalue : $value) . '"' . (empty($tmp[1]) ? '' : ' size="' . $tmp[1] . '"') . ' autofocus spellcheck="false">';
} elseif (preg_match('/^(integer)/', $typeofdata)) {
$tmp = explode(':', $typeofdata);
$valuetoshow = price2num($editvalue ? $editvalue : $value, 0);

View File

@@ -11727,7 +11727,7 @@ function verifCond($strToEvaluate, $onlysimplestring = '1')
//var_dump($strToEvaluate);
//$rep = dol_eval($strToEvaluate, 1, 0, '1'); // to show the error
$rep = dol_eval($strToEvaluate, 1, 1, $onlysimplestring); // The dol_eval() must contains all the "global $xxx;" for all variables $xxx found into the string condition
//var_dump($rep);
//var_dump($strToEvaluate, $rep);
$rights = (bool) $rep && (!is_string($rep) || strpos($rep, 'Bad string syntax to evaluate') === false);
//var_dump($rights);
}
@@ -12172,6 +12172,7 @@ function dol_eval_standard($s, $hideerrors = 1, $onlysimplestring = '1')
while ($scheck && $savescheck != $scheck) {
$savescheck = $scheck;
$scheck = preg_replace('/\$conf->[a-z\_]+->enabled/', '__VARCONFENABLED__', $scheck); // Remove this once $user->module->enabled has been replaced everywhere with isModEnabled.
$scheck = preg_replace('/\$user->id/', '__VARUSERID__', $scheck);
$scheck = preg_replace('/\$user->hasRight/', '__VARUSERHASRIGHT__', $scheck);
$scheck = preg_replace('/\$user->rights/', '__VARUSERHASRIGHT__', $scheck); // Remove this once $user->rights->xxx is replaced everywhere with $user->hasRight()
$scheck = preg_replace('/\$user->admin/', '__VARUSERISADMIN__', $scheck); // Remove this once $user->admin is replaced everywhere with $user->isAdmin()