Moving these, also adding seperate lang versions of cvs import

This commit is contained in:
Miles Lott 2001-07-08 13:57:04 +00:00
parent 03348f7b0d
commit a9b7ad66d8
9 changed files with 1341 additions and 0 deletions

View File

@ -0,0 +1,153 @@
<?php
/*
This file defines a set of functions and an associative array.
The key of the array corresponds to a header in the source
export file and the value of the array item will be used in
the creation of the output file.
The array need not be in any order and any fields not defined will
not be transferred. If the val='+', the value will be appended to
the previous field and any text after the '+' will be appended
before the value. For example, the following would add a comma and
a space between LastName and FirstName and store it in FullName:
array("LastName" => "FullName","FirstName" => "+, ");
Also start with a '#' symbol and a comma separated list will be
turned into a number of the same entries.
*/
class export_conv
{
var $currentrecord = array(); /* used for buffering to allow uid lines to go first */
var $id;
/* list of all id's */
var $ids = array();
var $type = 'vcard';
/* This will store the contacts and vcard objects */
var $contacts = '';
var $vcard = '';
/* This will be filled by the vcard object */
var $export = array();
/* make sure to order how we ask for these */
var $qfields = array(
'fn' => 'fn',
'n_given' => 'n_given',
'n_family' => 'n_family',
'n_middle' => 'n_middle',
'n_prefix' => 'n_prefix',
'n_suffix' => 'n_suffix',
'sound' => 'sound',
'bday' => 'bday',
'note' => 'note',
'tz' => 'tz',
'geo' => 'geo',
'url' => 'url',
'pubkey' => 'pubkey',
'org_name' => 'org_name',
'org_unit' => 'org_unit',
'title' => 'title',
'adr_one_type' => 'adr_one_type',
'adr_two_type' => 'adr_two_type',
'tel_prefer' => 'tel_prefer',
'email_type' => 'email_type',
'email_home_type' => 'email_home_type',
'adr_one_street' => 'adr_one_street',
'adr_one_locality' => 'adr_one_locality',
'adr_one_region' => 'adr_one_region',
'adr_one_postalcode' => 'adr_one_postalcode',
'adr_one_countryname' => 'adr_one_countryname',
'label' => 'label',
'adr_two_street' => 'adr_two_street',
'adr_two_locality' => 'adr_two_locality',
'adr_two_region' => 'adr_two_region',
'adr_two_postalcode' => 'adr_two_postalcode',
'adr_two_countryname' => 'adr_two_countryname',
'tel_work' => 'tel_work',
'tel_home' => 'tel_home',
'tel_voice' => 'tel_voice',
'tel_fax' => 'tel_fax',
'tel_msg' => 'tel_msg',
'tel_cell' => 'tel_cell',
'tel_pager' => 'tel_pager',
'tel_bbs' => 'tel_bbs',
'tel_modem' => 'tel_modem',
'tel_car' => 'tel_car',
'tel_isdn' => 'tel_isdn',
'tel_video' => 'tel_video',
'email' => 'email',
'email_home' => 'email_home'
);
/* This will store the contacts and vcard objects */
var $contacts = '';
var $vcard = '';
/* Read full list of user's contacts only to get id's for each */
function export_start_file($buffer,$ncat_id='')
{
$this->id=-1;
if ($ncat_id) { $filter = 'tid=n,cat_id='.$ncat_id; }
else { $filter = 'tid=n'; }
/* Setup the contact and vcard objects, and the export fields var */
$this->contacts = CreateObject('phpgwapi.contacts');
$this->vcard = CreateObject('phpgwapi.vcard');
$this->export = $this->vcard->export;
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);
for ($i=0;$i<count($tmp);$i++)
{
$this->ids[$i] = $tmp[$i]['id'];
}
/*
$ids is now an array of all id's for this user, e.g. $ids[0] = 21, etc...
$buffer is still empty
*/
return $buffer;
}
/* Read each entry */
function export_start_record($buffer)
{
$this->id++;
$top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0];
return $buffer;
}
/*
Read each attribute, populate buffer
name/value are the fields from the export array in the vcard class
*/
function export_new_attrib($buffer,$name,$value)
{
if ($this->export[$name] && ($value != '') )
{
$buffer[$this->id][$this->export[$name]] = $value;
/* echo '<br>'.$this->id.' - '.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]]; */
}
return $buffer;
}
function export_end_record($buffer)
{
return $buffer;
}
function export_end_file($buffer)
{
reset($this->ids);
for ($i=0;$i<count($this->ids);$i++)
{
$vcards .= $this->vcard->out($buffer[$i]);
}
$buffer = $vcards;
return $buffer;
}
}
?>

View File

