Migration LDAP --> SQL

This commit is contained in:
Ralf Becker 2008-05-07 13:15:11 +00:00
parent 7cc8653370
commit 3ca4300cca
2 changed files with 9 additions and 7 deletions

View File

@ -728,7 +728,7 @@ class socontacts
$start = $n = 0;
$num = 100;
while (($contacts = $sql_contacts->search(false,false,'n_family,n_given','','',false,'AND',
while ($type != 'sql' && ($contacts = $sql_contacts->search(false,false,'n_family,n_given','','',false,'AND',
array($start,$num),$type != 'contacts,accounts' ? array('contact_owner != 0') : false)))
{
// very worse hack, until Ralf finds a better solution
@ -754,21 +754,21 @@ class socontacts
}
$start += $num;
}
if ($type == 'contacts,accounts-back') // migrate the accounts to sql
if ($type == 'contacts,accounts-back' || $type == 'sql') // migrate the accounts to sql
{
// very worse hack, until Ralf finds a better solution
// when migrating data, we need to bind as global ldap admin account
// and not as currently logged in user
$ldap_contacts->ds = $GLOBALS['egw']->ldap->ldapConnect();
foreach($ldap_contacts->search(false,false,'n_family,n_given','','',false,'AND',
false,array('owner' => 0)) as $contact)
false,$type == 'sql'?null:array('owner' => 0)) as $contact)
{
if ($contact['jpegphoto']) // photo is NOT read by LDAP backend on search, need to do an extra read
{
$contact = $ldap_contacts->read($contact['id']);
}
unset($contact['id']); // ldap uid/account_lid
if ($contact['account_id'] && ($old = $sql_contacts->read(array('account_id' => $contact['account_id']))))
if ($type != 'sql' && $contact['account_id'] && ($old = $sql_contacts->read(array('account_id' => $contact['account_id']))))
{
$contact['id'] = $old['id'];
}
@ -778,7 +778,8 @@ class socontacts
if (!($err = $sql_contacts->save()))
{
echo '<p style="margin: 0px;">'.$n.': '.$contact['n_fn'].
($contact['org_name'] ? ' ('.$contact['org_name'].')' : '')." --> SQL (".lang('User').")</p>\n";
($contact['org_name'] ? ' ('.$contact['org_name'].')' : '')." --> SQL (".
($contact['owner']?lang('User'):lang('Contact')).")</p>\n";
}
else
{

View File

@ -84,7 +84,7 @@
</tr>
<tr class="th">
<td colspan="2">
&nbsp;{lang_Additional_information_about_using_LDAP_as_contact_repository}:
&nbsp;{lang_Additional_information_about_using_LDAP_as_contact_repository}:
<a href="addressbook/doc/README" target="_blank">README</a>
</td>
</tr>
@ -96,7 +96,8 @@
<option value="contacts" title="{lang_if_accounts_are_already_in_LDAP}">{lang_contacts_to_LDAP}</option>
<option value="contacts,accounts" title="{lang_use_setup_for_a_full_account-migration}">{lang_contacts_and_account_contact-data_to_LDAP}</option>
<option value="contacts,accounts-back" title="{lang_for_read_only_LDAP}">{lang_contacts_to_LDAP,_account_contact-data_to_SQL}</option>
</select>
<option value="sql" title="{lang_for_read_only_LDAP}">{lang_contacts_and_account_contact-data_to_SQL}</option>
</select>
<input type="button" onclick="if (this.form.migrate.value) document.location.href='index.php?menuaction=addressbook.uicontacts.migrate2ldap&type='+this.form.migrate.value;" value="{lang_Start}" />
</td>
</tr>