[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
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_-_Finnish 20005 2005-11-26 13:15:57Z 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 'Tehtävänimike' => 'title', 36 'Etunimi' => 'n_given', 37 'Toinen nimi' => 'n_middle', 38 'Sukunimi' => 'n_family', 39 'Jälkiliite' => 'n_suffix', 40 'Yritys' => 'org_name', 41 'Osasto' => 'org_unit', 42 'Lähiosoite (työ)' => 'adr_one_street', 43 'Lähiosoite (työ) 2' => 'address2', 44 'Lähiosoite (työ) 3' => 'address3', 45 'Postitoimipaikka (työ)' => 'adr_one_locality', 46 'Sijaintitiedot (työ)' => 'adr_one_region', 47 'Postinumero (työ)' => 'adr_one_postalcode', 48 'Maa (työ)' => 'adr_one_country', 49 'Lähiosoite (koti)' => 'adr_two_street', 50 'Postitoimipaikka (koti)' => 'adr_two_locality', 51 'Sijaintitiedot (koti)' => 'adr_two_region', 52 'Postinumero (koti)' => 'adr_two_postalcode', 53 'Maa (koti)' => 'adr_two_country', 54 'Työfaksi' => 'tel_fax', 55 'Työpuhelin' => 'tel_work', 56 'Avustajan puhelinnumero' => 'tel_msg', 57 'Autopuhelin' => 'tel_car', 58 'ISDN' => 'tel_isdn', 59 'Kotipuhelin' => 'tel_home', 60 'Matkapuhelin' => 'tel_cell', 61 'Hakulaite' => 'tel_pager', 62 'Työpuhelin 2' => 'ophone', 63 'Syntymäpäivä' => 'bday', 64 'Sähköpostiosoite' => 'email', 65 'Säköpostiosoite 2' => 'email_home',// Note! Typo error in Finnish Outlook 2003 export addressbook to csv-file! 66 'Web-sivu' => 'url', 67 'Muistilaput' => 'note' 68 ); 69 70 function import_start_file($buffer) 71 { 72 return $buffer; 73 } 74 75 function import_start_record($buffer) 76 { 77 $top = array(); 78 ++$this->id; 79 $this->currentrecord = $top; 80 return $buffer; 81 } 82 83 function import_new_attrib($buffer,$name,$value) 84 { 85 $value = trim($value); 86 $value = str_replace('\n','<BR>',$value); 87 $value = str_replace('\r','',$value); 88 $this->currentrecord += array($name => $value); 89 90 return $buffer; 91 } 92 93 function import_end_record($buffer) 94 { 95 $buffer[$this->id] = ''; 96 while(list($name, $value) = each($this->currentrecord)) 97 { 98 $buffer[$this->id][$name] = $value; 99 //echo '<br>'.$name.' => '.$value; 100 } 101 return $buffer; 102 } 103 104 function import_end_file($buffer,$access='private',$cat_id=0) 105 { 106 $contacts = CreateObject('phpgwapi.contacts'); 107 //echo '<br>'; 108 for($i=1;$i<=count($buffer);$i++) 109 { 110 while(list($name,$value) = @each($buffer[$i])) 111 { 112 //echo '<br>'.$i.': '.$name.' => '.$value; 113 $entry[$i][$name] = $value; 114 } 115 $entry[$i]['email_type'] = 'INTERNET'; 116 $entry[$i]['email_home_type'] = 'INTERNET'; 117 $entry[$i]['adr_one_type'] = 'intl'; 118 $entry[$i]['adr_two_type'] = 'intl'; 119 $entry[$i]['fn'] = $entry[$i]['n_given'] . ' ' . $entry[$i]['n_family']; 120 //echo '<br>'; 121 $contacts->add($GLOBALS['egw_info']['user']['account_id'],$entry[$i],$access,$cat_id); 122 } 123 $num = $i - 1; 124 return lang('Successfully imported %1 records into your addressbook.',$num); 125 } 126 } 127 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |