diff --git a/infolog/inc/class.infolog_customfields.inc.php b/infolog/inc/class.infolog_customfields.inc.php index 5642ae1dfb..96d474f578 100644 --- a/infolog/inc/class.infolog_customfields.inc.php +++ b/infolog/inc/class.infolog_customfields.inc.php @@ -301,4 +301,37 @@ class infolog_customfields extends admin_customfields Api\Storage\Customfields::save('infolog', $this->fields); Api\Config::save_value('group_owners',$this->group_owners,'infolog'); } + + /** + * Change account_ids in group_owners configuration hook called from admin_cmd_change_account_id + * + * @param array $changes + * @return int number of changed account_ids + */ + public static function change_account_ids(array $changes) + { + unset($changes['location']); // no change, but the hook name + $changed = 0; + + // migrate staff account_ids + $config = Api\Config::read('infolog'); + if (!empty($config['group_owners'])) + { + foreach($config['group_owners'] as &$account_id) + { + if (isset($changes[$account_id])) + { + $account_id = $changes[$account_id]; + $changed++; + $needs_save = true; + } + } + if ($needs_save) + { + Api\Config::save_value('group_owners', $config['group_owners'], 'infolog'); + } + } + + return $changed; + } } diff --git a/infolog/setup/setup.inc.php b/infolog/setup/setup.inc.php index 4cb0622130..6f99f79f77 100644 --- a/infolog/setup/setup.inc.php +++ b/infolog/setup/setup.inc.php @@ -57,6 +57,7 @@ $setup_info['infolog']['hooks']['pm_custom_app_icons'] = 'infolog.infolog_bo.pm_ $setup_info['infolog']['hooks']['timesheet_set'] = 'infolog.infolog_ui.timesheet_set'; $setup_info['infolog']['hooks']['calendar_set'] = 'infolog.infolog_ui.calendar_set'; $setup_info['infolog']['hooks']['mail_import'] = 'infolog_hooks::mail_import'; +$setup_info['infolog']['hooks']['change_account_ids'] = 'infolog_customfields::change_account_ids'; // Dependencies for this app to work $setup_info['infolog']['depends'][] = array(