phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] addressbook/inc/import Import_from_Outlook_-_English,


From: skwashd
Subject: [Phpgroupware-cvs] addressbook/inc/import Import_from_Outlook_-_English, 1.3 Import_from_Outlook_-_Deutsch, 1.3 Import_from_Netscape, 1.3 Import_Multiple_VCard, 1.3
Date: Thu, 24 Feb 2005 13:20:28 -0000

Update of addressbook/inc/import

Modified Files:
     Branch: MAIN
            Import_from_Outlook_-_English lines: +97 -113
            Import_from_Outlook_-_Deutsch lines: +136 -113
            Import_from_Netscape lines: +37 -53
            Import_Multiple_VCard lines: +8 -7

Log Message:
merge from 16

====================================================
Index: addressbook/inc/import/Import_from_Outlook_-_English
diff -u addressbook/inc/import/Import_from_Outlook_-_English:1.2 
addressbook/inc/import/Import_from_Outlook_-_English:1.3
--- addressbook/inc/import/Import_from_Outlook_-_English:1.2    Tue Dec  4 
01:17:10 2001
+++ addressbook/inc/import/Import_from_Outlook_-_English        Fri Dec 31 
04:55:24 2004
@@ -22,111 +22,106 @@
 //
 // Also start with a '#' symbol and a comma separated list will be
 // turned into a number of the same entries.
