Migration LDAP --> SQL

This commit is contained in:
Ralf Becker 2008-05-07 13:13:23 +00:00
parent 0c586d9ff0
commit eef92b5785
4 changed files with 11 additions and 7 deletions

View File

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

View File

@ -101,6 +101,7 @@ contact saved addressbook de Kontakt gespeichert
contact settings admin de Kontakt Einstellungen contact settings admin de Kontakt Einstellungen
contactform addressbook de Kontaktformular contactform addressbook de Kontaktformular
contacts and account contact-data to ldap admin de Kontakte und Kontaktdaten der Benutzer nach LDAP contacts and account contact-data to ldap admin de Kontakte und Kontaktdaten der Benutzer nach LDAP
contacts and account contact-data to sql admin de Kontakte und Kontaktdaten der Benutzer nach SQL
contacts to ldap admin de Kontakte nach LDAP contacts to ldap admin de Kontakte nach LDAP
contacts to ldap, account contact-data to sql admin de Kontakte nach LDAP, Kontaktdaten der Benutzer nach SQL contacts to ldap, account contact-data to sql admin de Kontakte nach LDAP, Kontaktdaten der Benutzer nach SQL
contains addressbook de beinhaltet contains addressbook de beinhaltet

View File

@ -101,6 +101,7 @@ contact saved addressbook en Contact saved
contact settings admin en Contact Settings contact settings admin en Contact Settings
contactform addressbook en Contactform contactform addressbook en Contactform
contacts and account contact-data to ldap admin en contacts and account contact-data to LDAP contacts and account contact-data to ldap admin en contacts and account contact-data to LDAP
contacts and account contact-data to sql admin en contacts and account contact-data to SQL
contacts to ldap admin en contacts to LDAP contacts to ldap admin en contacts to LDAP
contacts to ldap, account contact-data to sql admin en contacts to LDAP, account contact-data to SQL contacts to ldap, account contact-data to sql admin en contacts to LDAP, account contact-data to SQL
contains addressbook en contains contains addressbook en contains

View File

@ -112,6 +112,7 @@
<option value="contacts" title="{lang_if_accounts_are_already_in_LDAP}">{lang_contacts_to_LDAP}</option> <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" 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> <option value="contacts,accounts-back" title="{lang_for_read_only_LDAP}">{lang_contacts_to_LDAP,_account_contact-data_to_SQL}</option>
<option value="sql" title="{lang_for_read_only_LDAP}">{lang_contacts_and_account_contact-data_to_SQL}</option>
</select> </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}" /> <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> </td>