@ -0,0 +1,149 @@
<?php
// This file defines a set of functions and an associative array.
// The key of the array corresponds to a header in the source
// export file and the value of the array item will be used in
// the creation of the output file.
//
// The array need not be in any order and any fields not defined will
// not be transferred. If the val='+', the value will be appended to
// the previous field and any text after the '+' will be appended
// before the value. For example, the following would add a comma and
// a space between LastName and FirstName and store it in FullName:
//
// array("LastName" => "FullName","FirstName" => "+, ");
//
// Also start with a '#' symbol and a comma separated list will be
// turned into a number of the same entries.
class export_conv
{
var $currentrecord = array(); //used for buffering to allow uid lines to go first
var $id;
//list of all id's
var $ids = array();
var $type = 'ldif';
var $export= array(
'title' => 'title',
'n_given' => 'givenname',
'n_family' => 'sn',
'fn' => 'cn',
'org_name' => 'o',
'org_unit' => 'ou',
'adr_one_street' => 'streetaddress',
'adr_one_locality' => 'locality',
'adr_one_region' => 'st',
'adr_one_postalcode' => 'postalcode',
'adr_one_countryname' => 'countryname',
'tel_work' => 'telephonenumber',
'tel_home' => 'homephone',
'tel_fax' => 'facsimiletelephonenumber',
'ophone' => 'xmozillaanyphone',
'tel_cell' => 'cellphone',
'note' => 'description',
'ophone' => 'ophone',
'tel_pager' => 'pagerphone',
'email' => 'mail',
'url' => 'homeurl',
);
// This will store the contacts object
var $contacts = '';
// Read full list of user's contacts only to get id's for each
function export_start_file($buffer,$ncat_id='')
{
$this->id=-1;
if ($ncat_id) { $filter = "tid=n,cat_id=".$ncat_id; }
else { $filter = "tid=n"; }
$this->contacts = CreateObject('phpgwapi.contacts');
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);
for ($i=0;$i<count($tmp);$i++)
{
$this->ids[$i] = $tmp[$i]['id'];
}
// $ids is now an array of all id's for this user, e.g. $ids[0] = 21, etc...
// $buffer is still empty
return $buffer;
}
// Read each entry
function export_start_record($buffer)
{
$this->id++;
$top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0];
return $buffer;
}
// Read each attribute, populate buffer
// name/value are the fields from the export array above
function export_new_attrib($buffer,$name,$value)
{
if ($this->export[$name])
{
if (strstr($value,"\n"))
{
$value = ': '.base64_encode($value);
}
else
{
$value = ' '.$value;
}
$buffer[$this->id][$this->export[$name]] = $value;
//echo '<br>'.$this->id.' - '.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]];
}
return $buffer;
}
// Tack on some extra values
function export_end_record($buffer)
{
$buffer[$this->id]['dn'] = 'cn='.$buffer[$this->id]['cn'].',mail='.$buffer[$this->id]['mail'];
$buffer[$this->id]['xmozillauseconferenceserver'] = '0';
$buffer[$this->id]['xmozillanickname'] = '';
$buffer[$this->id]['xmozillausehtmlmail'] = 'False';
if ($buffer[$this->id]['ophone'])
{
$buffer[$this->id]['xmozillaanyphone'] = $buffer[$this->id]['ophone'];
}
else
{
$buffer[$this->id]['xmozillaanyphone'] = $buffer[$this->id]['telephonenumber'];
}
//echo '<br>'.$this->id.' - '.$buffer[$this->id]['dn'];
return $buffer;
}
function export_end_file($buffer)
{
reset($this->ids);
for ($i=0;$i<count($this->ids);$i++)
{
$entries .= 'dn: ' . $buffer[$i]['dn'] . "\n";
reset($this->export);
while (list($name,$value)=each($this->export))
{
if ($value != 'dn')
{
$entries .= $value . ":" . $buffer[$i][$value] . "\n";
}
}
$entries .= 'xmozillauseconferenceserver: ' . $buffer[$i]['xmozillauseconferenceserver'] . "\n";
$entries .= 'xmozillanickname: ' . $buffer[$i]['xmozillanickname'] . "\n";
$entries .= 'xmozillausehtmlmail: ' . $buffer[$i]['xmozillausehtmlmail'] . "\n";
$entries .= 'xmozillaanyphone: ' . $buffer[$i]['xmozillaanyphone'] . "\n";
$entries .= 'objectClass: person' . "\n";
$entries .= 'objectClass: account' . "\n";
$entries .= 'objectClass: organizationalPerson' . "\n";
$entries .= 'objectClass: posixAccount' . "\n";
$entries .= 'objectClass: inetOrgPerson' . "\n";
$entries .= 'objectClass: shadowAccount' . "\n";
$entries .= "\n";
}
$buffer = $entries;
return $buffer;
}
}
?>

View File

