コード例 #1
0
 public function ConvertContacts()
 {
     $contact_data = $this->DbOld->GetAll('SELECT * FROM contacts');
     $ok = $fail = 0;
     foreach ($contact_data as $i => $contact_row) {
         $imported = (int) $this->DbNew->GetOne('SELECT COUNT(*) FROM contacts WHERE clid = ?', array($contact_row['clid']));
         if ($imported) {
             // Skip contact, that was imported with domain in $this->ConvertActiveDomains
             continue;
         }
         $this->Log(sprintf('Import contact %s', $contact_row['clid']));
         if ($contact_row['type'] == 'bill') {
             $contact_row['type'] = CONTACT_TYPE::BILLING;
         }
         $Registry = $this->RegistryFactory->GetRegistryByExtension($contact_row['TLD'], $db_check = false);
         $Contact = $Registry->NewContactInstance($contact_row['type']);
         $Contact->CLID = $contact_row['clid'];
         $Contact->AuthCode = $contact_row['pw'];
         $Contact->UserID = $contact_row['userid'];
         try {
             $Contact = $Registry->GetRemoteContact($Contact);
             $this->DBContact->Save($Contact);
             $ok++;
         } catch (Exception $e) {
             $this->Log($e->getMessage(), E_USER_ERROR);
             $fail++;
         }
     }
     $this->Log(sprintf("Imported: %s; Failed: %s", $ok, $fail));
 }