'contact_private'=>"CASE access WHEN 'private' THEN 1 ELSE 0 END",
'n_fn'=>'fn',
'contact_title'=>'title',
'contact_bday'=>'bday',
'contact_note'=>'note',
'contact_tz'=>'tz',
'contact_geo'=>'geo',
'contact_url'=>'url',
'contact_pubkey'=>'pubkey',
'contact_label'=>'label',
'contact_email'=>'email',
'contact_email_home'=>'email_home',
'contact_modified'=>'last_mod',
// remove stupid old default values, rename phone-numbers, tel_bbs and tel_video are droped
'tel_work'=>"CASE tel_work WHEN '+1 (000) 000-0000' THEN NULL ELSE tel_work END",
'tel_cell'=>"CASE tel_cell WHEN '+1 (000) 000-0000' THEN NULL ELSE tel_cell END",
'tel_fax'=>"CASE tel_fax WHEN '+1 (000) 000-0000' THEN NULL ELSE tel_fax END",
'tel_assistent'=>"CASE tel_msg WHEN '+1 (000) 000-0000' THEN NULL ELSE tel_msg END",
'tel_car'=>"CASE tel_car WHEN '+1 (000) 000-0000' THEN NULL ELSE tel_car END",
'tel_pager'=>"CASE tel_pager WHEN '+1 (000) 000-0000' THEN NULL ELSE tel_pager END",
'tel_home'=>"CASE tel_home WHEN '+1 (000) 000-0000' THEN NULL ELSE tel_home END",
'tel_fax_home'=>"CASE tel_modem WHEN '+1 (000) 000-0000' THEN NULL ELSE tel_modem END",
'tel_cell_private'=>"CASE tel_isdn WHEN '+1 (000) 000-0000' THEN NULL ELSE tel_isdn END",
'tel_other'=>"CASE tel_voice WHEN '+1 (000) 000-0000' THEN NULL ELSE tel_voice END",
'tel_prefer'=>"CASE tel_prefer WHEN 'tel_voice' THEN 'tel_other' WHEN 'tel_msg' THEN 'tel_assistent' WHEN 'tel_modem' THEN 'tel_fax_home' WHEN 'tel_isdn' THEN 'tel_cell_private' WHEN 'ophone' THEN 'tel_other' ELSE tel_prefer END",
// set creator from owner
'contact_creator'=>'owner',
// set contact_fileas from org_name, n_family and n_given
'n_fileas'=>"CASE WHEN org_name='' THEN (".
($name_sql="CASE WHEN n_given='' THEN n_family ELSE ".$GLOBALS['egw_setup']->db->concat('n_family',"', '",'n_given').' END').
") ELSE (CASE WHEN n_family='' THEN org_name ELSE ".$GLOBALS['egw_setup']->db->concat('org_name',"': '",$name_sql).' END) END',
));
// migrate values saved in custom fields to the new table
'('.$old2new[$row['contact_name']].'IS NULL OR '.$old2new[$row['contact_name']]."='')",
),__LINE__,__FILE__,'addressbook');
}
// delete the not longer used custom fields plus rubish from old bugs
$GLOBALS['egw_setup']->db->delete('egw_addressbook_extra',"contact_name IN ('ophone','address2','address3','freebusy_url','cat_id','tid','lid','id','ab_id','access','owner','rights')".
" OR contact_value='' OR contact_value IS NULL".
($db2->capabilities['subqueries']?" OR contact_id NOT IN (SELECT contact_id FROM egw_addressbook)":''),