* AD/LDAP/InfoLog: change group owners on account-migration

This commit is contained in:
Ralf Becker 2018-03-14 14:49:32 +01:00
parent dcb78d9776
commit 6c15873c4f
2 changed files with 34 additions and 0 deletions

View File

@ -301,4 +301,37 @@ class infolog_customfields extends admin_customfields
Api\Storage\Customfields::save('infolog', $this->fields); Api\Storage\Customfields::save('infolog', $this->fields);
Api\Config::save_value('group_owners',$this->group_owners,'infolog'); 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;
}
} }

View File

@ -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']['timesheet_set'] = 'infolog.infolog_ui.timesheet_set';
$setup_info['infolog']['hooks']['calendar_set'] = 'infolog.infolog_ui.calendar_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']['mail_import'] = 'infolog_hooks::mail_import';
$setup_info['infolog']['hooks']['change_account_ids'] = 'infolog_customfields::change_account_ids';
// Dependencies for this app to work // Dependencies for this app to work
$setup_info['infolog']['depends'][] = array( $setup_info['infolog']['depends'][] = array(