[ 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 export 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 class export_conv 20 { 21 var $currentrecord = array(); /* used for buffering to allow uid lines to go first */ 22 var $id; 23 /* list of all id's */ 24 var $ids = array(); 25 var $type = 'vcard'; 26 27 /* This will store the contacts and vcard objects */ 28 var $contacts = ''; 29 var $vcard = ''; 30 /* This will be filled by the vcard object */ 31 var $export = array(); 32 33 /* make sure to order how we ask for these */ 34 var $qfields = array( 35 'fn' => 'fn', 36 'n_given' => 'n_given', 37 'n_family' => 'n_family', 38 'n_middle' => 'n_middle', 39 'n_prefix' => 'n_prefix', 40 'n_suffix' => 'n_suffix', 41 'sound' => 'sound', 42 'bday' => 'bday', 43 'note' => 'note', 44 'tz' => 'tz', 45 'geo' => 'geo', 46 'url' => 'url', 47 'pubkey' => 'pubkey', 48 'org_name' => 'org_name', 49 'org_unit' => 'org_unit', 50 'title' => 'title', 51 52 'adr_one_type' => 'adr_one_type', 53 'adr_two_type' => 'adr_two_type', 54 'tel_prefer' => 'tel_prefer', 55 'email_type' => 'email_type', 56 'email_home_type' => 'email_home_type', 57 58 'adr_one_street' => 'adr_one_street', 59 'adr_one_locality' => 'adr_one_locality', 60 'adr_one_region' => 'adr_one_region', 61 'adr_one_postalcode' => 'adr_one_postalcode', 62 'adr_one_countryname' => 'adr_one_countryname', 63 'label' => 'label', 64 65 'adr_two_street' => 'adr_two_street', 66 'adr_two_locality' => 'adr_two_locality', 67 'adr_two_region' => 'adr_two_region', 68 'adr_two_postalcode' => 'adr_two_postalcode', 69 'adr_two_countryname' => 'adr_two_countryname', 70 71 'tel_work' => 'tel_work', 72 'tel_home' => 'tel_home', 73 'tel_voice' => 'tel_voice', 74 'tel_fax' => 'tel_fax', 75 'tel_msg' => 'tel_msg', 76 'tel_cell' => 'tel_cell', 77 'tel_pager' => 'tel_pager', 78 'tel_bbs' => 'tel_bbs', 79 'tel_modem' => 'tel_modem', 80 'tel_car' => 'tel_car', 81 'tel_isdn' => 'tel_isdn', 82 'tel_video' => 'tel_video', 83 'email' => 'email', 84 'email_home' => 'email_home' 85 ); 86 87 /* Read full list of user's contacts only to get id's for each */ 88 function export_start_file($buffer,$ncat_id='') 89 { 90 $this->id=-1; 91 if ($ncat_id) 92 { 93 $filter = 'tid=n,cat_id='.$ncat_id; 94 } 95 else 96 { 97 $filter = 'tid=n'; 98 } 99 /* Setup the contact and vcard objects, and the export fields var */ 100 $this->contacts = CreateObject('phpgwapi.contacts'); 101 $this->vcard = CreateObject('phpgwapi.vcard'); 102 $this->export = $this->vcard->export; 103 104 $tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter); 105 for ($i=0;$i<count($tmp);$i++) 106 { 107 $this->ids[$i] = $tmp[$i]['id']; 108 } 109 /* 110 $ids is now an array of all id's for this user, e.g. $ids[0] = 21, etc... 111 $buffer is still empty 112 */ 113 return $buffer; 114 } 115 116 /* Read each entry */ 117 function export_start_record($buffer) 118 { 119 $this->id++; 120 $top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields); 121 $this->currentrecord = $top[0]; 122 return $buffer; 123 } 124 125 /* 126 Read each attribute, populate buffer 127 name/value are the fields from the export array in the vcard class 128 */ 129 function export_new_attrib($buffer,$name,$value) 130 { 131 if ($this->export[$name] && ($value != '') ) 132 { 133 $buffer[$this->id][$this->export[$name]] = $value; 134 /* echo '<br>'.$this->id.' - '.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]]; */ 135 } 136 return $buffer; 137 } 138 139 function export_end_record($buffer) 140 { 141 return $buffer; 142 } 143 144 function export_end_file($buffer) 145 { 146 reset($this->ids); 147 for ($i=0;$i<count($this->ids);$i++) 148 { 149 $vcards .= $this->vcard->out($buffer[$i]); 150 } 151 $buffer = $vcards; 152 return $buffer; 153 } 154 } 155 ?>
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 |