Skip to content

Commit

Permalink
Add a new hook into CommonObject#commonReplaceThirdparty (#30827)
Browse files Browse the repository at this point in the history
  • Loading branch information
creekorful authored Sep 30, 2024
1 parent 3e76477 commit 3da76f9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 3da76f9

Please sign in to comment.