@ -0,0 +1,133 @@
<?php
// This file defines a set of functions and an associative array.
// The key of the array corresponds to a header in the source
// export file and the value of the array item will be used in
// the creation of the output file.
//
// The array need not be in any order and any fields not defined will
// not be transferred. If the val='+', the value will be appended to
// the previous field and any text after the '+' will be appended
// before the value. For example, the following would add a comma and
// a space between LastName and FirstName and store it in FullName:
//
// array("LastName" => "FullName","FirstName" => "+, ");
//
// Also start with a '#' symbol and a comma separated list will be
// turned into a number of the same entries.
class export_conv
{
var $currentrecord = array(); //used for buffering to allow uid lines to go first
var $id;
//list of all id's
var $ids = array();
var $type = 'pdb';
var $export = array(
'title' => 'Title',
'n_given' => 'First',
'n_middle' => 'Middle',
'n_family' => 'Last',
'n_suffix' => 'Suffix',
'org_name' => 'Company',
'org_unit' => 'Dept',
'adr_one_street' => 'Bus. Street',
'address2' => 'Bus. St. 2',
'address3' => 'Bus. St. 3',
'adr_one_locality' => 'Bus. City',
'adr_one_region' => 'Bus. State',
'adr_one_postalcode' => 'Bus. Postal Code',
'adr_one_countryname' => 'Bus. Country',
'adr_two_street' => 'Home Street',
'adr_two_locality' => 'Home City',
'adr_two_region' => 'Home State',
'adr_two_postalcode' => 'Home Postal Code',
'adr_two_countryname' => 'Home Country',
'tel_fax' => 'Bus. Fax',
'tel_work' => 'Bus. Phone',
'tel_msg' => "Assistant's Phone",
'tel_car' => 'Car Phone',
'tel_isdn' => 'ISDN',
'tel_home' => 'Home Phone',
'tel_cell' => 'Mobile Phone',
'tel_pager' => 'Pager',
'ophone' => 'Bus. Phone2',
'bday' => 'Birthday',
'email' => 'Email Addr',
'email_home' => 'Email Addr2',
'url' => 'URL',
'note' => 'Notes'
);
// This will store the contacts object
var $contacts = '';
// Read full list of user's contacts only to get id's for each
function export_start_file($buffer,$ncat_id='')
{
$this->id=-1;
if ($ncat_id) { $filter = 'tid=n,cat_id='.$ncat_id; }
else { $filter = 'tid=n'; }
$this->contacts = CreateObject('phpgwapi.contacts');
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);
for ($i=0;$i<count($tmp);$i++)
{
$this->ids[$i] = $tmp[$i]['id'];
}
// $ids is now an array of all id's for this user, e.g. $ids[0] = 21, etc...
// $buffer is still empty
return $buffer;
}
// Read each entry
function export_start_record($buffer)
{
$this->id++;
$top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0];
return $buffer;
}
// Read each attribute, populate buffer array
// name/value are the fields from the export array above
function export_new_attrib($buffer,$name,$value)
{
if ($this->export[$name])
{
$buffer[$this->id][$this->export[$name]] = $value;
//echo '<br>'.$this->id.' - '.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]];
}
return $buffer;
}
// Tack on some extra values - none for this file
function export_end_record($buffer)
{
return $buffer;
}
// Parse it all into a string
function export_end_file($buffer)
{
reset($this->ids);
for ($i=0;$i<count($this->ids);$i++)
{
$j = $i + 1;
reset($this->export);
$entries .= "#" . $j . ":" . $buffer[$i]['n_given'] . $buffer[$i]['n_family'] . "\r\n";
while (list($name,$value)=each($this->export))
{
$entries .= $value . ":\t" . $buffer[$i][$value] . "\n";
}
$entries .= "\r\n";
}
$buffer = $entries;
$pdb = CreateObject('addressbook.pdb');
$pdb->fetch($buffer, 'phpgw Contacts', 'phpgw.pdb');
return $buffer;
}
}
?>

View File

