From b4e366ddc08390af12d235de9cbd32c77897b485 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Tue, 4 Dec 2001 01:26:53 +0000 Subject: [PATCH] formatting and globals, what else? --- addressbook/inc/export/Multiple_VCard | 10 +- addressbook/inc/export/Netscape_LDIF | 10 +- addressbook/inc/export/Outlook_CSV_-_Deutsch | 12 +- addressbook/inc/export/Outlook_CSV_-_English | 12 +- addressbook/inc/export/Palm_PDB | 10 +- addressbook/inc/export/phpgw_LDIF | 18 ++- addressbook/inc/export/phpgw_SQL | 137 ++++++++++--------- 7 files changed, 130 insertions(+), 79 deletions(-) diff --git a/addressbook/inc/export/Multiple_VCard b/addressbook/inc/export/Multiple_VCard index 6dab265cbc..04a0ecaf28 100644 --- a/addressbook/inc/export/Multiple_VCard +++ b/addressbook/inc/export/Multiple_VCard @@ -92,8 +92,14 @@ 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'); diff --git a/addressbook/inc/export/Netscape_LDIF b/addressbook/inc/export/Netscape_LDIF index bc2e1d2a46..dd413c4525 100644 --- a/addressbook/inc/export/Netscape_LDIF +++ b/addressbook/inc/export/Netscape_LDIF @@ -54,8 +54,14 @@ 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); diff --git a/addressbook/inc/export/Outlook_CSV_-_Deutsch b/addressbook/inc/export/Outlook_CSV_-_Deutsch index 1b4bb0aa62..8db17955ce 100644 --- a/addressbook/inc/export/Outlook_CSV_-_Deutsch +++ b/addressbook/inc/export/Outlook_CSV_-_Deutsch @@ -71,8 +71,14 @@ 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); @@ -120,7 +126,7 @@ { $entries .= $value . ','; } - $entries = substr($entries,0,-1); + $entries = substr($entries,0,-1); $entries .= "\r\n"; // Now add all the data diff --git a/addressbook/inc/export/Outlook_CSV_-_English b/addressbook/inc/export/Outlook_CSV_-_English index 27616b64d7..334a9b532e 100644 --- a/addressbook/inc/export/Outlook_CSV_-_English +++ b/addressbook/inc/export/Outlook_CSV_-_English @@ -71,8 +71,14 @@ 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); @@ -120,7 +126,7 @@ { $entries .= $value . ','; } - $entries = substr($entries,0,-1); + $entries = substr($entries,0,-1); $entries .= "\r\n"; // Now add all the data diff --git a/addressbook/inc/export/Palm_PDB b/addressbook/inc/export/Palm_PDB index 5620fefb5f..57101340a6 100644 --- a/addressbook/inc/export/Palm_PDB +++ b/addressbook/inc/export/Palm_PDB @@ -66,8 +66,14 @@ 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); diff --git a/addressbook/inc/export/phpgw_LDIF b/addressbook/inc/export/phpgw_LDIF index e4de5c354b..5388845114 100644 --- a/addressbook/inc/export/phpgw_LDIF +++ b/addressbook/inc/export/phpgw_LDIF @@ -88,8 +88,14 @@ 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); @@ -126,10 +132,9 @@ // Tack on some extra values function export_end_record($buffer) { - global $phpgw_info; - if ($phpgw_info['server']['ldap_contact_context']) + if ($GLOBALS['phpgw_info']['server']['ldap_contact_context']) { - $context = $phpgw_info['server']['ldap_contact_context']; + $context = $GLOBALS['phpgw_info']['server']['ldap_contact_context']; } $time = gettimeofday(); $cn = ereg_replace(',','',$buffer[$this->id]['cn']); @@ -144,7 +149,8 @@ return $buffer; } - function export_end_file($buffer) { + function export_end_file($buffer) + { reset($this->ids); for ($i=0;$iids);$i++) { diff --git a/addressbook/inc/export/phpgw_SQL b/addressbook/inc/export/phpgw_SQL index 4138ff8464..66b5ed1e4b 100644 --- a/addressbook/inc/export/phpgw_SQL +++ b/addressbook/inc/export/phpgw_SQL @@ -24,74 +24,82 @@ 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", + '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", + '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_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", + '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" + '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='') { + 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;$iids[$i] = $tmp[$i]['id']; } // $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 - 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]; @@ -109,8 +118,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 '
'.$this->id.' - '.$this->export[$name].': '.$buffer[$this->id][$this->export[$name]]; } @@ -118,18 +129,22 @@ } // 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) + { $top = 'INSERT INTO phpgw_addressbook('; reset($this->ids); - for ($i=0;$iids);$i++) { + for ($i=0;$iids);$i++) + { reset($this->export); $fields = $values = ""; - while (list($name,$value) = each($this->export)) { + while (list($name,$value) = each($this->export)) + { $fields .= $value . ","; $values .= "'" . $buffer[$i][$value] . "',"; }