From 9bece8c380e4da967dd74c48795874095225f91b Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller <45882981+Hystepik@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:56:45 +0200 Subject: [PATCH 1/3] New datastructure for webhok_target (#31363) Co-authored-by: Hystepik --- htdocs/install/mysql/migration/20.0.0-21.0.0.sql | 2 ++ .../install/mysql/tables/llx_webhook_target-webhook.sql | 1 + htdocs/webhook/class/target.class.php | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql index b0d31650596..ddefc5b15d5 100644 --- a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql +++ b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql @@ -132,6 +132,8 @@ ALTER TABLE llx_societe ADD COLUMN ip varchar(250); ALTER TABLE llx_recruitment_recruitmentcandidature ADD COLUMN ip varchar(250); ALTER TABLE llx_socpeople ADD COLUMN ip varchar(250); +ALTER TABLE llx_webhook_target ADD COLUMN trigger_stack text; + -- Product attribut extrafields CREATE TABLE llx_product_attribute_extrafields ( diff --git a/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql b/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql index 28802156847..54fdc2d2079 100644 --- a/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql +++ b/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql @@ -32,5 +32,6 @@ CREATE TABLE llx_webhook_target( connection_method varchar(255) NULL, -- to store the way to authenticate to the webhook connection_data varchar(255) NULL, -- to store the data to use to authenticate to the webhook trigger_codes text NULL -- list of selected trigger that must call the webhook + trigger_stack text, -- json object to store trigger to be send manually -- END MODULEBUILDER FIELDS ) ENGINE=innodb; diff --git a/htdocs/webhook/class/target.class.php b/htdocs/webhook/class/target.class.php index 48c907264f2..fb6aeec88e8 100644 --- a/htdocs/webhook/class/target.class.php +++ b/htdocs/webhook/class/target.class.php @@ -106,7 +106,8 @@ class Target extends CommonObject 'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => 1, 'position' => 510, 'notnull' => 1, 'visible' => -2, 'foreignkey' => 'user.rowid',), 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2,), 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,), - 'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => 1, 'position' => 2000, 'notnull' => 1, 'default' => '1', 'visible' => 1, 'index' => 1, 'arrayofkeyval' => array('0' => 'Disabled', '1' => 'Enabled'), 'validate' => 1,), + 'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => 1, 'position' => 2000, 'notnull' => 1, 'default' => '1', 'visible' => 1, 'index' => 1, 'arrayofkeyval' => array('0' => 'Disabled', '1' => 'AutomaticTrigger', '2' => 'ManualTrigger'), 'validate' => 1,), + "trigger_stack" => array("type" => "text", "label" => "TriggerStack", "enabled" => "1", 'position' => 59, 'notnull' => 0, "visible" => "0",), ); public $rowid; public $ref; @@ -123,6 +124,11 @@ class Target extends CommonObject * @var string List of trigger codes separated by a comma. Example: 'BILL_VALIDATE,PROPAL_DELETE,...' */ public $trigger_codes; + + /** + * @var string Json array to store manual trigger that needs to be send + */ + public $trigger_stack; // END MODULEBUILDER PROPERTIES From 9c20e93860e95d10eb857547b7172a91241e2530 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 11 Oct 2024 16:04:46 +0200 Subject: [PATCH 2/3] Fix: Cope with undevined country key in search array. (#31354) # Fix: Cope with undefined country key in search array Fix: ``` htdocs\partnership\partnership_list.php:533 PhanUndeclaredProperty Reference to undeclared property \Partnership->login htdocs\partnership\partnership_list.php:793 PhanTypeMismatchArgumentProbablyReal Argument 4 ($filter) is null of type null but \FormAdmin::select_language() takes array|string[] (no real type) defined at htdocs\core\class\html.formadmin.class.php:74 (the inferred real argument type has nothing in common with the parameter's phpdoc type) ``` --- dev/tools/phan/baseline.txt | 2 +- htdocs/partnership/partnership_list.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 24b013506ea..21519c7a845 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -700,7 +700,7 @@ return [ 'htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php' => ['PhanUndeclaredProperty'], 'htdocs/partnership/lib/partnership.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/partnership/partnership_card.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/partnership/partnership_list.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], + 'htdocs/partnership/partnership_list.php' => ['PhanUndeclaredProperty'], 'htdocs/paypal/lib/paypal.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/printing/index.php' => ['PhanUndeclaredProperty'], 'htdocs/printing/lib/printing.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 5ccb7ec210a..5d4ac440cf6 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2021 NextGestion * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -790,9 +791,9 @@ foreach ($all_fields_list as $key => $val) { } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language($search[$key], 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } elseif ($key == 'country') { - print $form->select_country($search[$key], 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print $form->select_country(in_array($key, $search) ? $search[$key] : 0, 'search_country', '', 0, 'minwidth100imp maxwidth100'); } else { print ''; } From c9690393bc1b748174156e0698eb940e0fb0db27 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 11 Oct 2024 16:05:37 +0200 Subject: [PATCH 3/3] Fix undefined global varialbe user/card.php (#31353) # Fix undefined global varialbe user/card.php Fix a few issues, one of which noticed in V21 UI. Also notified by phan: ``` htdocs\user\card.php:626 PhanUndeclaredGlobalVariable Global variable $mesgs is undeclared htdocs\user\card.php:2967 PhanUndeclaredGlobalVariable Global variable $soc is undeclared ``` --- dev/tools/phan/baseline.txt | 2 +- htdocs/user/card.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 21519c7a845..22aa739058b 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -918,7 +918,7 @@ return [ 'htdocs/ticket/list.php' => ['PhanTypeComparisonFromArray'], 'htdocs/ticket/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/user/bank.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], - 'htdocs/user/card.php' => ['PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], + 'htdocs/user/card.php' => ['PhanTypeMismatchProperty'], 'htdocs/user/class/api_users.class.php' => ['PhanTypeMismatchProperty'], 'htdocs/user/class/user.class.php' => ['PhanUndeclaredProperty'], 'htdocs/user/class/usergroup.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], diff --git a/htdocs/user/card.php b/htdocs/user/card.php index d37db64cf58..8dd90fdc380 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -609,6 +609,7 @@ if (empty($reshook)) { $dir = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'user').'/photos'; dol_mkdir($dir); + $mesgs = null; if (@is_dir($dir)) { $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); @@ -2964,7 +2965,15 @@ if ($action == 'create' || $action == 'adduserldap') { $genallowed = $user->hasRight("user", "user", "read"); $delallowed = $user->hasRight("user", "user", "write"); - print $formfile->showdocuments('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', !is_object($soc) || empty($soc->default_lang) ? '' : $soc->default_lang); + + if ($object->socid) { + $societe = new Societe($db); + $societe->fetch($object->socid); + } else { + $societe = null; + } + + print $formfile->showdocuments('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', !is_object($societe) || empty($societe->default_lang) ? '' : $societe->default_lang); $somethingshown = $formfile->numoffiles; // Show links to link elements