[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/addressbook/inc/import/ -> Import_from_Outlook_-_English (source)

   1  <?php
   2  // This file defines a set of functions and an associative array.
   3  // The key of the array corresponds to a header in the source
   4  // import file and the value of the array item will be used in
   5  // the creation of the output file.
   6  //
   7  // An exported Outlook file looks like this:
   8  //
   9  // Title<tab>First Name<tab>Middle Name<tab>Last Name<tab>...
  10  // <tab>Patrick<tab><tab>Walsh<tab>...
  11  //
  12  // Where the first line explains each optional field.  This is what
  13  // will be looked up in the key.
  14  //
  15  // The array need not be in any order and any fields not defined will
  16  // not be transferred.  If the val='+', the value will be appended to
  17  // the previous field and any text after the '+' will be appended
  18  // before the value.  For example, the following would add a comma and
  19  // a space between LastName and FirstName and store it in FullName:
  20  //
  21  //    array('LastName' => 'FullName','FirstName' => '+, ');
  22  //
  23  // Also start with a '#' symbol and a comma separated list will be
  24  // turned into a number of the same entries.
  25  
  26    /* $Id: Import_from_Outlook_-_English 18716 2005-07-03 14:15:23Z milosch $ */
  27  
  28      class import_conv
  29      {
  30          var $currentrecord = array(); //used for buffering to allow uid lines to go first
  31          var $id;
  32          var $type = 'csv';
  33  
  34          var $import = array(
  35              'Title' => 'n_prefix',
  36              'First Name' => 'n_given',
  37              'Middle Name' => 'n_middle',
  38              'Last Name' => 'n_family',
  39              'Suffix' => 'n_suffix',
  40              'Company' => 'org_name',  //objectclass: organization
  41              'Department' => 'org_unit', //objectclass: organizationalPerson
  42              'Job Title' => 'title', //objectclass: organizationalPerson
  43              'Business Street' => 'adr_one_street',
  44              'Business Street 2' => 'address2',
  45              'Business Street 3' => 'address3',
  46              'Business City' => 'adr_one_locality',
  47              'Business State' => 'adr_one_region',
  48              'Business Postal Code' => 'adr_one_postalcode',
  49              'Business Country' => 'adr_one_countryname',
  50              'Home Street' => 'adr_two_street',
  51              'Home City' => 'adr_two_locality',
  52              'Home State' => 'adr_two_region',
  53              'Home Postal Code' => 'adr_two_postalcode',
  54              'Home Country' => 'adr_two_countryname',
  55              'Home Street 2' => '',
  56              'Home Street 3' => '',
  57              'Other Street' => '',
  58              'Other City' => '',
  59              'Other State' => '',
  60              'Other Postal Code' => '',
  61              'Other Country' => '',
  62              "Assistant's Phone" => 'tel_msg',
  63              'Business Fax' => 'tel_fax',
  64              'Business Phone' => 'tel_work',
  65              'Business Phone 2' => 'ophone',
  66              'Callback' => '',
  67              'Car Phone' => 'tel_car',
  68              'Company Main Phone' => '',
  69              'Home Fax' => '',
  70              'Home Phone' => 'tel_home',
  71              'Home Phone 2' => '', //This will make another homePhone entry
  72              'ISDN' => 'tel_isdn',
  73              'Mobile Phone' => 'tel_cell', //newPilotPerson
  74              'Other Fax' => '',
  75              'Other Phone' => '',
  76              'Pager' => 'tel_pager',
  77              'Primary Phone' => '',
  78              'Radio Phone' => '',
  79              'TTY/TDD Phone' => '',
  80              'Telex' => '', //organization
  81              'Account' => '',
  82              'Anniversary' => '',
  83              "Assistant's Name" => '', //newPilotPerson
  84              'Billing Information' => '',
  85              'Birthday' => 'bday',
  86              'Categories' => '',
  87              'Children' => '',
  88              'Directory Server' => '',
  89              'E-mail Address' => 'email',
  90              'E-mail Display Name' => '',
  91              'E-mail 2 Address' => 'email_home',
  92              'E-mail 2 Display Name' => '',
  93              'E-mail 3 Address' => '', //add another...
  94              'E-mail 3 Display Name' => '',
  95              'Gender' => '',
  96              'Government ID Number' => '',
  97              'Hobby' => '',
  98              'Initials' => '',
  99              'Internet Free Busy' => '',
 100              'Keywords' => '',
 101              'Language' => '',
 102              'Location' => '',
 103              "Manager's Name" => '',
 104              'Mileage' => '',
 105              'Notes' => 'note',
 106              'Office Location' => '',
 107              'Organizational ID Number' => '',
 108              'PO Box' => '',
 109              'Priority' => '',
 110              'Private Profession' => '',
 111              'Referred By' => '',
 112              'Sensitivity' => '',
 113              'Spouse' => '',
 114              'User 1' => '',
 115              'User 2' => '',
 116              'User 3' => '',
 117              'User 4' => '',
 118              'Web Page' => 'url'
 119          );
 120  
 121  		function import_start_file($buffer)
 122          {
 123              return $buffer;
 124          }
 125  
 126  		function import_start_record($buffer)
 127          {
 128              $top = array();
 129              ++$this->id;
 130              $this->currentrecord = $top;
 131              return $buffer;
 132          }
 133  
 134  		function import_new_attrib($buffer,$name,$value)
 135          {
 136              $value = trim($value);
 137              $value = str_replace('\n','<BR>',$value);
 138              $value = str_replace('\r','',$value);
 139              $this->currentrecord += array($name => $value);
 140  
 141              return $buffer;
 142          }
 143  
 144  		function import_end_record($buffer)
 145          {
 146              $buffer[$this->id] = '';
 147              while(list($name, $value) = each($this->currentrecord))
 148              {
 149                  $buffer[$this->id][$name] = $value;
 150                  //echo '<br>'.$name.' => '.$value;
 151              }
 152              return $buffer;
 153          }
 154  
 155  		function import_end_file($buffer,$access='private',$cat_id=0)
 156          {
 157              $contacts = CreateObject('phpgwapi.contacts');
 158              //echo '<br>';
 159              for($i=1;$i<=count($buffer);$i++)
 160              {
 161                  while(list($name,$value) = @each($buffer[$i]))
 162                  {
 163                      //echo '<br>'.$i.': '.$name.' => '.$value;
 164                      $entry[$i][$name] = $value;
 165                  }
 166                  $entry[$i]['email_type']      = 'INTERNET';
 167                  $entry[$i]['email_home_type'] = 'INTERNET';
 168                  $entry[$i]['adr_one_type']    = 'intl';
 169                  $entry[$i]['adr_two_type']    = 'intl';
 170                  $entry[$i]['fn'] = $entry[$i]['n_given'] . ' ' . $entry[$i]['n_family'];
 171                  //echo '<br>';
 172                  $contacts->add($GLOBALS['egw_info']['user']['account_id'],$entry[$i],$access,$cat_id);
 173              }
 174              $num = $i - 1;
 175              return lang('Successfully imported %1 records into your addressbook.',$num);
 176          }
 177      }
 178  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7