Skip to content

Commit

Permalink
Merge branch 'develop' into FIX/32460/HandleLines
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy authored Jan 15, 2025
2 parents 4aad020 + 55b96e0 commit 8856e3c
Show file tree
Hide file tree
Showing 46 changed files with 287 additions and 161 deletions.
49 changes: 28 additions & 21 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,15 @@ jobs:
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

# Run all the precommit tools (defined in pre-commit-config.yaml).
# We can force exclusion of some of them here.
- name: Run pre-commit hooks
env:
# SKIP is used by pre-commit to not execute certain hooks
SKIP: no-commit-to-branch,php-cs,php-cbf,trailing-whitespace,end-of-file-fixer
- name: Extract PHP version
id: extract-php-version
run: |

Check failure on line 64 in .github/workflows/pre-commit.yml

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

shellcheck reported issue in this script: SC2016:info:1:22: Expressions don't expand in single quotes, use double quotes for that [shellcheck]

Check failure on line 64 in .github/workflows/pre-commit.yml

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

shellcheck reported issue in this script: SC2086:info:2:36: Double quote to prevent globbing and word splitting [shellcheck]
set -o pipefail
pre-commit gc
pre-commit run --show-diff-on-failure --color=always --all-files | tee "${RAW_LOG}"
# The next uses git, which is slow for a bit repo.
# - name: Get all changed php files (if PR)
# id: changed-php
# uses: tj-actions/changed-files@v45
# if: env.gh_event == 'pull_request'
# with:
# files: |
# **.php
PHP_VERSION=$(sed -n 's/.*\$arrayphpmaxversionwarning\s*=\s*array\s*(\s*\([0-9]\+\)\s*,\s*\([0-9]\+\).*/\1.\2/p' htdocs/install/check.php)
echo "PHP_VERSION=$PHP_VERSION" >> $GITHUB_ENV
- name: Setup PHPCS
uses: shivammathur/setup-php@v2
# Install when we're going to run phpcs
# Install proper php version, and also install phpcs which may be needed
if: |
! cancelled() &&
(
Expand All @@ -89,16 +76,36 @@ jobs:
(
env.gh_event == 'push'
&& (
github.event.ref == 'refs/heads/develop'
|| endsWith(github.event.ref, '.0')
github.event.ref == 'refs/heads/develop'
|| endsWith(github.event.ref, '.0')
)
)
)
with:
php-version: 8.1
php-version: ${{ env.PHP_VERSION }} # Version from check.php
coverage: none # disable xdebug, pcov
tools: phpcs

# Run all the precommit tools (defined into pre-commit-config.yaml).
# We can force exclusion of some of them here.
- name: Run pre-commit hooks
env:
# SKIP is used by pre-commit to not execute certain hooks
SKIP: no-commit-to-branch,php-cs,php-cbf,trailing-whitespace,end-of-file-fixer
run: |
set -o pipefail
pre-commit gc
pre-commit run --show-diff-on-failure --color=always --all-files | tee "${RAW_LOG}"
# The next uses git, which is slow for a bit repo.
# - name: Get all changed php files (if PR)
# id: changed-php
# uses: tj-actions/changed-files@v45
# if: env.gh_event == 'pull_request'
# with:
# files: |
# **.php

- name: Run some pre-commit hooks on selected changed files only
if: "! cancelled() && steps.changed-php.outputs.any_changed == 'true'"
env:
Expand Down
21 changes: 21 additions & 0 deletions htdocs/adherents/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,27 @@
}
}