@ -0,0 +1,171 @@
<?php
// This file defines a set of functions and an associative array.
// The key of the array corresponds to a header in the source
// export file and the value of the array item will be used in
// the creation of the output file.
//
// The array need not be in any order and any fields not defined will
// not be transferred. If the val='+', the value will be appended to
// the previous field and any text after the '+' will be appended
// before the value. For example, the following would add a comma and
// a space between LastName and FirstName and store it in FullName:
//
// array("LastName" => "FullName","FirstName" => "+, ");
//
// Also start with a '#' symbol and a comma separated list will be
// turned into a number of the same entries.
class export_conv
{
var $currentrecord = array(); //used for buffering to allow uid lines to go first
var $id;
//list of all id's
var $ids = array();
var $type = 'ldif';
var $export = array(
'id' => 'uidnumber',
'lid' => 'uid',
'tid' => 'phpgwcontacttype',
'owner' => 'phpgwcontactowner',
'access' => 'phpgwcontactaccess',
'fn' => 'cn', // 'prefix given middle family suffix'
'n_given' => 'givenname', // firstname
'n_family' => 'sn', // lastname
'n_middle' => 'phpgwmiddlename',
'n_prefix' => 'phpgwprefix',
'n_suffix' => 'phpgwsuffix',
'sound' => 'phpgwaudio',
'bday' => 'phpgwbirthday',
'note' => 'description',
'tz' => 'phpgwtz',
'geo' => 'phpgwgeo',
'url' => 'phpgwurl',
'pubkey' => 'phpgwpublickey',
'org_name' => 'o', // company
'org_unit' => 'ou', // division
'title' => 'title',
'adr_one_street' => 'streetaddress',
'adr_one_locality' => 'locality',
'adr_one_region' => 'st',
'adr_one_postalcode' => 'postalcode',
'adr_one_countryname' => 'co',
'adr_one_type' => 'phpgwadronetype', // address is domestic/intl/postal/parcel/work/home
'label' => 'phpgwaddresslabel', // address label
'adr_two_street' => 'phpgwadrtwostreet',
'adr_two_locality' => 'phpgwadrtwolocality',
'adr_two_region' => 'phpgwadrtworegion',
'adr_two_postalcode' => 'phpgwadrtwopostalcode',
'adr_two_countryname' => 'phpgwadrtwocountryname',
'adr_two_type' => 'phpgwadrtwotype', // address is domestic/intl/postal/parcel/work/home
'tel_work' => 'telephonenumber',
'tel_home' => 'homephone',
'tel_voice' => 'phpgwvoicetelephonenumber',
'tel_fax' => 'facsimiletelephonenumber',
'tel_msg' => 'phpgwmsgtelephonenumber',
'tel_cell' => 'phpgwcelltelephonenumber',
'tel_pager' => 'phpgwpagertelephonenumber',
'tel_bbs' => 'phpgwbbstelephonenumber',
'tel_modem' => 'phpgwmodemtelephonenumber',
'tel_car' => 'phpgwmobiletelephonenumber',
'tel_isdn' => 'phpgwisdnphonenumber',
'tel_video' => 'phpgwvideophonenumber',
'tel_prefer' => 'phpgwpreferphone', // home, work, voice, etc
'email' => 'mail',
'email_type' => 'phpgwmailtype', //'INTERNET','CompuServe',etc...
'email_home' => 'phpgwmailhome',
'email_home_type' => 'phpgwmailhometype' //'INTERNET','CompuServe',etc...
);
// This will store the contacts object
var $contacts = '';
// Read full list of user's contacts only to get id's for each
function export_start_file($buffer,$ncat_id='')
{
$this->id=-1;
if ($ncat_id) { $filter = 'tid=n,cat_id='.$ncat_id; }
else { $filter = 'tid=n'; }
$this->contacts = CreateObject('phpgwapi.contacts');
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);
for ($i=0;$i<count($tmp);$i++)
{
$this->ids[$i] = $tmp[$i]['id'];
}
// $ids is now an array of all id's for this user, e.g. $ids[0] = 21, etc...
// $buffer is still empty
return $buffer;
}
// Read each entry
function export_start_record($buffer)
{
$this->id++;
$top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0];
return $buffer;
}
// Read each attribute, populate buffer
// name/value are the fields from the export array above
function export_new_attrib($buffer,$name,$value)
{
if ($this->export[$name] && ($value != '') )
{
$buffer[$this->id][$this->export[$name]] = $value;
//echo '<br>'.$this->id.' - '.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]];
}
return $buffer;
}
// Tack on some extra values
function export_end_record($buffer)
{
global $phpgw_info;
if ($phpgw_info['server']['ldap_contact_context'])
{
$context = $phpgw_info['server']['ldap_contact_context'];
}
$time = gettimeofday();
$cn = ereg_replace(',','',$buffer[$this->id]['cn']);
$buffer[$this->id]['dn'] = 'uid='.time().$time['usec'].':'.$cn.','.$context;
$buffer[$this->id]['uid'] = time().$time['usec'];
if ($buffer[$this->id]['cn'])
{
$buffer[$this->id]['uid'] .= ':'.$buffer[$this->id]['cn'];
}
$buffer[$this->id]['description'] = ereg_replace("\r\n",';',$buffer[$this->id]['description']);
//echo '<br>'.$this->id.' - '.$buffer[$this->id]['dn'];
return $buffer;
}
function export_end_file($buffer) {
reset($this->ids);
for ($i=0;$i<count($this->ids);$i++)
{
$entries .= 'dn: '.$buffer[$i]['dn'] . "\n";
reset($this->export);
while (list($name,$value)=each($this->export))
{
if (($value != 'dn') && !empty($buffer[$i][$value]))
{
$tmp = ereg_replace(',','',$buffer[$i][$value]);
$entries .= $value . ': ' . $tmp . "\n";
}
}
$entries .= 'objectClass: person' . "\n";
$entries .= 'objectClass: organizationalPerson' . "\n";
$entries .= 'objectClass: inetOrgPerson' . "\n";
$entries .= 'objectClass: phpgwContact' . "\n";
$entries .= "\n";
}
$buffer = $entries;
return $buffer;
}
}
?>

View File