-
-       class import_conv
+       
include_once(PHPGW_INCLUDE_ROOT.'/addressbook/inc/class.addressbook_importer.inc.php');
+       class import_conv extends addressbook_importer
        {
                var $currentrecord = array(); //used for buffering to allow uid 
lines to go first
                var $id;
                var $type = 'csv';

                var $import = array(
-                       'Title' => 'title',
-                       'First Name' => 'n_given',
-                       'Middle Name' => 'n_middle',
-                       'Last Name' => 'n_family',
-                       'Suffix' => 'n_suffix',
-                       'Company' => 'org_name',  //objectclass: organization
-                       'Department' => 'org_unit', //objectclass: 
organizationalPerson
-                       'Job Title' => 'title', //objectclass: 
organizationalPerson
-                       'Business Street' => 'adr_one_street',
-                       'Business Street 2' => 'address2',
-                       'Business Street 3' => 'address3',
-                       'Business City' => 'adr_one_locality',
-                       'Business State' => 'adr_one_region',
-                       'Business Postal Code' => 'adr_one_postalcode',
-                       'Business Country' => 'adr_one_countryname',
-                       'Home Street' => 'adr_two_street',
-                       'Home City' => 'adr_two_locality',
-                       'Home State' => 'adr_two_region',
-                       'Home Postal Code' => 'adr_two_postalcode',
-                       'Home Country' => 'adr_two_countryname',
-                       'Home Street 2' => '',
-                       'Home Street 3' => '',
-                       'Other Street' => '',
-                       'Other City' => '',
-                       'Other State' => '',
-                       'Other Postal Code' => '',
-                       'Other Country' => '',
-                       "Assistant's Phone" => 'tel_msg',
-                       'Business Fax' => 'tel_fax',
-                       'Business Phone' => 'tel_work',
-                       'Business Phone 2' => 'ophone',
-                       'Callback' => '',
-                       'Car Phone' => 'tel_car',
-                       'Company Main Phone' => '',
-                       'Home Fax' => '',
-                       'Home Phone' => 'tel_home',
-                       'Home Phone 2' => '', //This will make another 
homePhone entry
-                       'ISDN' => 'tel_isdn',
-                       'Mobile Phone' => 'tel_cell', //newPilotPerson
-                       'Other Fax' => '',
-                       'Other Phone' => '',
-                       'Pager' => 'tel_pager',
-                       'Primary Phone' => '',
-                       'Radio Phone' => '',
-                       'TTY/TDD Phone' => '',
-                       'Telex' => '', //organization
-                       'Account' => '',
-                       'Anniversary' => '',
-                       "Assistant's Name" => '', //newPilotPerson
-                       'Billing Information' => '',
-                       'Birthday' => 'bday',
-                       'Categories' => '',
-                       'Children' => '',
-                       'Directory Server' => '',
-                       'E-mail Address' => 'email',
-                       'E-mail Display Name' => '',
-                       'E-mail 2 Address' => 'email_home',
+                       'Title'                 => array('person', 'title'),
+                       'First Name'            => array('person', 
'first_name'),
+                       'Middle Name'           => array('person', 
'middle_name'),
+                       'Last Name'             => array('person', 'last_name'),
+                       'Suffix'                => array('person', 'suffix'),
+                       'Company'               => '',  //objectclass: 
organization
+                       'Department'            => array('person', 
'department'), //objectclass: organizationalPerson
+                       'Job Title'             => array('person', 'title'), 
//objectclass: organizationalPerson
+                       'Business Street'       => array('location', 'add1', 
'work'),
+                       'Business Street 2'     => array('location', 'add2', 
'work'),
+                       'Business Street 3'     => array('location', 'add3', 
'work'),
+                       'Business City'         => array('location', 'city', 
'work'),
+                       'Business State'        => array('location', 'state', 
'work'),
+                       'Business Postal Code'  => array('location', 
'postal_code', 'work'),
+                       'Business Country'      => array('location', 'country', 
'work'),
+                       'Home Street'           => array('location', 'add1', 
'home'),
+                       'Home City'             => array('location', 'city', 
'home'),
+                       'Home State'            => array('location', 'state', 
'home'),
+                       'Home Postal Code'      => array('location', 
'postal_code', 'home'),
+                       'Home Country'          => array('location', 'country', 
'home'),
+                       'Home Street 2'         => array('location', 'add2', 
'home'),
+                       'Home Street 3'         => array('location', 'add3', 
'home'),
+                       'Other Street'          => '',
+                       'Other City'            => '',
+                       'Other State'           => '',
+                       'Other Postal Code'     => '',
+                       'Other Country'         => '',
+                       "Assistant's Phone"     => array('comms', 'msg phone'),
+                       'Business Fax'          => array('comms', 'work fax'),
+                       'Business Phone'        => array('comms', 'work phone'),
+                       'Business Phone 2'      => array('comms', 'bbs'),
+                       'Callback'              => '',
+                       'Car Phone'             => array('comms', 'car phone'),
+                       'Company Main Phone'    => '',
+                       'Home Fax'              => array('comms', 'home fax'),
+                       'Home Phone'            => array('comms', 'home phone'),
+                       'Home Phone 2'          => array('comms', 'modem'), 
//This will make another homePhone entry
+                       'ISDN'                  => array('comms', 'isdn'),
+                       'Mobile Phone'          => array('comms', 'mobile 
(cell) phone'), //newPilotPerson
+                       'Other Fax'             => array('comms', 'work fax'),
+                       'Other Phone'           => array('comms', 'video'),
+                       'Pager'                 => array('comms', 'pager'),
+                       'Primary Phone'         => '',
+                       'Radio Phone'           => '',
+                       'TTY/TDD Phone'         => '',
+                       'Telex'                 => '', //organization
+                       'Account'               => '',
+                       'Anniversary'           => '',
+                       "Assistant's Name"      => '', //newPilotPerson
+                       'Billing Information'   => '',
+                       'Birthday'              => array('person', 'birthday'),
+                       'Categories'            => array('person', 
'categories'),
+                       'Children'              => '',
+                       'Directory Server'      => '',
+                       'E-mail Address'        => array('comms', 'work email'),
+                       'E-mail Display Name'   => '',
+                       'E-mail 2 Address'      => array('comms', 'home email'),
                        'E-mail 2 Display Name' => '',
-                       'E-mail 3 Address' => '', //add another...
+                       'E-mail 3 Address'      => '', //add another...
                        'E-mail 3 Display Name' => '',
-                       'Gender' => '',
-                       'Government ID Number' => '',
-                       'Hobby' => '',
-                       'Initials' => '',
-                       'Internet Free Busy' => '',
-                       'Keywords' => '',
-                       'Language' => '',
-                       'Location' => '',
-                       "Manager's Name" => '',
-                       'Mileage' => '',
-                       'Notes' => 'note',
-                       'Office Location' => '',
+                       'Gender'                => '',
+                       'Government ID Number'  => '',
+                       'Hobby'                 => '',
+                       'Initials'              => array('person', 'initials'),
+                       'Internet Free Busy'    => '',
+                       'Keywords'              => '',
+                       'Language'              => '',
+                       'Location'              => '',
+                       "Manager's Name"        => '',
+                       'Mileage'               => '',
+                       'Notes'                 => array('notes', 'note', 
'general'),
+                       'Office Location'       => '',
                        'Organizational ID Number' => '',
-                       'PO Box' => '',
-                       'Priority' => '',
-                       'Private Profession' => '',
-                       'Referred By' => '',
-                       'Sensitivity' => '',
-                       'Spouse' => '',
-                       'User 1' => '',
-                       'User 2' => '',
-                       'User 3' => '',
-                       'User 4' => '',
-                       'Web Page' => 'url'
+                       'PO Box'                => '',
+                       'Priority'              => '',
+                       'Private Profession'    => '',
+                       'Referred By'           => '',
+                       'Sensitivity'           => '',
+                       'Spouse'                => '',
+                       'User 1'                => '',
+                       'User 2'                => '',
+                       'User 3'                => '',
+                       'User 4'                => '',
+                       'Web Page'              => array('comms', 'website')
                );

                function import_start_file($buffer)
                {
-                       return $buffer;
                }

                function import_start_record($buffer)
                {
-                       $top=array();
-                       ++$this->id;
-                       $this->currentrecord = $top;
-                       return $buffer;
                }

                function import_new_attrib($buffer,$name,$value)
@@ -134,42 +129,31 @@
                        $value = trim($value);
                        $value = str_replace('\n','<BR>',$value);
                        $value = str_replace('\r','',$value);
-                       $this->currentrecord += array($name => $value);

-                       return $buffer;
+                       $method = $name[0];
+                       $element = $name[1];
+                       $args = $name[2];
+
+                       $this->$method($element, $value, $args);
                }

                function import_end_record($buffer)
                {
-                       $buffer[$this->id]='';
-                       while ( list($name, $value) = 
each($this->currentrecord))
-                       {
-                               $buffer[$this->id][$name] = $value;
-                               //echo '<br>'.$name.' => '.$value;
-                       }
-                       return $buffer;
+                       $this->record_set[] = $this->record;
+                       $this->record = array();
                }

                function import_end_file($buffer,$access='private',$cat_id=0)
                {
-                       $contacts = CreateObject('phpgwapi.contacts');
-                       //echo '<br>';
-                       for ($i=1;$i<=count($buffer);$i++)
+                       $contacts = CreateObject('phpgwapi.contacts');
+
+                       $num = count($this->record_set);
+                       foreach($this->record_set as $contact)
                        {
-                               while ( list($name,$value) = @each($buffer[$i]) 
)
-                               {
-                                       //echo '<br>'.$i.': '.$name.' => 
'.$value;
-                                       $entry[$i][$name] = $value;
-                               }
-                               $entry[$i]['email_type']      = 'INTERNET';
-                               $entry[$i]['email_home_type'] = 'INTERNET';
-                               $entry[$i]['adr_one_type']    = 'intl';
-                               $entry[$i]['adr_two_type']    = 'intl';
-                               //echo '<br>';
-                               
$contacts->add($GLOBALS['phpgw_info']['user']['account_id'],$entry[$i],$access,$cat_id);
+                               $contact['categories'] = array($cat_id);
+                               $contacts->contact_import($contact);
                        }
-                       $num = $i - 1;
-                       return lang('Successfully imported x records into your 
addressbook.',$num);
+                       return lang('Successfully imported %1 records into your 
addressbook.',$num);
                }
        }
 ?>

====================================================
Index: addressbook/inc/import/Import_from_Outlook_-_Deutsch
diff -u addressbook/inc/import/Import_from_Outlook_-_Deutsch:1.2 
addressbook/inc/import/Import_from_Outlook_-_Deutsch:1.3
--- addressbook/inc/import/Import_from_Outlook_-_Deutsch:1.2    Tue Dec  4 
01:17:10 2001
+++ addressbook/inc/import/Import_from_Outlook_-_Deutsch        Fri Dec 31 
04:55:24 2004
@@ -22,8 +22,8 @@
 //
 // Also start with a '#' symbol and a comma separated list will be
 // turned into a number of the same entries.
-
-       class import_conv
+       
include_once(PHPGW_INCLUDE_ROOT.'/addressbook/inc/class.addressbook_importer.inc.php');
+       class import_conv extends addressbook_importer
        {
                var $currentrecord = array(); //used for buffering to allow uid 
lines to go first
                var $id;
@@ -31,106 +31,106 @@

                /* Thanks to knecke for the Outlook fields */
                var $import = array(
-                       'Anrede' => 'title',
-                       'Vorname' => 'n_given',
-                       'Weitere Vornamen' => 'n_middle',
-                       'Nachname' => 'n_family',
-                       'Suffix' => 'n_suffix',
-                       'Firma' => 'org_name',
-                       'Abteilung' => 'org_unit',
-                       'Position' => 'title',
-                       'Straße geschäftlich' => 'adr_one_street',
-                       'Straße geschäftlich 2' => 'address2',
-                       'Straße geschäftlich 3' => 'address3',
-                       'Ort geschäftlich' => 'adr_one_locality',
-                       'Region geschäftlich' => 'adr_one_region',
-                       'Postleitzahl geschäftlich' => 'adr_one_postalcode',
-                       'Land geschäftlich' => 'adr_one_countryname',
-                       'Straße privat' => 'adr_two_street',
-                       'Straße privat 2' => '',
-                       'Straße privat 3' => '',
-                       'Ort privat' => 'adr_two_locality',
-                       'Region privat' => 'adr_two_region',
-                       'Postleitzahl privat' => 'adr_two_postalcode',
-                       'Land privat' => 'adr_two_countryname',
-                       'Weitere Straße' => '',
-                       'Weitere Straße 2' => '',
-                       'Weitere Straße 3' => '',
-                       'Weiterer Ort' => '',
-                       'Weitere Region' => '',
-                       'Weitere Postleitzahl' => '',
-                       'Weiteres Land' => '',
-                       'Telefon Assistent' => 'tel_msg',
-                       'Fax geschäftlich' => 'tel_fax',
-                       'Telefon geschäftlich' => 'tel_work',
-                       'Telefon geschäftlich 2' => 'ophone',
-                       'Rückmeldung' => '',
-                       'Autotelefon' => 'tel_car',
-                       'Telefon Firma' => '',
-                       'Fax privat' => '',
-                       'Telefon privat' => 'tel_home',
-                       'Telefon privat 2' => '',
-                       'ISDN' => 'tel_isdn',
-                       'Mobiltelefon' => 'tel_cell',
-                       'Weiteres Fax' => '',
-                       'Weiteres Telefon' => '',
-                       'Pager' => 'tel_pager',
-                       'Haupttelefon' => '',
-                       'Mobiltelefon 2' => '',
+                       'Anrede'                => array('person', 'title'),
+                       'Vorname'               => array('person', 
'first_name'),
+                       'Weitere Vornamen'      => array('person', 
'middle_name'),
+                       'Nachname'              => array('person', 'last_name'),
+                       'Suffix'                => array('person', 'suffix'),
+                       'Firma'                 => '', //org_name
+                       'Abteilung'             => array('person', 
'department'),
+                       'Position'              => array('person', 'title'),
+                       'Straße geschäftlich'   => array('location', 'add1', 
'work'),
+                       'Straße geschäftlich 2' => array('location', 'add2', 
'work'),
+                       'Straße geschäftlich 3' => array('location', 'add3', 
'work'),
+                       'Ort geschäftlich'      => array('location', 'city', 
'work'),
+                       'Region geschäftlich'   => array('location', 'state', 
'work'),
+                       'Postleitzahl geschäftlich'=> array('location', 
'postal_code', 'work'),
+                       'Land geschäftlich'     => array('location', 'country', 
'work'),
+                       'Straße privat'         => array('location', 'add1', 
'home'),
+                       'Straße privat 2'       => array('location', 'add2', 
'home'),
+                       'Straße privat 3'       => array('location', 'add3', 
'home'),
+                       'Ort privat'            => array('location', 'city', 
'home'),
+                       'Region privat'         => array('location', 'state', 
'home'),
+                       'Postleitzahl privat'   => array('location', 
'postal_code', 'home'),
+                       'Land privat'           => array('location', 'country', 
'home'),
+                       'Weitere Straße'        => '',
+                       'Weitere Straße 2'      => '',
+                       'Weitere Straße 3'      => '',
+                       'Weiterer Ort'          => '',
+                       'Weitere Region'        => '',
+                       'Weitere Postleitzahl'  => '',
+                       'Weiteres Land'         => '',
+                       'Telefon Assistent'     => array('comms', 'msg phone'),
+                       'Fax geschäftlich'      => array('comms', 'work fax'),
+                       'Telefon geschäftlich'  => array('comms', 'work phone'),
+                       'Telefon geschäftlich 2'=> array('comms', 'bbs'),
+                       'Rückmeldung'           => '',
+                       'Autotelefon'           => array('comms', 'car phone'),
+                       'Telefon Firma'         => '',
+                       'Fax privat'            => array('comms', 'home fax'),
+                       'Telefon privat'        => array('comms', 'home phone'),
+                       'Telefon privat 2'      => '',
+                       'ISDN'                  => array('comms', 'isdn'),
+                       'Mobiltelefon'          => array('comms', 'mobile 
(cell) phone'),
+                       'Weiteres Fax'          => '',
+                       'Weiteres Telefon'      => '',
+                       'Pager'                 => array('comms', 'pager'),
+                       'Haupttelefon'          => '',
+                       'Mobiltelefon 2'        => '',
                        'Telefon für Hörbehinderte' => '',
-                       'Telex' => '',
-                       'Abrechnungsinformation' => '',
-                       'Benutzer 1' => '',
-                       'Benutzer 2' => '',
-                       'Benutzer 3' => '',
-                       'Benutzer 4' => '',
-                       'Beruf' => '',
-                       'Büro' => '',
-                       'E-Mail-Adresse' => 'email',
+                       'Telex'                 => '',
+                       'Abrechnungsinformation'=> '',
+                       'Benutzer 1'            => '',
+                       'Benutzer 2'            => '',
+                       'Benutzer 3'            => '',
+                       'Benutzer 4'            => '',
+                       'Beruf'                 => '',
+                       'Büro'                  => '',
+                       'E-Mail-Adresse'        => array('comms', 'work email'),
                        'E-Mail: Angezeigter Name' => '',
-                       'E-Mail 2: Adresse' => 'email_home',
+                       'E-Mail 2: Adresse'     => array('comms', 'home email'),
                        'E-Mail 2: Angezeigter Name' => '',
-                       'E-Mail 3: Adresse' => '',
+                       'E-Mail 3: Adresse'     => '',
                        'E-Mail 3: Angezeigter Name' => '',
-                       'Empfohlen von' => '',
-                       'Geburtstag' => 'bday',
-                       'Geschlecht' => '',
-                       'Hobby' => '',
-                       'Initialen' => '',
+                       'Empfohlen von'         => '',
+                       'Geburtstag'            => array('person', 'birthday'),
+                       'Geschlecht'            => '',
+                       'Hobby'                 => '',
+                       'Initialen'             => '',
                        'Internet-Frei/Gebucht' => '',
-                       'Jahrestag' => '',
-                       'Kategorien' => '',
-                       'Kinder' => '',
-                       'Konto' => '',
-                       'Name Assistent' => '',
+                       'Jahrestag'             => '',
+                       'Kategorien'            => '',
+                       'Kinder'                => '',
+                       'Konto'                 => '',
+                       'Name Assistent'        => '',
                        'Name des/der Vorgesetzten' => '',
-                       'Notizen' => 'note',
-                       'Organisations-Nr.' => '',
-                       'Ort' => '',
-                       'Partner' => '',
-                       'Postfach' => '',
-                       'Priorität' => '',
-                       'Privat' => '',
-                       'Regierungs-Nr.' => '',
-                       'Reisekilometer' => '',
-                       'Sprache' => '',
-                       'Stichwörter' => '',
-                       'Vertraulichkeit' => '',
-                       'Verzeichnisserver' => '',
-                       'Webseite' => 'url'
+                       'Notizen'               => array('notes', 'note', 
'general'),
+                       'Organisations-Nr.'     => '',
+                       'Ort'                   => '',
+                       'Partner'               => '',
+                       'Postfach'              => '',
+                       'Priorität'             => '',
+                       'Privat'                => '',
+                       'Regierungs-Nr.'        => '',
+                       'Reisekilometer'        => '',
+                       'Sprache'               => '',
+                       'Stichwörter'           => '',
+                       'Vertraulichkeit'       => '',
+                       'Verzeichnisserver'     => '',
+                       'Webseite'              => array('comms', 'website')
                );

                function import_start_file($buffer)
                {
-                       return $buffer;
+//                     return $buffer;
                }

                function import_start_record($buffer)
                {
-                       $top=array();
-                       ++$this->id;
-                       $this->currentrecord = $top;
-                       return $buffer;
+//                     $top=array();
+//                     ++$this->id;
+//                     $this->currentrecord = $top;
+//                     return $buffer;
                }

                function import_new_attrib($buffer,$name,$value)
@@ -138,42 +138,65 @@
                        $value = trim($value);
                        $value = str_replace('\n','<BR>',$value);
                        $value = str_replace('\r','',$value);
-                       $this->currentrecord += array($name => $value);
+//                     $this->currentrecord += array($name => $value);
+
+//                     return $buffer;

-                       return $buffer;
+                       $method = $name[0];
+                       $element = $name[1];
+                       $args = $name[2];
+
+                       $this->$method($element, $value, $args);
                }

                function import_end_record($buffer)
                {
-                       $buffer[$this->id]='';
-                       while ( list($name, $value) = 
each($this->currentrecord))
-                       {
-                               $buffer[$this->id][$name] = $value;
-                               //echo '<br>'.$name.' => '.$value;
-                       }
-                       return $buffer;
+//                     $buffer[$this->id]='';
+//                     while ( list($name, $value) = 
each($this->currentrecord))
+//                     {
+//                             $buffer[$this->id][$name] = $value;
+//                             //echo '<br>'.$name.' => '.$value;
+//                     }
+//                     return $buffer;
+
+                       $this->record_set[] = $this->record;
+                       $this->record = array();
                }

                function import_end_file($buffer,$access='private',$cat_id=0)
                {
-                       $contacts = CreateObject('phpgwapi.contacts');
-                       //echo '<br>';
-                       for ($i=1;$i<=count($buffer);$i++)
+//                     echo '<pre>';
+//                     print_r($this->record_set);
+//                     echo '</pre>';
+
+                       $contacts = CreateObject('phpgwapi.contacts');
+
+                       $num = count($this->record_set);
+                       foreach($this->record_set as $contact)
                        {
-                               while ( list($name,$value) = @each($buffer[$i]) 
)
-                               {
-                                       //echo '<br>'.$i.': '.$name.' => 
'.$value;
-                                       $entry[$i][$name] = $value;
-                               }
-                               $entry[$i]['email_type']      = 'INTERNET';
-                               $entry[$i]['email_home_type'] = 'INTERNET';
-                               $entry[$i]['adr_one_type']    = 'intl';
-                               $entry[$i]['adr_two_type']    = 'intl';
-                               //echo '<br>';
-                               
$contacts->add($GLOBALS['phpgw_info']['user']['account_id'],$entry[$i],$access,$cat_id);
+                               $contact['categories'] = array($cat_id);
+                               $contacts->contact_import($contact);
                        }
-                       $num = $i - 1;
-                       return lang('Successfully imported x records into your 
addressbook.',$num);
+                       return lang('Successfully imported %1 records into your 
addressbook.',$num);
+
+//                     $contacts = CreateObject('phpgwapi.contacts');
+//                     //echo '<br>';
+//                     for ($i=1;$i<=count($buffer);$i++)
+//                     {
+//                             while ( list($name,$value) = @each($buffer[$i]) 
)
+//                             {
+//                                     //echo '<br>'.$i.': '.$name.' => 
'.$value;
+//                                     $entry[$i][$name] = $value;
+//                             }
+//                             $entry[$i]['email_type']      = 'INTERNET';
+//                             $entry[$i]['email_home_type'] = 'INTERNET';
+//                             $entry[$i]['adr_one_type']    = 'intl';
+//                             $entry[$i]['adr_two_type']    = 'intl';
+//                             //echo '<br>';
+//                             
$contacts->add($GLOBALS['phpgw_info']['user']['account_id'],$entry[$i],$access,$cat_id);
+//                     }
+//                     $num = $i - 1;
+//                     return lang('Successfully imported x records into your 
addressbook.',$num);
                }
        }
 ?>

====================================================
Index: addressbook/inc/import/Import_from_Netscape
diff -u addressbook/inc/import/Import_from_Netscape:1.2 
addressbook/inc/import/Import_from_Netscape:1.3
--- addressbook/inc/import/Import_from_Netscape:1.2     Tue Dec  4 01:17:10 2001
+++ addressbook/inc/import/Import_from_Netscape Fri Dec 31 04:55:24 2004
@@ -16,33 +16,35 @@
   Also start with a '#' symbol and a comma separated list will be
   turned into a number of the same entries.
 */
-       class import_conv
+       
include_once(PHPGW_INCLUDE_ROOT.'/addressbook/inc/class.addressbook_importer.inc.php');
+       class import_conv extends addressbook_importer
        {
                var $currentrecord = array(); /* used for buffering to allow 
uid lines to go first */
                var $id;
                var $type = 'ldif';

                var $import = array(
-                       'title'            => 'title',
-                       'givenname'        => 'n_given',
-                       'sn'               => 'n_family',
-                       'cn'               => 'fn',
-                       'o'                => 'org_name',
-                       'ou'               => 'org_unit',
-                       'streetaddress'    => 'adr_one_street',
-                       'locality'         => 'adr_one_locality',
-                       'st'               => 'adr_one_region',
-                       'postalcode'       => 'adr_one_postalcode',
-                       'countryname'      => 'adr_one_countryname',
-                       'telephonenumber'  => 'tel_work',
-                       'homephone'        => 'tel_home',
-                       'facsimiletelephonenumber' => 'tel_fax',
-                       'xmozillaanyphone' => 'ophone',
-                       'cellphone'        => 'tel_cell',
-                       'description'      => 'note',
-                       'pagerphone'       => 'tel_pager',
-                       'mail'             => 'email',
-                       'homeurl'          => 'url',
+                       'title'            => array('person', 'title'),
+                       'givenname'        => array('person', 'first_name'),
+                       'sn'               => array('person', 'last_name'),
+                       'cn'               => '',
+                       'o'                => '',
+                       'ou'               => array('person', 'department'),
+                       'streetaddress'    => array('location', 'add1', 'work'),
+                       'locality'         => array('location', 'city', 'work'),
+                       'st'               => array('location', 'state', 
'work'),
+                       'postalcode'       => array('location', 'postal_code', 
'work'),
+                       'countryname'      => array('location', 'country', 
'work'),
+                       'telephonenumber'  => array('comms', 'work phone'),
+                       'homephone'        => array('comms', 'home phone'),
+                       'facsimiletelephonenumber' => array('comms', 'work 
fax'),
+                       // ophone will be an other field
+                       'xmozillaanyphone' => array('comms', 'voice phone'),
+                       'cellphone'        => array('comms', 'mobile (cell) 
phone'),
+                       'pagerphone'       => array('comms', 'pager'),
+                       'mail'             => array('comms', 'work email'),
+                       'homeurl'          => array('comms', 'website'),
+                       'description'      => array('notes', 'note', 'general'),
                        'xmozillauseconferenceserver' => '',
                        'xmozillanickname' => '',
                        'xmozillausehtmlmail' => '',
@@ -52,59 +54,41 @@

                function import_start_file($buffer)
                {
-                       return $buffer;
                }

                function import_start_record($buffer)
                {
-                       $top=array();
-                       ++$this->id;
-                       $this->currentrecord = $top;
-                       return $buffer;
                }

                function import_new_attrib($buffer,$name,$value)
                {
-                       /* chop leading space from value */
                        $value = trim($value);
                        $value = str_replace('\r','',$value);
-                       /* echo '<br>'.$name.' => '.$value; */
-                       $this->currentrecord += array($name => $value);

-                       return $buffer;
+                       $method = $name[0];
+                       $element = $name[1];
+                       $args = $name[2];
+
+                       $this->$method($element, $value, $args);
                }

                function import_end_record($buffer)
                {
-                       $buffer[$this->id]='';
-                       while ( list($name, $value) = 
each($this->currentrecord))
-                       {
-                               $buffer[$this->id][$name] = $value;
-                               /* echo '<br>'.$this->id.': '.$name.' => 
'.$value; */
-                       }
-                       return $buffer;
+                       $this->record_set[] = $this->record;
+                       $this->record = array();
                }

                function import_end_file($buffer,$access='private',$cat_id=0)
                {
-                       $contacts = CreateObject('phpgwapi.contacts');
-                       /* echo '<br>'; */
-                       for ($i=1;$i<=count($buffer);$i++)
+                       $contacts = CreateObject('phpgwapi.contacts');
+
+                       $num = count($this->record_set);
+                       foreach($this->record_set as $contact)
                        {
-                               while ( list($name,$value) = @each($buffer[$i]) 
)
-                               {
-                                       /* echo '<br>'.$i.': '.$name.' => 
'.$value; */
-                                       $entry[$i][$name] = $value;
-                               }
-                               $entry[$i]['email_type']      = 'INTERNET';
-                               $entry[$i]['email_home_type'] = 'INTERNET';
-                               $entry[$i]['adr_one_type']    = 'intl';
-                               $entry[$i]['adr_two_type']    = 'intl';
-                               /* echo '<br>'; */
-                               
$contacts->add($GLOBALS['phpgw_info']['user']['account_id'],$entry[$i],$access,$cat_id);
+                               $contact['categories'] = array($cat_id);
+                               $contacts->contact_import($contact);
                        }
-                       $num = $i - 1;
-                       return lang('Successfully imported x records into your 
addressbook.',$num);
+                       return lang('Successfully imported %1 records into your 
addressbook.',$num);
                }
        }
 ?>

====================================================
Index: addressbook/inc/import/Import_Multiple_VCard
diff -u addressbook/inc/import/Import_Multiple_VCard:1.2 
addressbook/inc/import/Import_Multiple_VCard:1.3
--- addressbook/inc/import/Import_Multiple_VCard:1.2    Tue Dec  4 01:17:10 2001
+++ addressbook/inc/import/Import_Multiple_VCard        Fri Dec 31 04:55:24 2004
@@ -47,11 +47,8 @@

                function import_new_attrib($buffer,$name,$value)
                {
-                       $value = trim($value);
-                       $value = ereg_replace('=0D=0A','\n',$value);
-                       /* echo '<br>'.$this->id.': '.$name.' => '.$value; */
-                       $this->currentrecord += array($name => $value);
-
+                       $line = $name . ':' . $value;
+                       $this->currentrecord += 
$this->vcard->parse_vcard_line($line);
                        return $buffer;
                }

@@ -77,11 +74,15 @@
                                   bogus values that get stuffed in.
                                */
                                $entry = $this->vcard->in($buffer[$i]);
+                               $entry['owner'] = 
$GLOBALS['phpgw_info']['user']['account_id'];
+                               $entry['access'] = $access;
+                               $entry['categories'] = array($cat_id);
+
                                /* Now actually add the new entry */
-                               
$this->contacts->add($GLOBALS['phpgw_info']['user']['account_id'],$entry,$access,$cat_id);
+                               $ab_id = 
$this->contacts->contact_import($entry);
                        }
                        $num = $i - 1;
-                       return lang('Successfully imported x records into your 
addressbook.',$num);
+                       return lang('Successfully imported %1 records into your 
addressbook.',$num);
                }
        }
 ?>






reply via email to

[Prev in Thread] Current Thread [Next in Thread]