if ($action == 'update_extras' && $user->hasRight('adherent', 'creer')) {
$object->oldcopy = dol_clone($object, 2);
$attribute_name = GETPOST('attribute', 'restricthtml');

// Fill array 'array_options' with data from update form
$ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
if ($ret < 0) {
$error++;
}
if (!$error) {
$result = $object->updateExtraField($attribute_name, 'MEMBER_MODIFY');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
if ($error) {
$action = 'edit_extras';
}
}

// SPIP Management
if (is_object($mailmanspip)) {
if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_del_spip' && $confirm == 'yes') {
Expand Down
7 changes: 6 additions & 1 deletion htdocs/admin/ihm.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,12 @@
if ($mode == 'css') {
//file_put_contents(DOL_DATA_ROOT.'/admin/customcss.css', $data);
//dol_chmod(DOL_DATA_ROOT.'/admin/customcss.css');
dolibarr_set_const($db, "MAIN_IHM_CUSTOM_CSS", GETPOST('MAIN_IHM_CUSTOM_CSS', 'restricthtml'), 'chaine', 0, '', $conf->entity);
$csscontent = GETPOST('MAIN_IHM_CUSTOM_CSS', 'restricthtml');
$csscontent = dol_string_nohtmltag($csscontent, 2);

dolibarr_set_const($db, "MAIN_IHM_CUSTOM_CSS", $csscontent, 'chaine', 0, '', $conf->entity);

setEventMessages($langs->trans("RecordSaved"), null);
}

$_SESSION["mainmenu"] = ""; // The menu manager may have changed
Expand Down
4 changes: 2 additions & 2 deletions htdocs/commande/class/commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class Commande extends CommonOrder
'fk_mode_reglement' => array('type' => 'integer', 'label' => 'PaymentMode', 'enabled' => 1, 'visible' => -1, 'position' => 185),
'date_livraison' => array('type' => 'date', 'label' => 'DateDeliveryPlanned', 'enabled' => 1, 'visible' => -1, 'position' => 190, 'csslist' => 'nowraponall'),
'fk_shipping_method' => array('type' => 'integer', 'label' => 'ShippingMethod', 'enabled' => 1, 'visible' => -1, 'position' => 195),
'fk_warehouse' => array('type' => 'integer:Entrepot:product/stock/class/entrepot.class.php', 'label' => 'Fk warehouse', 'enabled' => 'isModEnabled("stock")', 'visible' => -1, 'position' => 200),
'fk_warehouse' => array('type' => 'integer:Entrepot:product/stock/class/entrepot.class.php', 'label' => 'DefaultWarehouse', 'enabled' => 'isModEnabled("stock")', 'visible' => -1, 'position' => 200, 'nodepth' => 1),
'fk_availability' => array('type' => 'integer', 'label' => 'Availability', 'enabled' => 1, 'visible' => -1, 'position' => 205),
'fk_input_reason' => array('type' => 'integer', 'label' => 'InputReason', 'enabled' => 1, 'visible' => -1, 'position' => 210),
//'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>-1, 'position'=>215),
Expand Down Expand Up @@ -857,7 +857,7 @@ public function cloture($user, $notrigger = 0)
*/
public function cancel($idwarehouse = -1)
{
global $conf, $user, $langs;
global $user, $langs;

$error = 0;

Expand Down
6 changes: 3 additions & 3 deletions htdocs/compta/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@
}
// Ref
if (!empty($arrayfields['f.ref']['checked'])) {
print '<td class="liste_titre" align="left">';
print '<td class="liste_titre">';
print '<input class="flat maxwidth50imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
Expand All @@ -1439,7 +1439,7 @@
}
//$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order.
// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth75');
print '</td>';
}
// Invoice Subtype
Expand Down Expand Up @@ -2505,7 +2505,7 @@

// Author
if (!empty($arrayfields['u.login']['checked'])) {
print '<td class="tdoverflowmax200">';
print '<td class="tdoverflowmax125">';
if ($userstatic->id) {
print $userstatic->getNomUrl(-1);
} else {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="2">'.$langs->trans("BoxTitleLastModifiedDonations", $max);
print '<a href="'.DOL_URL_ROOT.'/don/list.php?sortfield=f.tms&sortorder=desc"><span class="badge marginleftonly">...</span></a>';
print '<a href="'.DOL_URL_ROOT.'/don/list.php?sortfield=d.tms&sortorder=desc"><span class="badge marginleftonly">...</span></a>';
print '</th>';
print '<th class="right">'.$langs->trans("AmountTTC").'</th>';
print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/contact/class/contact.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ class Contact extends CommonObject
'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 3, 'position' => 200, 'searchall' => 1),
'default_lang' => array('type' => 'varchar(6)', 'label' => 'Default lang', 'enabled' => 1, 'visible' => 3, 'position' => 205),
'canvas' => array('type' => 'varchar(32)', 'label' => 'Canvas', 'enabled' => 1, 'visible' => 3, 'position' => 210),
'ip' => array('type' => 'ip', 'label' => 'IPAddress', 'enabled' => '1', 'position' => 700, 'notnull' => 0, 'visible' => '-2', 'comment' => 'ip used to create record (for public submission page)'),
'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -1, 'position' => 300),
'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 305),
'fk_user_creat' => array('type' => 'integer', 'label' => 'UserAuthor', 'enabled' => 1, 'visible' => 3, 'position' => 310),
'fk_user_modif' => array('type' => 'integer', 'label' => 'UserModif', 'enabled' => 1, 'visible' => 3, 'position' => 315),
'statut' => array('type' => 'tinyint(4)', 'label' => 'Status', 'enabled' => 1, 'visible' => 1, 'notnull' => 1, 'position' => 500),
'ip' => array('type' => 'varchar(250)', 'label' => 'Ip', 'enabled' => '1', 'position' => 700, 'notnull' => 0, 'visible' => '0', 'comment' => 'ip used to create record (for public submission page)'),
'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -1, 'position' => 1000),
);

Expand Down
24 changes: 23 additions & 1 deletion htdocs/contact/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,";
$sql .= " p.rowid, p.ref_ext, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email, p.birthday,";
$sql .= " p.socialnetworks, p.photo,";
$sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_modification,";
$sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.ip, p.datec as date_creation, p.tms as date_modification,";
$sql .= " p.import_key, p.fk_stcommcontact as stcomm_id, p.fk_prospectlevel,";
$sql .= " st.libelle as stcomm, st.picto as stcomm_picto,";
$sql .= " co.label as country, co.code as country_code";
Expand Down Expand Up @@ -1240,6 +1240,11 @@
$parameters = array('arrayfields' => $arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// IP
if (!empty($arrayfields['p.ip']['checked'])) {
print '<td class="liste_titre">';
print '</td>';
}
// Date creation
if (!empty($arrayfields['p.datec']['checked'])) {
print '<td class="liste_titre">';
Expand Down Expand Up @@ -1385,6 +1390,12 @@
$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// IP
if (!empty($arrayfields['p.ip']['checked'])) {
print_liste_field_titre($arrayfields['p.ip']['label'], $_SERVER["PHP_SELF"], "p.ip", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
$totalarray['nbfield']++;
}
// Date creation
if (!empty($arrayfields['p.datec']['checked'])) {
print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
$totalarray['nbfield']++;
Expand Down Expand Up @@ -1754,6 +1765,17 @@
$parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;

// IP creation
if (!empty($arrayfields['p.ip']['checked'])) {
print '<td class="center nowraponall">';
print dol_print_ip($obj->ip);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}

// Date creation
if (!empty($arrayfields['p.datec']['checked'])) {
print '<td class="center nowraponall">';
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/boxes/box_graph_product_distribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public function loadBox($max = 5)
if (empty($data3)) {
$showpointvalue = 0;
$nocolor = 1;

$data3 = array(array(0 => $langs->trans("None"), 1 => 1));
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/doleditor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class DolEditor
* @param string $toolbarname Name of the toolbar set to use ('dolibarr_details[_encoded]'=the less featured, 'dolibarr_notes[_encoded]' for notes content, 'dolibarr_mailings[_encoded]' for emailing content, 'dolibarr_readonly').
* @param string $toolbarlocation Deprecated. Not used
* @param bool $toolbarstartexpanded Bar is visible or not at start
* @param bool|int $uselocalbrowser Enabled to add links to local object with a local media filemanager. If false, only external images URL can be added into content, or images saved inline with src="data:..." with a cut/paste.
* @param bool|int $uselocalbrowser Enabled to add links to local object with a local media filemanager. -1=auto, false=only external images URL can be added into content, or images saved inline with src="data:..." with a cut/paste.
* @param bool|int|string $okforextendededitor 1 or True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace.
* Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave".
* @param int $rows Size of rows for textarea tool
Expand Down
26 changes: 23 additions & 3 deletions htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6906,12 +6906,31 @@ public function load_cache_vatrates($country_code)
public function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = null, $societe_acheteuse = null, $idprod = 0, $info_bits = 0, $type = '', $options_only = false, $mode = 0, $type_vat = 0)
{
// phpcs:enable
global $langs, $mysoc;
global $langs, $mysoc, $hookmanager;

$langs->load('errors');

$return = '';

// Bypass the default method
$hookmanager->initHooks(array('commonobject'));
$info_bits == 1 ? $is_npr = 1 : $is_npr = 0;
$parameters = array(
'seller' => $societe_vendeuse,
'buyer' => $societe_acheteuse,
'idprod' => $idprod,
'is_npr' => $is_npr,
'type' => $type,
'options_only' => $options_only,
'mode' => $mode,
'type_vat' => $type_vat
);
$reshook = $hookmanager->executeHooks('load_tva', $parameters);
if ($reshook > 0) {
return $hookmanager->resPrint;
} elseif ($reshook === 0) {
$return .= $hookmanager->resPrint;
}

// Define defaultnpr, defaultttx and defaultcode
$defaultnpr = ($info_bits & 0x01);
$defaultnpr = (preg_match('/\*/', $selectedrate) ? 1 : $defaultnpr);
Expand Down Expand Up @@ -9374,7 +9393,8 @@ public static function multiselectarray($htmlname, $array, $selected = array(),
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
// Specify format function for selected item
formatSelection: formatSelection,
templateSelection: formatSelection /* For 4.0 */
templateSelection: formatSelection, /* For 4.0 */
language: select2arrayoflanguage
});

/* Add also morecss to the css .select2 that is after the #htmlname, for component that are show dynamically after load, because select2 set
Expand Down
4 changes: 4 additions & 0 deletions htdocs/core/class/translate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 =
}
}

$str = str_replace('%)', '__percent_parenthesis__', $str);

if (strpos($key, 'Format') !== 0) {
try {
// @phan-suppress-next-line PhanPluginPrintfVariableFormatString
Expand All @@ -691,6 +693,8 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 =
}
}

$str = str_replace('__percent_parenthesis__', '%)', $str);

// We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities because
// we want to keep '"' '<b>' '</b>' '<u>' '</u>' '<i>' '</i>' '<center> '</center>' '<strong' '</strong>' '<a ' '</a>' '<br>' '<span' '</span>' '< ' that are reliable HTML tags inside translation strings.
$str = str_replace(
Expand Down
11 changes: 6 additions & 5 deletions htdocs/core/customreports.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* include DOL_DOCUMENT_ROOT.'/core/customreports.php';
*/

/**
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
Expand Down Expand Up @@ -322,6 +322,7 @@
$MI = substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1);
$SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);

$arrayoffilterfields = array();
$arrayofmesures = array();
$arrayofxaxis = array();
$arrayofgroupby = array();
Expand Down Expand Up @@ -375,6 +376,10 @@
}
}

$count = 0;
$arrayoffilterfields = fillArrayOfFilterFields($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayoffilterfields, 0, $count);
$arrayoffilterfields = dol_sort_array($arrayoffilterfields, 'position', 'asc', 0, 0, 1);

$count = 0;
$arrayofmesures = fillArrayOfMeasures($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofmesures, 0, $count);
$arrayofmesures = dol_sort_array($arrayofmesures, 'position', 'asc', 0, 0, 1);
Expand All @@ -387,10 +392,6 @@
$arrayofgroupby = fillArrayOfGroupBy($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofgroupby, 0, $count);
$arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1);

$count = 0;
$arrayoffilterfields = fillArrayOfFilterFields($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayoffilterfields, 0, $count);
$arrayoffilterfields = dol_sort_array($arrayoffilterfields, 'position', 'asc', 0, 0, 1);


// Check parameters
if ($action == 'viewgraph') {
Expand Down
4 changes: 3 additions & 1 deletion htdocs/core/lib/company.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2366,11 +2366,13 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
$out .= dol_trunc($libelle, 120);
}
if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
$out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' ';
$transcode = $langs->trans("Action".$histo[$key]['acode']);
$libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing');
$out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'"';
$out .= ' title="'.dol_escape_htmltag($libelle).'">';
$out .= img_object($langs->trans("ShowEMailing"), "email").' ';
$out .= dol_trunc($libelle, 120);
$out .= '</a>';
}
$out .= '</td>';

Expand Down
10 changes: 8 additions & 2 deletions htdocs/core/lib/customreports.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,12 @@ function fillArrayOfFilterFields($object, $tablealias, $labelofobject, &$arrayof
{
global $langs, $extrafields, $db;

$MAXLEVEL = 2;

if (empty($object)) { // Protection against bad use of method
return array();
}
if ($level >= 3) { // Limit scan on 2 levels max
if ($level > $MAXLEVEL) { // Limit scan on 2 levels max
return $arrayoffields;
}

Expand Down Expand Up @@ -612,7 +614,11 @@ function fillArrayOfFilterFields($object, $tablealias, $labelofobject, &$arrayof
if (class_exists($newobject)) {
$tmpobject = new $newobject($db);
$count++;
$arrayoffields = fillArrayOfFilterFields($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayoffields, $level + 1, $count, $tablepath);
if (!empty($val['nodepth'])) {
$arrayoffields = fillArrayOfFilterFields($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayoffields, $MAXLEVEL, $count, $tablepath);
} else {
$arrayoffields = fillArrayOfFilterFields($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayoffields, $level + 1, $count, $tablepath);
}
} else {
print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
}
Expand Down
Loading

0 comments on commit 8856e3c

Please sign in to comment.