Ejemplo n.º 1
0
 function export($conv_type, $cat_id = '', $both_types = '', $sub_cats = '')
 {
     include PHPGW_APP_INC . '/export/' . $conv_type;
     $buffer = array();
     $contacts = new export_conv();
     // Note our use of ===.  Simply == would not work as expected
     if (strpos($conv_type, 'OpenOffice') === false) {
         // Read in user custom fields, if any
         $customfields = array();
         while (list($col, $descr) = @each($GLOBALS['phpgw_info']['user']['preferences']['addressbook'])) {
             if (substr($col, 0, 6) == 'extra_') {
                 $field = preg_replace('/extra_/', '', $col);
                 $field = preg_replace('/ /', '_', $field);
                 $customfields[$field] = ucfirst($field);
             }
         }
         if (!empty($cat_id)) {
             $buffer = $contacts->export_start_file($buffer, $cat_id);
         } else {
             $buffer = $contacts->export_start_file($buffer);
         }
         for ($i = 0; $i < count($contacts->ids); $i++) {
             $buffer = $contacts->export_start_record($buffer);
             while (list($name, $value) = each($contacts->currentrecord)) {
                 $buffer = $contacts->export_new_attrib($buffer, $name, $value);
             }
             $buffer = $contacts->export_end_record($buffer);
         }
         // Here, buffer becomes a string suitable for printing
         $buffer = $contacts->export_end_file($buffer);
         $tsvfilename = "{$GLOBALS['phpgw_info']['server']['temp_dir']}/{$tsvfilename}";
     } else {
         //echo "<pre>here1  $both_types $sub_cats</pre>";
         $tsvfilename = $contacts->do_it($both_types, $sub_cats);
         $buffer = $tsvfilename;
     }
     return $buffer;
 }