// migrate to the multiple addressbook schema first if needed if ($prefs_all['db_version'] == 1 || !array_key_exists('db_version', $prefs_all)) { self::$helper->debug("migrating DB1 to DB2"); unset($prefs_all['db_version']); $p = array(); $p['CardDAV'] = $prefs_all; $p['db_version'] = 2; $prefs_all = $p; } // migrate settings to database foreach ($prefs_all as $desc => $prefs) { // skip non address book attributes if (!is_array($prefs)) { continue; } $crypt_password = self::$helper->encrypt_password($prefs['password']); self::$helper->debug("move addressbook {$desc}"); $dbh->query('INSERT INTO ' . get_table_name('carddav_addressbooks') . '(name,username,password,url,active,user_id) ' . 'VALUES (?, ?, ?, ?, ?, ?)', $desc, $prefs['username'], $crypt_password, $prefs['url'], $prefs['use_carddav'], $_SESSION['user_id']); } // delete old settings $usettings = $rcmail->user->get_prefs(); $usettings['carddav'] = array(); self::$helper->debug("delete old prefs: " . $rcmail->user->save_prefs($usettings)); } public static function initClass() { self::$helper = new carddav_common('BACKEND: '); } } carddav_backend::initClass();