@ -0,0 +1,144 @@
<?php
// This file defines a set of functions and an associative array.
// The key of the array corresponds to a header in the source
// export file and the value of the array item will be used in
// the creation of the output file.
//
// The array need not be in any order and any fields not defined will
// not be transferred. If the val='+', the value will be appended to
// the previous field and any text after the '+' will be appended
// before the value. For example, the following would add a comma and
// a space between LastName and FirstName and store it in FullName:
//
// array("LastName" => "FullName","FirstName" => "+, ");
//
// Also start with a '#' symbol and a comma separated list will be
// turned into a number of the same entries.
class export_conv
{
var $currentrecord = array(); //used for buffering to allow uid lines to go first
var $id;
//list of all id's
var $ids = array();
var $type = 'sql';
var $export= array(
"id" => "id",
"lid" => "lid",
"tid" => "tid",
"owner" => "owner",
"fn" => "fn",
"n_given" => "n_given",
"n_family" => "n_family",
"n_middle" => "n_middle",
"n_prefix" => "n_prefix",
"n_suffix" => "n_suffix",
"sound" => "sound",
"bday" => "bday",
"note" => "note",
"tz" => "tz",
"geo" => "geo",
"url" => "url",
"pubkey" => "pubkey",
"org_name" => "org_name",
"org_unit" => "org_unit",
"title" => "title",
"adr_one_street" => "adr_one_street",
"adr_one_locality" => "adr_one_locality",
"adr_one_region" => "adr_one_region",
"adr_one_postalcode" => "adr_one_postalcode",
"adr_one_countryname" => "adr_one_countryname",
"adr_one_type" => "adr_one_type",
"label" => "label",
"adr_two_street" => "adr_two_street",
"adr_two_locality" => "adr_two_locality",
"adr_two_region" => "adr_two_region",
"adr_two_postalcode" => "adr_two_postalcode",
"adr_two_countryname" => "adr_two_countryname",
"adr_two_type" => "adr_two_type",
"tel_work" => "tel_work",
"tel_home" => "tel_home",
"tel_voice" => "tel_voice",
"tel_fax" => "tel_fax",
"tel_msg" => "tel_msg",
"tel_cell" => "tel_cell",
"tel_pager" => "tel_pager",
"tel_bbs" => "tel_bbs",
"tel_modem" => "tel_modem",
"tel_car" => "tel_car",
"tel_isdn" => "tel_isdn",
"tel_video" => "tel_video",
"tel_prefer" => "tel_prefer",
"email" => "email",
"email_type" => "email_type",
"email_home" => "email_home",
"email_home_type" => "email_home_type"
);
// This will store the contacts object
var $contacts = '';
// Read full list of user's contacts only to get id's for each
function export_start_file($buffer,$ncat_id='') {
$this->id=-1;
if ($ncat_id) { $filter = "tid=n,cat_id=".$ncat_id; }
else { $filter = "tid=n"; }
$this->contacts = CreateObject('phpgwapi.contacts');
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);
for ($i=0;$i<count($tmp);$i++) {
$this->ids[$i] = $tmp[$i]['id'];
}
// $ids is now an array of all id's for this user, e.g. $ids[0] = 21, etc...
// $buffer is still empty
return $buffer;
}
// Read each entry
function export_start_record($buffer) {
$this->id++;
$top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0];
return $buffer;
}
// Read each attribute, populate buffer array
// name/value are the fields from the export array above
function export_new_attrib($buffer,$name,$value) {
if ($this->export[$name]) {
$buffer[$this->id][$this->export[$name]] = $value;
//echo '<br>'.$this->id.' - '.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]];
}
return $buffer;
}
// Tack on some extra values - none for this file
function export_end_record($buffer) {
return $buffer;
}
// Parse it all into a string
function export_end_file($buffer) {
$top = 'INSERT INTO phpgw_addressbook(';
reset($this->ids);
for ($i=0;$i<count($this->ids);$i++) {
reset($this->export);
$fields = $values = "";
while (list($name,$value) = each($this->export)) {
$fields .= $value . ",";
$values .= "'" . $buffer[$i][$value] . "',";
}
$fields = substr($fields,0,-1) . ")\n VALUES(";
$values = substr($values,0,-1) . ");\n";
$entries .= $top . $fields . $values;
}
$buffer = $entries;
return $buffer;
}
}
?>

View File

@ -0,0 +1,113 @@
<?php
/*
This file defines a set of functions and an associative array.
The key of the array corresponds to a header in the source
import file and the value of the array item will be used in
the creation of the output file.
The array need not be in any order and any fields not defined will
not be transferred. If the val='+', the value will be appended to
the previous field and any text after the '+' will be appended
before the value. For example, the following would add a comma and
a space between LastName and FirstName and store it in FullName:
array('LastName' => 'FullName','FirstName' => '+, ');
Also start with a '#' symbol and a comma separated list will be
turned into a number of the same entries.
*/
class import_conv
{
var $currentrecord = array(); /* used for buffering to allow uid lines to go first */
var $id;
var $type = 'ldif';
var $import = array(
'title' => 'title',
'givenname' => 'n_given',
'sn' => 'n_family',
'cn' => 'fn',
'o' => 'org_name',
'ou' => 'org_unit',
'streetaddress' => 'adr_one_street',
'locality' => 'adr_one_locality',
'st' => 'adr_one_region',
'postalcode' => 'adr_one_postalcode',
'countryname' => 'adr_one_countryname',
'telephonenumber' => 'tel_work',
'homephone' => 'tel_home',
'facsimiletelephonenumber' => 'tel_fax',
'xmozillaanyphone' => 'ophone',
'cellphone' => 'tel_cell',
'description' => 'note',
'pagerphone' => 'tel_pager',
'mail' => 'email',
'homeurl' => 'url',
'xmozillauseconferenceserver' => '',
'xmozillanickname' => '',
'xmozillausehtmlmail' => '',
'modifytimestamp' => '',
'objectclass' => ''
);
function import_start_file($buffer)
{
return $buffer;
}
function import_start_record($buffer)
{
$top=array();
++$this->id;
$this->currentrecord = $top;
return $buffer;
}
function import_new_attrib($buffer,$name,$value)
{
/* chop leading space from value */
$value = trim($value);
$value = str_replace('\r','',$value);
/* echo '<br>'.$name.' => '.$value; */
$this->currentrecord += array($name => $value);
return $buffer;
}
function import_end_record($buffer)
{
global $phpgw_info;
$buffer[$this->id]='';
while ( list($name, $value) = each($this->currentrecord))
{
$buffer[$this->id][$name] = $value;
/* echo '<br>'.$this->id.': '.$name.' => '.$value; */
}
return $buffer;
}
function import_end_file($buffer,$access='private',$cat_id=0)
{
global $phpgw,$phpgw_info;
$contacts = CreateObject('phpgwapi.contacts');
/* echo '<br>'; */
for ($i=1;$i<=count($buffer);$i++)
{
while ( list($name,$value) = @each($buffer[$i]) )
{
/* echo '<br>'.$i.': '.$name.' => '.$value; */
$entry[$i][$name] = $value;
}
$entry[$i]['email_type'] = 'INTERNET';
$entry[$i]['email_home_type'] = 'INTERNET';
$entry[$i]['adr_one_type'] = 'intl';
$entry[$i]['adr_two_type'] = 'intl';
/* echo '<br>'; */
$contacts->add($phpgw_info['user']['account_id'],$entry[$i],$access,$cat_id);
}
$num = $i - 1;
return lang('Successfully imported x records into your addressbook.',$num);
}
}
?>

