From 1ff0e8a8212538849bb536d6937a71c73fa62fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 8 Jun 2024 16:59:40 +0200 Subject: [PATCH] fix an old error (#29850) * fix an old error * fix OdfException is never thrown in the try block * fix OdfException is never thrown in the try block * fix Undefined array key "name" * fix missing translation * fix missing translation * fix Undefined variable $lineid * fix warnings * fix upload dir * fix phpcs --- dev/translation/ignore_translation_keys.lst | 1 - .../doc/doc_generic_product_odt.modules.php | 4 +-- .../doc/doc_generic_project_odt.modules.php | 29 +++++-------------- .../task/doc/doc_generic_task_odt.modules.php | 18 ++++++------ htdocs/product/admin/product_tools.php | 5 ++-- htdocs/projet/card.php | 2 +- htdocs/projet/contact.php | 3 +- htdocs/projet/element.php | 5 ++-- htdocs/projet/tasks/comment.php | 3 +- htdocs/workstation/workstation_agenda.php | 3 +- htdocs/workstation/workstation_card.php | 8 +++-- htdocs/workstation/workstation_document.php | 5 ++-- htdocs/workstation/workstation_note.php | 3 +- 13 files changed, 41 insertions(+), 48 deletions(-) diff --git a/dev/translation/ignore_translation_keys.lst b/dev/translation/ignore_translation_keys.lst index 85080e64f14..5f5fd5279ee 100644 --- a/dev/translation/ignore_translation_keys.lst +++ b/dev/translation/ignore_translation_keys.lst @@ -931,7 +931,6 @@ WebServiceKey WebServiceURL Website WebsiteMustBeSameThanClonedPageIfTranslation -Weighted WelcomeOnOnlineSignaturePage WidgetDisabledAsModuleDisabled Widgets diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 3a829f825e0..85450edf7f0 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -1,7 +1,7 @@ * Copyright (C) 2012 Juanjo Menent - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * * 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 @@ -412,8 +412,6 @@ class doc_generic_product_odt extends ModelePDFProduct foreach ($array_lines as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 79b7945c13e..2111ebe5aca 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -3,7 +3,7 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2016-2023 Charlene Benke - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023 Gauthier VERDOL * Copyright (C) 2024 MDW * @@ -596,8 +596,8 @@ class doc_generic_project_odt extends ModelePDFProjects // Make substitution $substitutionarray = array( - '__FROM_NAME__' => $this->emetteur->name, - '__FROM_EMAIL__' => $this->emetteur->email, + '__FROM_NAME__' => $this->emetteur->name, + '__FROM_EMAIL__' => $this->emetteur->email, ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook @@ -610,10 +610,10 @@ class doc_generic_project_odt extends ModelePDFProjects $odfHandler = new Odf( $srctemplatepath, array( - 'PATH_TO_TMP' => $conf->project->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. - 'DELIMITER_LEFT' => '{', - 'DELIMITER_RIGHT' => '}' + 'PATH_TO_TMP' => $conf->project->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' ) ); } catch (Exception $e) { @@ -624,9 +624,6 @@ class doc_generic_project_odt extends ModelePDFProjects // After construction $odfHandler->contentXml contains content and // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by // [!-- BEGIN lines --]*[!-- END lines --] - //print html_entity_decode($odfHandler->__toString()); - //print exit; - // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); @@ -772,8 +769,6 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($tmparray as $key => $val) { try { $listlinestasktime->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -805,8 +800,6 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($tmparray as $key => $val) { try { $listlinestasktime->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -831,8 +824,6 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($tmparray as $key => $val) { try { $listtasksfiles->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -866,8 +857,6 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -913,8 +902,6 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -1105,8 +1092,6 @@ class doc_generic_project_odt extends ModelePDFProjects foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 7d412e6c140..b330aaac9b2 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -3,7 +3,7 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023 Gauthier VERDOL * Copyright (C) 2024 MDW * @@ -318,14 +318,14 @@ class doc_generic_task_odt extends ModelePDFTask global $conf; return array( - 'tasktime_rowid' => $tasktime['rowid'], - 'tasktime_task_date' => dol_print_date($tasktime['task_date'], 'day'), - 'tasktime_task_duration' => convertSecondToTime($tasktime['task_duration'], 'all'), - 'tasktime_note' => $tasktime['note'], - 'tasktime_fk_user' => $tasktime['fk_user'], - 'tasktime_user_name' => $tasktime['name'], - 'tasktime_user_first' => $tasktime['firstname'], - 'tasktime_fullcivname' => $tasktime['fullcivname'] + 'tasktime_rowid' => $tasktime['rowid'], + 'tasktime_task_date' => dol_print_date($tasktime['task_date'], 'day'), + 'tasktime_task_duration' => convertSecondToTime($tasktime['task_duration'], 'all'), + 'tasktime_note' => $tasktime['note'], + 'tasktime_fk_user' => $tasktime['fk_user'], + 'tasktime_user_name' => $tasktime['lastname'], + 'tasktime_user_first' => $tasktime['firstname'], + 'tasktime_fullcivname' => $tasktime['fullcivname'] ); } diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 02632bd4bf4..a87f009dde1 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -1,6 +1,7 @@ * Copyright (C) 2013-2015 Laurent Destailleur + * Copyright (C) 2024 Frédéric France * * 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 @@ -198,10 +199,10 @@ if ($action == 'convert') { if ($vat_src_code_old) { $sql .= " AND default_vat_code = '".$db->escape($vat_src_code_old)."'"; } else { - " AND default_vat_code = IS NULL"; + $sql .= " AND default_vat_code = IS NULL"; } $sql .= " AND s.fk_pays = ".((int) $country_id); - //print $sql; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 418c3e5ca69..15fa1fe4001 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1401,7 +1401,7 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { if (strcmp($object->opp_amount, '')) { print ''.price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).''; if (strcmp($object->opp_percent, '')) { - print '       '.$langs->trans("Weighted").': '.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).''; + print '       '.$langs->trans("OpportunityWeightedAmountShort").': '.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).''; } } print ''; diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index e8edd52584b..db8b06f371c 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010 Regis Houssin * Copyright (C) 2012-2015 Laurent Destailleur * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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 @@ -441,7 +442,7 @@ if ($id > 0 || !empty($ref)) { if (strcmp($object->opp_amount, '')) { print ''.price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).''; if (strcmp($object->opp_percent, '')) { - print '       '.$langs->trans("Weighted").': '.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).''; + print '       '.$langs->trans("OpportunityWeightedAmountShort").': '.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).''; } } print ''; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 2ef4256a946..32150cd4d3d 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -8,8 +8,9 @@ * Copyright (C) 2016 Josep Lluís Amador * Copyright (C) 2021-2023 Gauthier VERDOL * Copyright (C) 2021 Noé Cendrier - * Copyright (C) 2023 Frédéric France wfrederic.france@netlogic.fr> + * Copyright (C) 2023 Frédéric France wfrederic.france@free.fr> * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * 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 * the Free Software Foundation; either version 3 of the License, or @@ -316,7 +317,7 @@ if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { if (!is_null($object->opp_amount) && strcmp($object->opp_amount, '')) { print ''.price($object->opp_amount, 0, $langs, 1, 0, 0, $conf->currency).''; if (strcmp($object->opp_percent, '')) { - print '       '.$langs->trans("Weighted").': '.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).''; + print '       '.$langs->trans("OpportunityWeightedAmountShort").': '.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).''; } } print ''; diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index 4656f02dbed..10750562add 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006-2017 Laurent Destailleur * Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2024 Frédéric France * * 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 @@ -215,7 +216,7 @@ if ($id > 0 || !empty($ref)) { if (strcmp($projectstatic->opp_amount, '')) { print price($projectstatic->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); if (strcmp($projectstatic->opp_percent, '')) { - print '       '.$langs->trans("Weighted").': '.price($projectstatic->opp_amount * $projectstatic->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).''; + print '       '.$langs->trans("OpportunityWeightedAmountShort").': '.price($projectstatic->opp_amount * $projectstatic->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).''; } } print ''; diff --git a/htdocs/workstation/workstation_agenda.php b/htdocs/workstation/workstation_agenda.php index d0d792ce208..776a5cdd6ae 100644 --- a/htdocs/workstation/workstation_agenda.php +++ b/htdocs/workstation/workstation_agenda.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2020 Gauthier VERDOL + * Copyright (C) 2024 Frédéric France * * 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 @@ -85,7 +86,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->workstation->multidir_output[$object->entity]."/".$object->id; + $upload_dir = rtrim(getMultidirOutput($object, '', 1), '/'); } // Permissions diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index 0dc3d05c6d5..39537b35664 100644 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -1,6 +1,7 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -93,7 +94,7 @@ $permissiontodelete = $user->hasRight('workstation', 'workstation', 'delete') || $permissionnote = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_dellink.inc.php -$upload_dir = $conf->workstation->multidir_output[isset($object->entity) ? $object->entity : 1]; +$upload_dir = rtrim(getMultidirOutput($object, '', 1), '/'); // Security check $isdraft = 0; @@ -335,7 +336,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $parameters = array( + 'formConfirm' => $formconfirm, + // 'lineid' => $lineid, + ); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $formconfirm .= $hookmanager->resPrint; diff --git a/htdocs/workstation/workstation_document.php b/htdocs/workstation/workstation_document.php index e1b891da1ce..69dc0ec2573 100644 --- a/htdocs/workstation/workstation_document.php +++ b/htdocs/workstation/workstation_document.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2020 Gauthier VERDOL + * Copyright (C) 2024 Frédéric France * * 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 @@ -75,7 +76,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->workstation->multidir_output[$object->entity ? $object->entity : $conf->entity]."/workstation/".get_exdir(0, 0, 0, 1, $object); + $upload_dir = rtrim(getMultidirOutput($object, '', 1), '/'); } // Security check @@ -186,7 +187,7 @@ if ($object->id) { $modulepart = 'workstation'; $param = '&id='.$object->id; //$relativepathwithnofile='workstation/' . dol_sanitizeFileName($object->id).'/'; - $relativepathwithnofile = 'workstation/'.dol_sanitizeFileName($object->ref).'/'; + //$relativepathwithnofile = 'workstation/'.dol_sanitizeFileName($object->ref).'/'; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/workstation/workstation_note.php b/htdocs/workstation/workstation_note.php index f2be1c32504..794e69b17d4 100644 --- a/htdocs/workstation/workstation_note.php +++ b/htdocs/workstation/workstation_note.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2020 Gauthier VERDOL + * Copyright (C) 2024 Frédéric France * * 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 @@ -53,7 +54,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->workstation->multidir_output[$object->entity]."/".$object->id; + $upload_dir = rtrim(getMultidirOutput($object, '', 1), '/'); } $permissionnote = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_setnotes.inc.php