Formatting

This commit is contained in:
Miles Lott 2001-05-21 07:31:00 +00:00
parent 551661182f
commit 061c819fed
6 changed files with 378 additions and 319 deletions

View File

@ -12,36 +12,41 @@
/* $Id$ */
if ($download =='on') {
$phpgw_info["flags"] = array(
"noheader" => True,
"nonavbar" => True
if ($download == 'on')
{
$phpgw_info['flags'] = array(
'noheader' => True,
'nonavbar' => True
);
} else {
$phpgw_info["flags"] = array(
"noheader" => False,
"nonavbar" => False
}
else
{
$phpgw_info['flags'] = array(
'noheader' => False,
'nonavbar' => False
);
}
$phpgw_info["flags"]["currentapp"] = "addressbook";
$phpgw_info["flags"]["enable_contacts_class"] = True;
$phpgw_info["flags"]["enable_browser_class"] = True;
include("../header.inc.php");
$phpgw_info['flags'] = array(
'currentapp' => 'addressbook',
'enable_contacts_class' => True,
'enable_browser_class' => True
);
include('../header.inc.php');
$sep = SEP;
if (!$convert)
{
$t = new Template(PHPGW_APP_TPL);
$t->set_file(array("export" => "export.tpl"));
$t->set_file(array('export' => 'export.tpl'));
$dir_handle=opendir($phpgw_info["server"]["app_root"].$sep."export");
$i=0; $myfilearray="";
$dir_handle=opendir($phpgw_info['server']['app_root'].$sep.'export');
$i=0; $myfilearray='';
while ($file = readdir($dir_handle))
{
#echo "<!-- ".is_file($phpgw_info["server"]["app_root"].$sep."conv".$sep.$file)." -->";
if ((substr($file, 0, 1) != ".") && is_file($phpgw_info["server"]["app_root"].$sep."export".$sep.$file) )
if ((substr($file, 0, 1) != '.') && is_file($phpgw_info['server']['app_root'].$sep.'export'.$sep.$file) )
{
$myfilearray[$i] = $file;
$i++;
@ -52,40 +57,40 @@
for ($i=0;$i<count($myfilearray);$i++)
{
$fname = ereg_replace('_',' ',$myfilearray[$i]);
$conv .= ' <OPTION VALUE="'.$myfilearray[$i].'">'.$fname.'</OPTION>'."\n";
$conv .= ' <option value="'.$myfilearray[$i].'">'.$fname.'</option>'."\n";
}
$t->set_var("lang_cancel",lang("Cancel"));
$t->set_var("lang_cat",lang("Select Category"));
$t->set_var("cat_link",cat_option($cat_id,False,False));
$t->set_var("cancel_url",$phpgw->link("/addressbook/index.php"));
$t->set_var("navbar_bg",$phpgw_info["theme"]["navbar_bg"]);
$t->set_var("navbar_text",$phpgw_info["theme"]["navbar_text"]);
$t->set_var("export_text",lang("Export from Addressbook"));
$t->set_var("action_url",$phpgw->link("/addressbook/export.php"));
$t->set_var("filename",lang("Export file name"));
$t->set_var("conv",$conv);
$t->set_var("debug",lang(""));
$t->set_var("download",lang("Submit"));
$t->set_var("start",$start);
$t->set_var("sort",$sort);
$t->set_var("order",$order);
$t->set_var("filter",$filter);
$t->set_var("query",$query);
$t->set_var("cat_id",$cat_id);
$t->pparse("out","export");
$t->set_var('lang_cancel',lang('Cancel'));
$t->set_var('lang_cat',lang('Select Category'));
$t->set_var('cat_link',cat_option($cat_id,False,False));
$t->set_var('cancel_url',$phpgw->link('/addressbook/index.php'));
$t->set_var('navbar_bg',$phpgw_info['theme']['navbar_bg']);
$t->set_var('navbar_text',$phpgw_info['theme']['navbar_text']);
$t->set_var('export_text',lang('Export from Addressbook'));
$t->set_var('action_url',$phpgw->link('/addressbook/export.php'));
$t->set_var('filename',lang('Export file name'));
$t->set_var('conv',$conv);
$t->set_var('debug',lang(''));
$t->set_var('download',lang('Submit'));
$t->set_var('start',$start);
$t->set_var('sort',$sort);
$t->set_var('order',$order);
$t->set_var('filter',$filter);
$t->set_var('query',$query);
$t->set_var('cat_id',$cat_id);
$t->pparse('out','export');
$phpgw->common->phpgw_footer();
}
else
{
include ($phpgw_info["server"]["app_root"].$sep."export".$sep.$conv_type);
include ($phpgw_info['server']['app_root'].$sep.'export'.$sep.$conv_type);
$buffer=array();
$this = new export_conv;
// Read in user custom fields, if any
$customfields = array();
while (list($col,$descr) = @each($phpgw_info["user"]["preferences"]["addressbook"]))
while (list($col,$descr) = @each($phpgw_info['user']['preferences']['addressbook']))
{
if ( substr($col,0,6) == 'extra_' )
{
@ -95,9 +100,9 @@
}
}
$extrafields = array(
"ophone" => "ophone",
"address2" => "address2",
"address3" => "address3"
'ophone' => 'ophone',
'address2' => 'address2',
'address3' => 'address3'
);
if ($this->type != 'vcard')
{
@ -128,7 +133,7 @@
$tsvfilename = $phpgw_info['server']['temp_dir'].$sep.$tsvfilename;
if ( ($download == "on") || ($o->type == 'pdb') )
if ( ($download == 'on') || ($o->type == 'pdb') )
{
// filename, default application/octet-stream, length of file, default nocache True
$phpgw->browser->content_header($tsvfilename,'',strlen($buffer));
@ -139,9 +144,9 @@
echo "<pre>\n";
echo $buffer;
echo "\n</pre>\n";
echo '<a href="'.$phpgw->link("/addressbook/index.php",
echo '<a href="'.$phpgw->link('/addressbook/index.php',
"sort=$sort&order=$order&filter=$filter&start=$start&query=$query&cat_id=$cat_id")
. '">'.lang("OK").'</a>';
. '">'.lang('OK').'</a>';
$phpgw->common->phpgw_footer();
}
}

View File

@ -28,56 +28,56 @@
// 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",
'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_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_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",
'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"
'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
@ -85,17 +85,19 @@
var $vcard = '';
// Read full list of user's contacts only to get id's for each
function export_start_file($buffer,$ncat_id='') {
function export_start_file($buffer,$ncat_id='')
{
$this->id=-1;
if ($ncat_id) { $filter = "tid=n,cat_id=".$ncat_id; }
else { $filter = "tid=n"; }
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->vcard = CreateObject('phpgwapi.vcard');
$this->export = $this->vcard->export;
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);
for ($i=0;$i<count($tmp);$i++) {
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...
@ -104,7 +106,8 @@
}
// Read each entry
function export_start_record($buffer) {
function export_start_record($buffer)
{
$this->id++;
$top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0];
@ -113,21 +116,26 @@
// 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 != "") ) {
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) {
function export_end_record($buffer)
{
return $buffer;
}
function export_end_file($buffer) {
function export_end_file($buffer)
{
reset($this->ids);
for ($i=0;$i<count($this->ids);$i++) {
for ($i=0;$i<count($this->ids);$i++)
{
$vcards .= $this->vcard->out($buffer[$i]);
}
$buffer = $vcards;

View File

@ -24,41 +24,43 @@
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",
'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='') {
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++) {
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...
@ -67,7 +69,8 @@
}
// Read each entry
function export_start_record($buffer) {
function export_start_record($buffer)
{
$this->id++;
$top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0];
@ -76,12 +79,17 @@
// 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;
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]];
@ -90,40 +98,48 @@
}
// 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"];
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) {
function export_end_file($buffer)
{
reset($this->ids);
for ($i=0;$i<count($this->ids);$i++) {
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') {
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 .= '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;

View File

@ -30,52 +30,54 @@
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"
'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='') {
function export_start_file($buffer,$ncat_id='')
{
$this->id=-1;
if ($ncat_id) { $filter = "tid=n,cat_id=".$ncat_id; }
else { $filter = "tid=n"; }
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++) {
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...
@ -84,7 +86,8 @@
}
// Read each entry
function export_start_record($buffer) {
function export_start_record($buffer)
{
$this->id++;
$top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0];
@ -93,8 +96,10 @@
// 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]) {
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]];
}
@ -102,14 +107,17 @@
}
// Tack on some extra values
function export_end_record($buffer) {
function export_end_record($buffer)
{
return $buffer;
}
function export_end_file($buffer) {
function export_end_file($buffer)
{
// Build the header for the file (field list)
reset($this->export);
while (list($name,$value)=each($this->export)) {
while (list($name,$value)=each($this->export))
{
$entries .= $value . ',';
}
$entries = substr($entries,0,-1);
@ -117,9 +125,11 @@
// Now add all the data
reset($this->ids);
for ($i=0;$i<count($this->ids);$i++) {
for ($i=0;$i<count($this->ids);$i++)
{
reset($this->export);
while (list($name,$value)=each($this->export)) {
while (list($name,$value)=each($this->export))
{
$entries .= $buffer[$i][$value] . ',';
}
$entries = substr($entries,0,-1);

View File

@ -21,56 +21,58 @@
var $id;
//list of all id's
var $ids = array();
var $type = "pdb";
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"
'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='') {
function export_start_file($buffer,$ncat_id='')
{
$this->id=-1;
if ($ncat_id) { $filter = "tid=n,cat_id=".$ncat_id; }
else { $filter = "tid=n"; }
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++) {
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...
@ -79,7 +81,8 @@
}
// Read each entry
function export_start_record($buffer) {
function export_start_record($buffer)
{
$this->id++;
$top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0];
@ -88,8 +91,10 @@
// 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]) {
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]];
}
@ -97,26 +102,30 @@
}
// Tack on some extra values - none for this file
function export_end_record($buffer) {
function export_end_record($buffer)
{
return $buffer;
}
// Parse it all into a string
function export_end_file($buffer) {
function export_end_file($buffer)
{
reset($this->ids);
for ($i=0;$i<count($this->ids);$i++) {
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)) {
while (list($name,$value)=each($this->export))
{
$entries .= $value . ":\t" . $buffer[$i][$value] . "\n";
}
$entries .= "\r\n";
}
$buffer = $entries;
$pdb = CreateObject("addressbook.pdb");
$pdb = CreateObject('addressbook.pdb');
$pdb->fetch($buffer, 'phpgw Contacts', 'phpgw.pdb');
return $buffer;
}

View File

@ -24,75 +24,77 @@
var $type = 'ldif';
var $export = array(
"id" => "uidnumber",
"lid" => "uid",
"tid" => "phpgwcontacttype",
"owner" => "phpgwowner",
"access" => "phpgwaccess",
"fn" => "cn", // 'prefix given middle family suffix'
"n_given" => "givenname", // firstname
"n_family" => "sn", // lastname
"n_middle" => "middlename",
"n_prefix" => "prefix",
"n_suffix" => "suffix",
"sound" => "audio",
"bday" => "birthday",
"note" => "description",
"tz" => "tz",
"geo" => "geo",
"url" => "url",
"pubkey" => "publickey",
'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",
'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" => "countryname",
"adr_one_type" => "phpgwadronetype", // address is domestic/intl/postal/parcel/work/home
"label" => "phpgwaddresslabel", // address label
'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
'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" => "voicetelephonenumber",
"tel_fax" => "facsimiletelephonenumber",
"tel_msg" => "msgtelephonenumber",
"tel_cell" => "cellphone",
"tel_pager" => "pagertelephonenumber",
"tel_bbs" => "bbstelephonenumber",
"tel_modem" => "modemtelephonenumber",
"tel_car" => "mobiletelephonenumber",
"tel_isdn" => "isdnphonenumber",
"tel_video" => "videophonenumber",
"tel_prefer" => "preferphone", // home, work, voice, etc
"email" => "mail",
"email_type" => "mailtype", //'INTERNET','CompuServe',etc...
"email_home" => "mailhome",
"email_home_type" => "mailhometype" //'INTERNET','CompuServe',etc...
'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='') {
function export_start_file($buffer,$ncat_id='')
{
$this->id=-1;
if ($ncat_id) { $filter = "tid=n,cat_id=".$ncat_id; }
else { $filter = "tid=n"; }
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++) {
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...
@ -101,7 +103,8 @@
}
// Read each entry
function export_start_record($buffer) {
function export_start_record($buffer)
{
$this->id++;
$top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0];
@ -110,8 +113,10 @@
// 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 != "") ) {
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]];
}
@ -119,38 +124,44 @@
}
// Tack on some extra values
function export_end_record($buffer) {
function export_end_record($buffer)
{
global $phpgw_info;
if ($phpgw_info['server']['ldap_contact_context']) {
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'];
$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"]);
$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++) {
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])) {
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 .= $value . ': ' . $tmp . "\n";
}
}
$entries .= "objectClass: person\n";
$entries .= "objectClass: organizationalPerson\n";
$entries .= "objectClass: inetOrgPerson\n";
$entries .= "objectClass: phpgwContact\n";
$entries .= 'objectClass: person' . "\n";
$entries .= 'objectClass: organizationalPerson' . "\n";
$entries .= 'objectClass: inetOrgPerson' . "\n";
$entries .= 'objectClass: phpgwContact' . "\n";
$entries .= "\n";
}
$buffer = $entries;