View File

@ -0,0 +1,178 @@
<?php
// This file defines a set of functions and an associative array.
// The key of the array corresponds to a header in the source
// import file and the value of the array item will be used in
// the creation of the output file.
//
// An exported Outlook file looks like this:
//
// Title<tab>First Name<tab>Middle Name<tab>Last Name<tab>...
// <tab>Patrick<tab><tab>Walsh<tab>...
//
// Where the first line explains each optional field. This is what
// will be looked up in the key.
//
// The array need not be in any order and any fields not defined will
// not be transferred. If the val='+', the value will be appended to
// the previous field and any text after the '+' will be appended
// before the value. For example, the following would add a comma and
// a space between LastName and FirstName and store it in FullName:
//
// array('LastName' => 'FullName','FirstName' => '+, ');
//
// Also start with a '#' symbol and a comma separated list will be
// turned into a number of the same entries.
class import_conv
{
var $currentrecord = array(); //used for buffering to allow uid lines to go first
var $id;
var $type = 'csv';
var $import = array(
'Title' => 'title',
'First Name' => 'n_given',
'Middle Name' => 'n_middle',
'Last Name' => 'n_family',
'Suffix' => 'n_suffix',
'Company' => 'org_name', //objectclass: organization
'Department' => 'org_unit', //objectclass: organizationalPerson
'Job Title' => 'title', //objectclass: organizationalPerson
'Business Street' => 'adr_one_street',
'Business Street 2' => 'address2',
'Business Street 3' => 'address3',
'Business City' => 'adr_one_locality',
'Business State' => 'adr_one_region',
'Business Postal Code' => 'adr_one_postalcode',
'Business Country' => 'adr_one_countryname',
'Home Street' => 'adr_two_street',
'Home City' => 'adr_two_locality',
'Home State' => 'adr_two_region',
'Home Postal Code' => 'adr_two_postalcode',
'Home Country' => 'adr_two_countryname',
'Home Street 2' => '',
'Home Street 3' => '',
'Other Street' => '',
'Other City' => '',
'Other State' => '',
'Other Postal Code' => '',
'Other Country' => '',
"Assistant's Phone" => 'tel_msg',
'Business Fax' => 'tel_fax',
'Business Phone' => 'tel_work',
'Business Phone 2' => 'ophone',
'Callback' => '',
'Car Phone' => 'tel_car',
'Company Main Phone' => '',
'Home Fax' => '',
'Home Phone' => 'tel_home',
'Home Phone 2' => '', //This will make another homePhone entry
'ISDN' => 'tel_isdn',
'Mobile Phone' => 'tel_cell', //newPilotPerson
'Other Fax' => '',
'Other Phone' => '',
'Pager' => 'tel_pager',
'Primary Phone' => '',
'Radio Phone' => '',
'TTY/TDD Phone' => '',
'Telex' => '', //organization
'Account' => '',
'Anniversary' => '',
"Assistant's Name" => '', //newPilotPerson
'Billing Information' => '',
'Birthday' => 'bday',
'Categories' => '',
'Children' => '',
'Directory Server' => '',
'E-mail Address' => 'email',
'E-mail Display Name' => '',
'E-mail 2 Address' => 'email_home',
'E-mail 2 Display Name' => '',
'E-mail 3 Address' => '', //add another...
'E-mail 3 Display Name' => '',
'Gender' => '',
'Government ID Number' => '',
'Hobby' => '',
'Initials' => '',
'Internet Free Busy' => '',
'Keywords' => '',
'Language' => '',
'Location' => '',
"Manager's Name" => '',
'Mileage' => '',
'Notes' => 'note',
'Office Location' => '',
'Organizational ID Number' => '',
'PO Box' => '',
'Priority' => '',
'Private Profession' => '',
'Referred By' => '',
'Sensitivity' => '',
'Spouse' => '',
'User 1' => '',
'User 2' => '',
'User 3' => '',
'User 4' => '',
'Web Page' => 'url'
);
function import_start_file($buffer)
{
return $buffer;
}
function import_start_record($buffer)
{
$top=array();
++$this->id;
$this->currentrecord = $top;
return $buffer;
}
function import_new_attrib($buffer,$name,$value)
{
$value = trim($value);
$value = str_replace('\n','<BR>',$value);
$value = str_replace('\r','',$value);
$this->currentrecord += array($name => $value);
return $buffer;
}
function import_end_record($buffer)
{
global $phpgw_info;
$buffer[$this->id]='';
while ( list($name, $value) = each($this->currentrecord))
{
$buffer[$this->id][$name] = $value;
//echo '<br>'.$name.' => '.$value;
}
return $buffer;
}
function import_end_file($buffer,$access='private',$cat_id=0)
{
global $phpgw,$phpgw_info;
$contacts = CreateObject('phpgwapi.contacts');
//echo '<br>';
for ($i=1;$i<=count($buffer);$i++)
{
while ( list($name,$value) = @each($buffer[$i]) )
{
//echo '<br>'.$i.': '.$name.' => '.$value;
$entry[$i][$name] = $value;
}
$entry[$i]['email_type'] = 'INTERNET';
$entry[$i]['email_home_type'] = 'INTERNET';
$entry[$i]['adr_one_type'] = 'intl';
$entry[$i]['adr_two_type'] = 'intl';
//echo '<br>';
$contacts->add($phpgw_info['user']['account_id'],$entry[$i],$access,$cat_id);
}
$num = $i - 1;
return lang('Successfully imported x records into your addressbook.',$num);
}
}
?>

