formatting and globals, what else?

This commit is contained in:
Miles Lott 2001-12-04 01:26:53 +00:00
parent eb0592bb14
commit b4e366ddc0
7 changed files with 130 additions and 79 deletions

View File

@ -92,8 +92,14 @@
function export_start_file($buffer,$ncat_id='') function export_start_file($buffer,$ncat_id='')
{ {
$this->id=-1; $this->id=-1;
if ($ncat_id) { $filter = 'tid=n,cat_id='.$ncat_id; } if ($ncat_id)
else { $filter = 'tid=n'; } {
$filter = 'tid=n,cat_id='.$ncat_id;
}
else
{
$filter = 'tid=n';
}
/* Setup the contact and vcard objects, and the export fields var */ /* Setup the contact and vcard objects, and the export fields var */
$this->contacts = CreateObject('phpgwapi.contacts'); $this->contacts = CreateObject('phpgwapi.contacts');
$this->vcard = CreateObject('phpgwapi.vcard'); $this->vcard = CreateObject('phpgwapi.vcard');

View File

@ -54,8 +54,14 @@
function export_start_file($buffer,$ncat_id='') function export_start_file($buffer,$ncat_id='')
{ {
$this->id=-1; $this->id=-1;
if ($ncat_id) { $filter = "tid=n,cat_id=".$ncat_id; } if ($ncat_id)
else { $filter = "tid=n"; } {
$filter = 'tid=n,cat_id=' . $ncat_id;
}
else
{
$filter = 'tid=n';
}
$this->contacts = CreateObject('phpgwapi.contacts'); $this->contacts = CreateObject('phpgwapi.contacts');
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter); $tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);

View File

@ -71,8 +71,14 @@
function export_start_file($buffer,$ncat_id='') function export_start_file($buffer,$ncat_id='')
{ {
$this->id=-1; $this->id=-1;
if ($ncat_id) { $filter = 'tid=n,cat_id='.$ncat_id; } if ($ncat_id)
else { $filter = 'tid=n'; } {
$filter = 'tid=n,cat_id='.$ncat_id;
}
else
{
$filter = 'tid=n';
}
$this->contacts = CreateObject('phpgwapi.contacts'); $this->contacts = CreateObject('phpgwapi.contacts');
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter); $tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);
@ -120,7 +126,7 @@
{ {
$entries .= $value . ','; $entries .= $value . ',';
} }
$entries = substr($entries,0,-1); $entries = substr($entries,0,-1);
$entries .= "\r\n"; $entries .= "\r\n";
// Now add all the data // Now add all the data

View File

@ -71,8 +71,14 @@
function export_start_file($buffer,$ncat_id='') function export_start_file($buffer,$ncat_id='')
{ {
$this->id=-1; $this->id=-1;
if ($ncat_id) { $filter = 'tid=n,cat_id='.$ncat_id; } if ($ncat_id)
else { $filter = 'tid=n'; } {
$filter = 'tid=n,cat_id='.$ncat_id;
}
else
{
$filter = 'tid=n';
}
$this->contacts = CreateObject('phpgwapi.contacts'); $this->contacts = CreateObject('phpgwapi.contacts');
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter); $tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);
@ -120,7 +126,7 @@
{ {
$entries .= $value . ','; $entries .= $value . ',';
} }
$entries = substr($entries,0,-1); $entries = substr($entries,0,-1);
$entries .= "\r\n"; $entries .= "\r\n";
// Now add all the data // Now add all the data

View File

@ -66,8 +66,14 @@
function export_start_file($buffer,$ncat_id='') function export_start_file($buffer,$ncat_id='')
{ {
$this->id=-1; $this->id=-1;
if ($ncat_id) { $filter = 'tid=n,cat_id='.$ncat_id; } if ($ncat_id)
else { $filter = 'tid=n'; } {
$filter = 'tid=n,cat_id='.$ncat_id;
}
else
{
$filter = 'tid=n';
}
$this->contacts = CreateObject('phpgwapi.contacts'); $this->contacts = CreateObject('phpgwapi.contacts');
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter); $tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);

View File

@ -88,8 +88,14 @@
function export_start_file($buffer,$ncat_id='') function export_start_file($buffer,$ncat_id='')
{ {
$this->id=-1; $this->id=-1;
if ($ncat_id) { $filter = 'tid=n,cat_id='.$ncat_id; } if ($ncat_id)
else { $filter = 'tid=n'; } {
$filter = 'tid=n,cat_id='.$ncat_id;
}
else
{
$filter = 'tid=n';
}
$this->contacts = CreateObject('phpgwapi.contacts'); $this->contacts = CreateObject('phpgwapi.contacts');
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter); $tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter);
@ -126,10 +132,9 @@
// Tack on some extra values // Tack on some extra values
function export_end_record($buffer) function export_end_record($buffer)
{ {
global $phpgw_info; if ($GLOBALS['phpgw_info']['server']['ldap_contact_context'])
if ($phpgw_info['server']['ldap_contact_context'])
{ {
$context = $phpgw_info['server']['ldap_contact_context']; $context = $GLOBALS['phpgw_info']['server']['ldap_contact_context'];
} }
$time = gettimeofday(); $time = gettimeofday();
$cn = ereg_replace(',','',$buffer[$this->id]['cn']); $cn = ereg_replace(',','',$buffer[$this->id]['cn']);
@ -144,7 +149,8 @@
return $buffer; return $buffer;
} }
function export_end_file($buffer) { function export_end_file($buffer)
{
reset($this->ids); reset($this->ids);
for ($i=0;$i<count($this->ids);$i++) for ($i=0;$i<count($this->ids);$i++)
{ {

View File

@ -24,74 +24,82 @@
var $type = 'sql'; var $type = 'sql';
var $export= array( var $export= array(
"id" => "id", 'id' => 'id',
"lid" => "lid", 'lid' => 'lid',
"tid" => "tid", 'tid' => 'tid',
"owner" => "owner", 'owner' => 'owner',
"fn" => "fn", 'fn' => 'fn',
"n_given" => "n_given", 'n_given' => 'n_given',
"n_family" => "n_family", 'n_family' => 'n_family',
"n_middle" => "n_middle", 'n_middle' => 'n_middle',
"n_prefix" => "n_prefix", 'n_prefix' => 'n_prefix',
"n_suffix" => "n_suffix", 'n_suffix' => 'n_suffix',
"sound" => "sound", 'sound' => 'sound',
"bday" => "bday", 'bday' => 'bday',
"note" => "note", 'note' => 'note',
"tz" => "tz", 'tz' => 'tz',
"geo" => "geo", 'geo' => 'geo',
"url" => "url", 'url' => 'url',
"pubkey" => "pubkey", 'pubkey' => 'pubkey',
"org_name" => "org_name", 'org_name' => 'org_name',
"org_unit" => "org_unit", 'org_unit' => 'org_unit',
"title" => "title", 'title' => 'title',
"adr_one_street" => "adr_one_street", 'adr_one_street' => 'adr_one_street',
"adr_one_locality" => "adr_one_locality", 'adr_one_locality' => 'adr_one_locality',
"adr_one_region" => "adr_one_region", 'adr_one_region' => 'adr_one_region',
"adr_one_postalcode" => "adr_one_postalcode", 'adr_one_postalcode' => 'adr_one_postalcode',
"adr_one_countryname" => "adr_one_countryname", 'adr_one_countryname' => 'adr_one_countryname',
"adr_one_type" => "adr_one_type", 'adr_one_type' => 'adr_one_type',
"label" => "label", 'label' => 'label',
"adr_two_street" => "adr_two_street", 'adr_two_street' => 'adr_two_street',
"adr_two_locality" => "adr_two_locality", 'adr_two_locality' => 'adr_two_locality',
"adr_two_region" => "adr_two_region", 'adr_two_region' => 'adr_two_region',
"adr_two_postalcode" => "adr_two_postalcode", 'adr_two_postalcode' => 'adr_two_postalcode',
"adr_two_countryname" => "adr_two_countryname", 'adr_two_countryname' => 'adr_two_countryname',
"adr_two_type" => "adr_two_type", 'adr_two_type' => 'adr_two_type',
"tel_work" => "tel_work", 'tel_work' => 'tel_work',
"tel_home" => "tel_home", 'tel_home' => 'tel_home',
"tel_voice" => "tel_voice", 'tel_voice' => 'tel_voice',
"tel_fax" => "tel_fax", 'tel_fax' => 'tel_fax',
"tel_msg" => "tel_msg", 'tel_msg' => 'tel_msg',
"tel_cell" => "tel_cell", 'tel_cell' => 'tel_cell',
"tel_pager" => "tel_pager", 'tel_pager' => 'tel_pager',
"tel_bbs" => "tel_bbs", 'tel_bbs' => 'tel_bbs',
"tel_modem" => "tel_modem", 'tel_modem' => 'tel_modem',
"tel_car" => "tel_car", 'tel_car' => 'tel_car',
"tel_isdn" => "tel_isdn", 'tel_isdn' => 'tel_isdn',
"tel_video" => "tel_video", 'tel_video' => 'tel_video',
"tel_prefer" => "tel_prefer", 'tel_prefer' => 'tel_prefer',
"email" => "email", 'email' => 'email',
"email_type" => "email_type", 'email_type' => 'email_type',
"email_home" => "email_home", 'email_home' => 'email_home',
"email_home_type" => "email_home_type" 'email_home_type' => 'email_home_type'
); );
// This will store the contacts object // This will store the contacts object
var $contacts = ''; var $contacts = '';
// Read full list of user's contacts only to get id's for each // 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; $this->id=-1;
if ($ncat_id) { $filter = "tid=n,cat_id=".$ncat_id; } if ($ncat_id)
else { $filter = "tid=n"; } {
$filter = 'tid=n,cat_id=' . $ncat_id;
}
else
{
$filter = 'tid=n';
}
$this->contacts = CreateObject('phpgwapi.contacts'); $this->contacts = CreateObject('phpgwapi.contacts');
$tmp = $this->contacts->read('','',array('id'=>'id'),'',$filter); $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']; $this->ids[$i] = $tmp[$i]['id'];
} }
// $ids is now an array of all id's for this user, e.g. $ids[0] = 21, etc... // $ids is now an array of all id's for this user, e.g. $ids[0] = 21, etc...
@ -100,7 +108,8 @@
} }
// Read each entry // Read each entry
function export_start_record($buffer) { function export_start_record($buffer)
{
$this->id++; $this->id++;
$top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields); $top = $this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
$this->currentrecord = $top[0]; $this->currentrecord = $top[0];
@ -109,8 +118,10 @@
// Read each attribute, populate buffer array // Read each attribute, populate buffer array
// name/value are the fields from the export array above // name/value are the fields from the export array above
function export_new_attrib($buffer,$name,$value) { function export_new_attrib($buffer,$name,$value)
if ($this->export[$name]) { {
if ($this->export[$name])
{
$buffer[$this->id][$this->export[$name]] = $value; $buffer[$this->id][$this->export[$name]] = $value;
//echo '<br>'.$this->id.' - '.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]]; //echo '<br>'.$this->id.' - '.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]];
} }
@ -118,18 +129,22 @@
} }
// Tack on some extra values - none for this file // Tack on some extra values - none for this file
function export_end_record($buffer) { function export_end_record($buffer)
{
return $buffer; return $buffer;
} }
// Parse it all into a string // Parse it all into a string
function export_end_file($buffer) { function export_end_file($buffer)
{
$top = 'INSERT INTO phpgw_addressbook('; $top = 'INSERT INTO phpgw_addressbook(';
reset($this->ids); reset($this->ids);
for ($i=0;$i<count($this->ids);$i++) { for ($i=0;$i<count($this->ids);$i++)
{
reset($this->export); reset($this->export);
$fields = $values = ""; $fields = $values = "";
while (list($name,$value) = each($this->export)) { while (list($name,$value) = each($this->export))
{
$fields .= $value . ","; $fields .= $value . ",";
$values .= "'" . $buffer[$i][$value] . "',"; $values .= "'" . $buffer[$i][$value] . "',";
} }