[ 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_Netscape (source)

   1  <?php
   2  /*
   3    This file defines a set of functions and an associative array.
   4    The key of the array corresponds to a header in the source
   5    import file and the value of the array item will be used in
   6    the creation of the output file.
   7  
   8    The array need not be in any order and any fields not defined will
   9    not be transferred.  If the val='+', the value will be appended to
  10    the previous field and any text after the '+' will be appended 
  11    before the value.  For example, the following would add a comma and
  12    a space between LastName and FirstName and store it in FullName:
  13  
  14       array('LastName' => 'FullName','FirstName' => '+, ');
  15  
  16    Also start with a '#' symbol and a comma separated list will be
  17    turned into a number of the same entries.
  18  */
  19  
  20    /* $Id: Import_from_Netscape 18716 2005-07-03 14:15:23Z milosch $ */
  21  
  22      class import_conv
  23      {
  24          var $currentrecord = array(); /* used for buffering to allow uid lines to go first */
  25          var $id;
  26          var $type = 'ldif';
  27  
  28          var $import = array(
  29              'title'            => 'title', 
  30              'givenname'        => 'n_given',
  31              'sn'               => 'n_family',
  32              'cn'               => 'fn',
  33              'o'                => 'org_name',
  34              'ou'               => 'org_unit',
  35              'streetaddress'    => 'adr_one_street',
  36              'locality'         => 'adr_one_locality',
  37              'st'               => 'adr_one_region',
  38              'postalcode'       => 'adr_one_postalcode',
  39              'countryname'      => 'adr_one_countryname',
  40              'telephonenumber'  => 'tel_work',
  41              'homephone'        => 'tel_home',
  42              'facsimiletelephonenumber' => 'tel_fax',
  43              'xmozillaanyphone' => 'ophone',
  44              'cellphone'        => 'tel_cell',
  45              'description'      => 'note',
  46              'pagerphone'       => 'tel_pager',
  47              'mail'             => 'email',
  48              'homeurl'          => 'url',
  49              'xmozillauseconferenceserver' => '',
  50              'xmozillanickname' => '',
  51              'xmozillausehtmlmail' => '',
  52              'modifytimestamp'  => '',
  53              'objectclass'      => ''
  54          );
  55  
  56  		function import_start_file($buffer)
  57          {
  58              return $buffer;
  59          }
  60  
  61  		function import_start_record($buffer)
  62          {
  63              $top = array();
  64              ++$this->id;
  65              $this->currentrecord = $top;
  66              return $buffer;
  67          }
  68  
  69  		function import_new_attrib($buffer,$name,$value)
  70          {
  71              /* chop leading space from value */
  72              $value = trim($value);
  73              $value = str_replace('\r','',$value);
  74              /* echo '<br>'.$name.' => '.$value; */
  75              $this->currentrecord += array($name => $value);
  76  
  77              return $buffer;
  78          }
  79  
  80  		function import_end_record($buffer)
  81          {
  82              $buffer[$this->id] = '';
  83              while(list($name, $value) = each($this->currentrecord))
  84              {
  85                  $buffer[$this->id][$name] = $value;
  86                  /* echo '<br>'.$this->id.': '.$name.' => '.$value; */
  87              }
  88              return $buffer;
  89          }
  90  
  91  		function import_end_file($buffer,$access='private',$cat_id=0)
  92          {
  93              $contacts = CreateObject('phpgwapi.contacts');
  94              /* echo '<br>'; */
  95              for($i=1;$i<=count($buffer);$i++)
  96              {
  97                  while(list($name,$value) = @each($buffer[$i]))
  98                  {
  99                      /* echo '<br>'.$i.': '.$name.' => '.$value; */
 100                      $entry[$i][$name] = $value;
 101                  }
 102                  $entry[$i]['email_type']      = 'INTERNET';
 103                  $entry[$i]['email_home_type'] = 'INTERNET';
 104                  $entry[$i]['adr_one_type']    = 'intl';
 105                  $entry[$i]['adr_two_type']    = 'intl';
 106                  /* echo '<br>'; */
 107                  $contacts->add($GLOBALS['egw_info']['user']['account_id'],$entry[$i],$access,$cat_id);
 108              }
 109              $num = $i - 1;
 110              return lang('Successfully imported %1 records into your addressbook.',$num);
 111          }
 112      }
 113  ?>


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