View File

@ -0,0 +1,210 @@
<?php
// This file defines a set of functions and an associative array.
// The key of the array corresponds to a header in the source
// import file and the value of the array item will be used in
// the creation of the output file.
//
// An exported Outlook file looks like this:
//
// Title<tab>First Name<tab>Middle Name<tab>Last Name<tab>...
// <tab>Patrick<tab><tab>Walsh<tab>...
//
// Where the first line explains each optional field. This is what
// will be looked up in the key.
//
// The array need not be in any order and any fields not defined will
// not be transferred. If the val='+', the value will be appended to
// the previous field and any text after the '+' will be appended
// before the value. For example, the following would add a comma and
// a space between LastName and FirstName and store it in FullName:
//
// array('LastName' => 'FullName','FirstName' => '+, ');
//
// Also start with a '#' symbol and a comma separated list will be
// turned into a number of the same entries.
class import_conv
{
var $currentrecord = array(); //used for buffering to allow uid lines to go first
var $id;
var $type = 'csv';
var $import = array(
'Nome'
'Cognome'
'Secondo nome'
'Nome e cognome'
'Alternativo'
'Indirizzo di posta elettronica'
'Via (ab.)'
'Città (ab.)'
'CAP (ab.)'
'Provincia (ab.)'
'Paese (ab.)'
'Telefono (ab.)'
'Fax (ab.)'
'Cellulare'
'Pagina Web personale'
'Via (uff.)'
'Città (uff.)'
'CAP (uff.)'
'Provincia (uff.)'
'Paese (uff.)'
'Pagina Web professionale'
'Telefono (uff.)'
'Fax (uff.):'
'Cercapersone'
'Società'
'Posizione'
'Reparto'
'Ufficio'
'Note'
);
var $import = array(
'Title' => 'title',
'First Name' => 'n_given',
'Middle Name' => 'n_middle',
'Last Name' => 'n_family',
'Suffix' => 'n_suffix',
'Company' => 'org_name', //objectclass: organization
'Department' => 'org_unit', //objectclass: organizationalPerson
'Job Title' => 'title', //objectclass: organizationalPerson
'Business Street' => 'adr_one_street',
'Business Street 2' => 'address2',
'Business Street 3' => 'address3',
'Business City' => 'adr_one_locality',
'Business State' => 'adr_one_region',
'Business Postal Code' => 'adr_one_postalcode',
'Business Country' => 'adr_one_countryname',
'Home Street' => 'adr_two_street',
'Home City' => 'adr_two_locality',
'Home State' => 'adr_two_region',
'Home Postal Code' => 'adr_two_postalcode',
'Home Country' => 'adr_two_countryname',
'Home Street 2' => '',
'Home Street 3' => '',
'Other Street' => '',
'Other City' => '',
'Other State' => '',
'Other Postal Code' => '',
'Other Country' => '',
"Assistant's Phone" => 'tel_msg',
'Business Fax' => 'tel_fax',
'Business Phone' => 'tel_work',
'Business Phone 2' => 'ophone',
'Callback' => '',
'Car Phone' => 'tel_car',
'Company Main Phone' => '',
'Home Fax' => '',
'Home Phone' => 'tel_home',
'Home Phone 2' => '', //This will make another homePhone entry
'ISDN' => 'tel_isdn',
'Mobile Phone' => 'tel_cell', //newPilotPerson
'Other Fax' => '',
'Other Phone' => '',
'Pager' => 'tel_pager',
'Primary Phone' => '',
'Radio Phone' => '',
'TTY/TDD Phone' => '',
'Telex' => '', //organization
'Account' => '',
'Anniversary' => '',
"Assistant's Name" => '', //newPilotPerson
'Billing Information' => '',
'Birthday' => 'bday',
'Categories' => '',
'Children' => '',
'Directory Server' => '',
'E-mail Address' => 'email',
'E-mail Display Name' => '',
'E-mail 2 Address' => 'email_home',
'E-mail 2 Display Name' => '',
'E-mail 3 Address' => '', //add another...
'E-mail 3 Display Name' => '',
'Gender' => '',
'Government ID Number' => '',
'Hobby' => '',
'Initials' => '',
'Internet Free Busy' => '',
'Keywords' => '',
'Language' => '',
'Location' => '',
"Manager's Name" => '',
'Mileage' => '',
'Notes' => 'note',
'Office Location' => '',
'Organizational ID Number' => '',
'PO Box' => '',
'Priority' => '',
'Private Profession' => '',
'Referred By' => '',
'Sensitivity' => '',
'Spouse' => '',
'User 1' => '',
'User 2' => '',
'User 3' => '',
'User 4' => '',
'Web Page' => 'url'
);
function import_start_file($buffer)
{
return $buffer;
}
function import_start_record($buffer)
{
$top=array();
++$this->id;
$this->currentrecord = $top;
return $buffer;
}
function import_new_attrib($buffer,$name,$value)
{
$value = trim($value);
$value = str_replace('\n','<BR>',$value);
$value = str_replace('\r','',$value);
$this->currentrecord += array($name => $value);
return $buffer;
}
function import_end_record($buffer)
{
global $phpgw_info;
$buffer[$this->id]='';
while ( list($name, $value) = each($this->currentrecord))
{
$buffer[$this->id][$name] = $value;
//echo '<br>'.$name.' => '.$value;
}
return $buffer;
}
function import_end_file($buffer,$access='private',$cat_id=0)
{
global $phpgw,$phpgw_info;
$contacts = CreateObject('phpgwapi.contacts');
//echo '<br>';
for ($i=1;$i<=count($buffer);$i++)
{
while ( list($name,$value) = @each($buffer[$i]) )
{
//echo '<br>'.$i.': '.$name.' => '.$value;
$entry[$i][$name] = $value;
}
$entry[$i]['email_type'] = 'INTERNET';
$entry[$i]['email_home_type'] = 'INTERNET';
$entry[$i]['adr_one_type'] = 'intl';
$entry[$i]['adr_two_type'] = 'intl';
//echo '<br>';
$contacts->add($phpgw_info['user']['account_id'],$entry[$i],$access,$cat_id);
}
$num = $i - 1;
return lang('Successfully imported x records into your addressbook.',$num);
}
}
?>

