offer to delete all existing accounts from SQL tables, before migration to it

This commit is contained in:
Ralf Becker 2013-05-23 14:33:14 +00:00
parent a7944a3b76
commit eaf3e6e1a5
3 changed files with 24 additions and 5 deletions

View File

@ -64,6 +64,7 @@ $cmd = new setup_cmd_ldap(array(
'ldap_admin' => !empty($_POST['ldap_admin']) ? $_POST['ldap_admin'] : $GLOBALS['egw_info']['server']['ldap_root_dn'],
'ldap_admin_pw' => !empty($_POST['ldap_admin']) ? $_POST['ldap_admin_pw'] : $GLOBALS['egw_info']['server']['ldap_root_pw'],
'ldap_base' => implode(',',$base_parts),
'truncate_egw_accounts' => !empty($_POST['truncate_egw_accounts']),
)+$GLOBALS['egw_info']['server']);
if (!$_POST['migrate'])
@ -77,6 +78,7 @@ if (!$_POST['migrate'])
$setup_tpl->set_block('migration','ldap_admin','ldap_admin');
$setup_tpl->set_block('migration','submit','submit');
$setup_tpl->set_block('migration','footer','footer');
$setup_tpl->set_block('migration','truncate_egw_accounts','truncate_egw_accounts');
foreach($accounts as $account_id => $account)
{
@ -99,7 +101,7 @@ if (!$_POST['migrate'])
$setup_tpl->set_var('users',$user_list);
$setup_tpl->set_var('groups',$group_list);
$setup_tpl->set_var('description',lang('Migration between eGroupWare account repositories').': '.$direction);
$setup_tpl->set_var('description',lang('Migration between EGroupware account repositories').': '.$direction);
$setup_tpl->set_var('select_users',lang('Select which user(s) will be exported'));
$setup_tpl->set_var('select_groups',lang('Select which group(s) will be exported'));
$setup_tpl->set_var('memberships',$identical_account_id_warning ?
@ -124,6 +126,11 @@ if (!$_POST['migrate'])
{
$setup_tpl->pfp('out','ldap_admin');
}
if ($to == 'sql')
{
$setup_tpl->set_var('truncate_egw_accounts_message', lang('Delete all existing accounts from SQL database'));
$setup_tpl->pfp('out','truncate_egw_accounts');
}
$setup_tpl->pfp('out','submit');
$setup_tpl->pfp('out','footer');
}

View File

@ -48,10 +48,11 @@ class setup_cmd_ldap extends setup_cmd
* @param string $ldap_group_context=null ou for groups, default "ou=groups,$base"
* @param string $sub_command='create_ldap' 'create_ldap', 'test_ldap', 'test_ldap_root', see exec method
* @param string $ldap_encryption_type='des'
* @param boolean $truncate_egw_accounts=false truncate accounts table before migration to SQL
*/
function __construct($domain,$ldap_host=null,$ldap_suffix=null,$ldap_admin=null,$ldap_admin_pw=null,
$ldap_base=null,$ldap_root_dn=null,$ldap_root_pw=null,$ldap_context=null,$ldap_search_filter=null,
$ldap_group_context=null,$sub_command='create_ldap',$ldap_encryption_type='des')
$ldap_group_context=null,$sub_command='create_ldap',$ldap_encryption_type='des',$truncate_egw_accounts=false)
{
if (!is_array($domain))
{
@ -69,6 +70,7 @@ class setup_cmd_ldap extends setup_cmd
'ldap_group_context' => $ldap_group_context,
'sub_command' => $sub_command,
'ldap_encryption_type' => $ldap_encryption_type,
'truncate_egw_accounts' => $truncate_egw_accounts,
);
}
//echo __CLASS__.'::__construct()'; _debug_array($domain);
@ -145,12 +147,12 @@ class setup_cmd_ldap extends setup_cmd
// read accounts from old store
$accounts = $this->accounts(!$to_ldap);
/* uncomment if you want to have SQL cleaned up before migration
if (!$to_ldap)
// clean up SQL before migration
if (!$to_ldap && $this->truncate_egw_accounts)
{
$GLOBALS['egw']->db->query('TRUNCATE TABLE egw_accounts', __LINE__, __FILE__);
$GLOBALS['egw']->db->query('DELETE FROM egw_addressbook WHERE account_id IS NOT NULL', __LINE__, __FILE__);
}*/
}
// instanciate accounts obj for new store
$accounts_obj = $this->accounts_obj($to_ldap);
@ -224,6 +226,8 @@ class setup_cmd_ldap extends setup_cmd
{
if (!isset($emailadmin_src))
{
// add egw-pear to include_path, as setup does NOT do it (only includes common_functions.inc.php from API)
set_include_path(EGW_SERVER_ROOT.'/egw-pear'.PATH_SEPARATOR.get_include_path());
include_once(EGW_INCLUDE_ROOT.'/emailadmin/inc/class.'.$ldap_class.'.inc.php');
if ($to_ldap)
{

View File

@ -37,6 +37,14 @@
</tr>
<!-- END ldap_admin -->
<!-- BEGIN truncate_egw_accounts -->
<tr bgcolor="#e6e6e6">
<td colspan="2" align="center">
<label><input type="checkbox" name="truncate_egw_accounts">{truncate_egw_accounts_message}</label>
</td>
</tr>
<!-- END truncate_egw_accounts -->
<!-- BEGIN submit -->
</tr>
<tr bgcolor="#e6e6e6">