From 3da76f953671ba8cb446f1ac9f8c07e3a3c37179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Mon, 30 Sep 2024 10:19:35 +0200 Subject: [PATCH] Add a new hook into CommonObject#commonReplaceThirdparty (#30827) --- htdocs/core/class/commonobject.class.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6fa140f2ea8eb..dfe43e86bb7b6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9376,6 +9376,21 @@ public function getRights() */ public static function commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) { + global $hookmanager; + + $hookmanager->initHooks(array('commonobject')); + $parameters = array( + 'origin_id' => $origin_id, + 'dest_id' => $dest_id, + 'tables' => $tables, + ); + $reshook = $hookmanager->executeHooks('commonReplaceThirdparty', $parameters); + if ($reshook) { + return true; // replacement code + } elseif ($reshook < 0) { + return $ignoreerrors === 1; // failure + } // reshook = 0 => execute normal code + foreach ($tables as $table) { $sql = 'UPDATE '.$dbs->prefix().$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id);