[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
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_Mozilla 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 'postaladdress' => 'adr_one_street', 37 'mozillaPostalAddress2' => 'address2', 38 'locality' => 'adr_one_locality', 39 'l' => 'adr_one_locality', 40 'st' => 'adr_one_region', 41 'postalcode' => 'adr_one_postalcode', 42 'countryname' => 'adr_one_countryname', 43 'c' => 'adr_one_countryname', 44 'homepostaladdress' => 'adr_two_street', 45 'mozillahomelocalityname' => 'adr_two_locality', 46 'mozillahomestate' => 'adr_two_region', 47 'mozillahomepostalcode' => 'adr_two_postalcode', 48 'mozillahomecountryname' => 'adr_two_countryname', 49 'telephonenumber' => 'tel_work', 50 'homephone' => 'tel_home', 51 'facsimiletelephonenumber' => 'tel_fax', 52 'xmozillaanyphone' => 'ophone', 53 'mobile' => 'tel_cell', 54 'description' => 'note', 55 'pager' => 'tel_pager', 56 'mail' => 'email', 57 'homeurl' => 'url', 58 'workurl' => 'url' 59 ); 60 61 function import_start_file($buffer) 62 { 63 return $buffer; 64 } 65 66 function import_start_record($buffer) 67 { 68 $top = array(); 69 ++$this->id; 70 $this->currentrecord = $top; 71 return $buffer; 72 } 73 74 function import_new_attrib($buffer,$name,$value) 75 { 76 /* chop leading space from value */ 77 $value = trim($value); 78 $value = str_replace('\r','',$value); 79 /* echo '<br>'.$name.' => '.$value; */ 80 $this->currentrecord += array($name => $value); 81 82 return $buffer; 83 } 84 85 function import_end_record($buffer) 86 { 87 $buffer[$this->id] = ''; 88 while(list($name, $value) = each($this->currentrecord)) 89 { 90 $buffer[$this->id][$name] = $value; 91 /* echo '<br>'.$this->id.': '.$name.' => '.$value; */ 92 } 93 return $buffer; 94 } 95 96 function import_end_file($buffer,$access='private',$cat_id=0) 97 { 98 $contacts = CreateObject('phpgwapi.contacts'); 99 /* echo '<br>'; */ 100 for($i=1;$i<=count($buffer);$i++) 101 { 102 while(list($name,$value) = @each($buffer[$i])) 103 { 104 /* echo '<br>'.$i.': '.$name.' => '.$value; */ 105 $entry[$i][$name] = $value; 106 } 107 $entry[$i]['email_type'] = 'INTERNET'; 108 $entry[$i]['email_home_type'] = 'INTERNET'; 109 $entry[$i]['adr_one_type'] = 'intl'; 110 $entry[$i]['adr_two_type'] = 'intl'; 111 /* echo '<br>'; */ 112 $contacts->add($GLOBALS['egw_info']['user']['account_id'],$entry[$i],$access,$cat_id); 113 } 114 $num = $i - 1; 115 return lang('Successfully imported %1 records into your addressbook.',$num); 116 } 117 } 118 ?>
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 |