View File

@ -0,0 +1,90 @@
<?php
/*
This file defines a set of functions and an associative array.
The key of the array corresponds to a header in the source
import file and the value of the array item will be used in
the creation of the output file.
The array need not be in any order and any fields not defined will
not be transferred. If the val='+', the value will be appended to
the previous field and any text after the '+' will be appended
before the value. For example, the following would add a comma and
a space between LastName and FirstName and store it in FullName:
array('LastName' => 'FullName','FirstName' => '+, ');
Also start with a '#' symbol and a comma separated list will be
turned into a number of the same entries.
*/
class import_conv
{
var $currentrecord = array(); /* used for buffering to allow uid lines to go first */
var $id;
var $type = 'vcard';
/* These will hold the class objects */
var $contacts = '';
var $vcard = '';
/* This will be populated via the vcard->import var */
var $import = array();
function import_start_file($buffer)
{
$this->id = 0;
$this->contacts = CreateObject('phpgwapi.contacts');
$this->vcard = CreateObject('phpgwapi.vcard');
$this->import = $this->vcard->import;
return $buffer;
}
function import_start_record($buffer)
{
++$this->id;
$this->currentrecord = array();
return $buffer;
}
function import_new_attrib($buffer,$name,$value)
{
$value = trim($value);
$value = ereg_replace('=0D=0A','\n',$value);
/* echo '<br>'.$this->id.': '.$name.' => '.$value; */
$this->currentrecord += array($name => $value);
return $buffer;
}
function import_end_record($buffer)
{
global $phpgw_info;
$buffer[$this->id]='';
while ( list($name, $value) = each($this->currentrecord))
{
$buffer[$this->id][$name] = $value;
/* $buffer[$this->id]['private'] = $private; */
/* echo '<br>'.$name.' => '.$value; */
}
return $buffer;
}
function import_end_file($buffer,$access='private',$cat_id=0)
{
global $phpgw,$phpgw_info;
for ($i=1;$i<=count($buffer);$i++)
{
/*
Send the entire array to the vcard class in function.
It will parse the vcard fields and clean the array of extra
bogus values that get stuffed in.
*/
$entry = $this->vcard->in($buffer[$i]);
/* Now actually add the new entry */
$this->contacts->add($phpgw_info['user']['account_id'],$entry,$access,$cat_id);
}
$num = $i - 1;
return lang('Successfully imported x records into your addressbook.',$num);
}
}
?>