Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
usercard_csv2vcard.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Generated Header (not documented yet)
9  *
10  * @author Anakeen 2000
11  * @version $Id: usercard_csv2vcard.php,v 1.6 2008/08/14 09:59:14 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 // remove all tempory doc and orphelines values
19 include_once ("FDL/Class.Doc.php");
20 include_once ("FDL/Class.UsercardVcard.php");
21 
22 $fimport = GetHttpVars("ifile"); // file to convert
23 $fvcf = GetHttpVars("ofile", "php://stdin"); // output file
25 $appl->Set("USERCARD", $core);
26 
27 $dbaccess = $appl->GetParam("FREEDOM_DB");
28 if ($dbaccess == "") {
29  print "Database not found : param FREEDOM_DB";
30  exit;
31 }
32 
34 
35 $lattr = $doc->GetNormalAttributes();
36 $format = "DOC;" . $doc->id . ";<special id>;<special dirid>; ";
37 
38 while (list($k, $attr) = each($lattr)) {
39  $format.= $attr->getLabel() . " ;";
40 }
41 //print_r( $lattr);;
43 
44 $fdoc = fopen($fimport, "r");
45 
46 $deffam = $action->GetParam("DEFAULT_FAMILY", getFamIdFromName($dbaccess, "USER"));
47 
48 $usercard->open($fvcf, "w");
49 while ($data = fgetcsv($fdoc, 1000, ";")) {
50  $num = count($data);
51  if ($data[0] != "DOC") continue;
52  if ($data[1] != $deffam) continue;
53 
54  $attr = array();
55  reset($data);
56  //array_shift($data);array_shift($data);array_shift($data);array_shift($data);
57  while (list($k, $v) = each($data)) {
58  if ($k > 3) $attr[$lattr[$k - 4]->id] = $v;
59  }
60 
61  $usercard->WriteCard($attr["us_lname"] . " " . $attr["us_fname"], $attr);
62 }
63 ?>
← centre documentaire © anakeen - published under CC License - Dynacase