mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
These have moved
This commit is contained in:
parent
c4b724eeeb
commit
16914adba3
@ -1,145 +0,0 @@
|
||||
<?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 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;
|
||||
}
|
||||
} // end export class
|
||||
?>
|
@ -1,149 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,142 +0,0 @@
|
||||
<?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.
|
||||
//
|
||||
// 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 export_conv
|
||||
{
|
||||
var $currentrecord = array(); //used for buffering to allow uid lines to go first
|
||||
var $id;
|
||||
var $type = 'csv';
|
||||
|
||||
var $export = array(
|
||||
'title' => 'Title',
|
||||
'n_given' => 'First Name',
|
||||
'n_middle' => 'Middle Name',
|
||||
'n_family' => 'Last Name',
|
||||
'n_suffix' => 'Suffix',
|
||||
'org_name' => 'Company',
|
||||
'org_unit' => 'Department',
|
||||
'adr_one_street' => 'Business Street',
|
||||
'address2' => 'Business Street 2',
|
||||
'address3' => 'Business Street 3',
|
||||
'adr_one_locality' => 'Business City',
|
||||
'adr_one_region' => 'Business State',
|
||||
'adr_one_postalcode' => 'Business Postal Code',
|
||||
'adr_one_countryname' => 'Business 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' => 'Business Fax',
|
||||
'tel_work' => 'Business 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' => 'Business Phone 2',
|
||||
'bday' => 'Birthday',
|
||||
'email' => 'E-mail Address',
|
||||
'email_home' => 'E-mail Address 2',
|
||||
'url' => 'Web Page',
|
||||
'note' => 'Notes'
|
||||
);
|
||||
|
||||
// This will store the contacts object
|
||||
var $contacts = '';
|
||||
|
||||
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])
|
||||
{
|
||||
$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)
|
||||
{
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function export_end_file($buffer)
|
||||
{
|
||||
// Build the header for the file (field list)
|
||||
reset($this->export);
|
||||
while (list($name,$value)=each($this->export))
|
||||
{
|
||||
$entries .= $value . ',';
|
||||
}
|
||||
$entries = substr($entries,0,-1);
|
||||
$entries .= "\r\n";
|
||||
|
||||
// Now add all the data
|
||||
reset($this->ids);
|
||||
for ($i=0;$i<count($this->ids);$i++)
|
||||
{
|
||||
reset($this->export);
|
||||
while (list($name,$value)=each($this->export))
|
||||
{
|
||||
$entries .= $buffer[$i][$value] . ',';
|
||||
}
|
||||
$entries = substr($entries,0,-1);
|
||||
$entries .= "\r\n";
|
||||
}
|
||||
$buffer = $entries;
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,133 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,171 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,144 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user