[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] addressbook/inc/export Outlook_CSV_-_Deutsch, 1.3 Out
From: |
skwashd |
Subject: |
[Phpgroupware-cvs] addressbook/inc/export Outlook_CSV_-_Deutsch, 1.3 Outlook_CSV_-_English, 1.3 Palm_PDB, 1.3 Netscape_LDIF, 1.3 Multiple_VCard, 1.3 phpgw_LDIF, 1.3 phpgw_SQL, 1.3 OpenOffice_-_writer, 1.2 OpenOffice_-_calc, 1.2 sample.sxc, 1.2 sample.sxw, 1.2 |
Date: |
Thu, 24 Feb 2005 13:22:06 -0000 |
Update of addressbook/inc/export
Modified Files:
Branch: MAIN
Outlook_CSV_-_Deutsch lines: +91 -28
Outlook_CSV_-_English lines: +108 -42
Palm_PDB lines: +105 -41
Netscape_LDIF lines: +79 -29
Multiple_VCard lines: +91 -65
phpgw_LDIF lines: +85 -71
phpgw_SQL lines: +228 -81
Added Files:
Branch: MAIN
OpenOffice_-_writer lines: +474 -0
OpenOffice_-_calc lines: +499 -0
sample.sxc lines: +41 -0
sample.sxw lines: +44 -0
Log Message:
merge from 16
====================================================
Index: addressbook/inc/export/Outlook_CSV_-_Deutsch
diff -u addressbook/inc/export/Outlook_CSV_-_Deutsch:1.2
addressbook/inc/export/Outlook_CSV_-_Deutsch:1.3
--- addressbook/inc/export/Outlook_CSV_-_Deutsch:1.2 Tue Dec 4 01:26:53 2001
+++ addressbook/inc/export/Outlook_CSV_-_Deutsch Fri Dec 31 04:55:24 2004
@@ -30,25 +30,25 @@
var $type = 'csv';
var $export = array(
- 'title' => 'Anrede',
- 'n_given' => 'Vorname',
- 'n_middle' => 'Weitere Vornamen',
- 'n_family' => 'Nachname',
- 'n_suffix' => 'Suffix',
- 'org_name' => 'Firma',
- 'org_unit' => 'Abteilung',
- 'adr_one_street' => 'Straße geschäftlich',
- 'address2' => 'Straße geschäftlich 2',
- 'address3' => 'Straße geschäftlich 3',
- 'adr_one_locality' => 'Ort geschäftlich',
- 'adr_one_region' => 'Region geschäftlich',
- 'adr_one_postalcode' => 'Postleitzahl geschäftlich',
- 'adr_one_countryname' => 'Land geschäftlich',
- 'adr_two_street' => 'Straße privat',
- 'adr_two_locality' => 'Ort privat',
- 'adr_two_region' => 'Region privat',
- 'adr_two_postalcode' => 'Postleitzahl privat',
- 'adr_two_countryname' => 'Land privat',
+ 'title' => 'Anrede',
+ 'first_name' => 'Vorname',
+ 'middle_name' => 'Weitere Vornamen',
+ 'last_name' => 'Nachname',
+ 'suffix' => 'Suffix',
+ 'org_name' => 'Firma',
+ 'department' => 'Abteilung',
+ 'work_add1' => 'Straße geschäftlich',
+ 'work_add2' => 'Straße geschäftlich 2',
+ 'work_add3' => 'Straße geschäftlich 3',
+ 'work_city' => 'Ort geschäftlich',
+ 'work_state' => 'Region geschäftlich',
+ 'work_postal_code' => 'Postleitzahl geschäftlich',
+ 'work_country' => 'Land geschäftlich',
+ 'home_add1' => 'Straße privat',
+ 'home_city' => 'Ort privat',
+ 'home_state' => 'Region privat',
+ 'home_postal_code' => 'Postleitzahl privat',
+ 'home_country' => 'Land privat',
'tel_fax' => 'Fax geschäftlich',
'tel_work' => 'Telefon geschäftlich',
'tel_msg' => 'Telefon Assistent',
@@ -70,22 +70,30 @@
function export_start_file($buffer,$ncat_id='')
{
+ $this->contacts = CreateObject('phpgwapi.contacts');
+
$this->id=-1;
+ $fields = array('person_id');
+
if ($ncat_id)
{
- $filter = 'tid=n,cat_id='.$ncat_id;
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL, $ncat_id);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
else
{
- $filter = 'tid=n';
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
- $this->contacts = CreateObject('phpgwapi.contacts');
- $tmp =
$this->contacts->read('','',array('id'=>'id'),'',$filter);
- for ($i=0;$i<count($tmp);$i++)
+ if(is_array($tmp_person))
{
- $this->ids[$i] = $tmp[$i]['id'];
+ foreach($tmp_person as $data)
+ {
+ $this->ids[] = $data['person_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;
@@ -95,8 +103,63 @@
function export_start_record($buffer)
{
$this->id++;
- $top =
$this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
- $this->currentrecord = $top[0];
+ $top =
$this->contacts->person_complete_data($this->ids[$this->id]);
+
+ if(is_array($top['locations']))
+ {
+ foreach($top['locations'] as $key => $values)
+ {
+ if($values['type']=='work')
+ {
+ $work_type = $key;
+ }
+ elseif($values['type']=='home')
+ {
+ $home_type = $key;
+ }
+ }
+ }
+
+ if(is_array($top['notes']))
+ {
+ $note_id = key($top['notes']);
+ }
+
+ $record['title'] = $top['title'];
+ $record['first_name'] = $top['first_name'];
+ $record['middle_name'] = $top['middle_name'];
+ $record['last_name'] = $top['last_name'];
+ $record['suffix'] = $top['suffix'];
+ $record['org_name'] = $top['org_name'];
+ $record['department'] = $top['department'];
+ $record['work_add1'] =
$top['locations'][$work_type]['add1'];
+ $record['work_add2'] =
$top['locations'][$work_type]['add2'];
+ $record['work_add3'] =
$top['locations'][$work_type]['add3'];
+ $record['work_city'] =
$top['locations'][$work_type]['city'];
+ $record['work_state'] =
$top['locations'][$work_type]['state'];
+ $record['work_postal_code'] =
$top['locations'][$work_type]['postal_code'];
+ $record['work_country'] =
$top['locations'][$work_type]['country'];
+ $record['home_add1'] =
$top['locations'][$home_type]['add1'];
+ $record['home_city'] =
$top['locations'][$home_type]['city'];
+ $record['home_state'] =
$top['locations'][$home_type]['state'];
+ $record['home_postal_code'] =
$top['locations'][$home_type]['postal_code'];
+ $record['home_country'] =
$top['locations'][$home_type]['country'];
+ $record['tel_fax'] =
$top['comm_media']['work fax'];
+ $record['tel_work'] =
$top['comm_media']['work phone'];
+ $record['tel_msg'] =
$top['comm_media']['msg phone'];
+ $record['tel_car'] =
$top['comm_media']['car phone'];
+ $record['tel_isdn'] =
$top['comm_media']['isdn'];
+ $record['tel_home'] =
$top['comm_media']['home phone'];
+ $record['tel_cell'] =
$top['comm_media']['mobile (cell) phone'];
+ $record['tel_pager'] =
$top['comm_media']['pager'];
+ $record['ophone'] =
$top['comm_media']['voice phone'];
+ $record['bday'] =
$top['comm_media']['birthday'];
+ $record['email'] =
$top['comm_media']['work email'];
+ $record['email_home'] =
$top['comm_media']['home email'];
+ $record['url'] =
$top['comm_media']['website'];
+ $record['note'] =
$top['notes'][$note_id]['text'];
+
+ $this->currentrecord = $record;
return $buffer;
}
@@ -136,7 +199,7 @@
reset($this->export);
while (list($name,$value)=each($this->export))
{
- $entries .= $buffer[$i][$value] . ',';
+ $entries .= '"'.$buffer[$i][$value] .
'",';
}
$entries = substr($entries,0,-1);
$entries .= "\r\n";
====================================================
Index: addressbook/inc/export/Outlook_CSV_-_English
diff -u addressbook/inc/export/Outlook_CSV_-_English:1.2
addressbook/inc/export/Outlook_CSV_-_English:1.3
--- addressbook/inc/export/Outlook_CSV_-_English:1.2 Tue Dec 4 01:26:53 2001
+++ addressbook/inc/export/Outlook_CSV_-_English Fri Dec 31 04:55:24 2004
@@ -30,39 +30,39 @@
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',
+ 'first_name' => 'First Name',
+ 'middle_name' => 'Middle Name',
+ 'last_name' => 'Last Name',
+ 'suffix' => 'Suffix',
+ 'org_name' => 'Company',
+ 'department' => 'Department',
+ 'work_add1' => 'Business Street',
+ 'work_add2' => 'Business Street 2',
+ 'work_add3' => 'Business Street 3',
+ 'work_city' => 'Business City',
+ 'work_state' => 'Business State',
+ 'work_postal_code' => 'Business Postal Code',
+ 'work_country' => 'Business Country',
+ 'home_add1' => 'Home Street',
+ 'home_city' => 'Home City',
+ 'home_state' => 'Home State',
+ 'home_postal_code' => 'Home Postal Code',
+ 'home_country' => '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
@@ -70,22 +70,30 @@
function export_start_file($buffer,$ncat_id='')
{
+ $this->contacts = CreateObject('phpgwapi.contacts');
+
$this->id=-1;
+ $fields = array('person_id');
+
if ($ncat_id)
{
- $filter = 'tid=n,cat_id='.$ncat_id;
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL, $ncat_id);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
else
{
- $filter = 'tid=n';
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
- $this->contacts = CreateObject('phpgwapi.contacts');
- $tmp =
$this->contacts->read('','',array('id'=>'id'),'',$filter);
- for ($i=0;$i<count($tmp);$i++)
+ if(is_array($tmp_person))
{
- $this->ids[$i] = $tmp[$i]['id'];
+ foreach($tmp_person as $data)
+ {
+ $this->ids[] = $data['person_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;
@@ -95,8 +103,66 @@
function export_start_record($buffer)
{
$this->id++;
- $top =
$this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
- $this->currentrecord = $top[0];
+
+ $top =
$this->contacts->person_complete_data($this->ids[$this->id]);
+
+ if(is_array($top['locations']))
+ {
+ foreach($top['locations'] as $key => $values)
+ {
+ if($values['type']=='work')
+ {
+ $work_type = $key;
+ }
+ elseif($values['type']=='home')
+ {
+ $home_type = $key;
+ }
+ }
+ }
+
+ if(is_array($top['notes']))
+ {
+ $note_id = key($top['notes']);
+ }
+
+
+
+ $record['title'] = $top['title'];
+ $record['first_name'] = $top['first_name'];
+ $record['middle_name'] = $top['middle_name'];
+ $record['last_name'] = $top['last_name'];
+ $record['suffix'] = $top['suffix'];
+ $record['org_name'] = $top['org_name'];
+ $record['department'] = $top['department'];
+ $record['work_add1'] =
$top['locations'][$work_type]['add1'];
+ $record['work_add2'] =
$top['locations'][$work_type]['add2'];
+ $record['work_add3'] =
$top['locations'][$work_type]['add3'];
+ $record['work_city'] =
$top['locations'][$work_type]['city'];
+ $record['work_state'] =
$top['locations'][$work_type]['state'];
+ $record['work_postal_code'] =
$top['locations'][$work_type]['postal_code'];
+ $record['work_country'] =
$top['locations'][$work_type]['country'];
+ $record['home_add1'] =
$top['locations'][$home_type]['add1'];
+ $record['home_city'] =
$top['locations'][$home_type]['city'];
+ $record['home_state'] =
$top['locations'][$home_type]['state'];
+ $record['home_postal_code'] =
$top['locations'][$home_type]['postal_code'];
+ $record['home_country'] =
$top['locations'][$home_type]['country'];
+ $record['tel_fax'] =
$top['comm_media']['work fax'];
+ $record['tel_work'] =
$top['comm_media']['work phone'];
+ $record['tel_msg'] =
$top['comm_media']['msg phone'];
+ $record['tel_car'] =
$top['comm_media']['car phone'];
+ $record['tel_isdn'] =
$top['comm_media']['isdn'];
+ $record['tel_home'] =
$top['comm_media']['home phone'];
+ $record['tel_cell'] =
$top['comm_media']['mobile (cell) phone'];
+ $record['tel_pager'] =
$top['comm_media']['pager'];
+ $record['ophone'] =
$top['comm_media']['voice phone'];
+ $record['bday'] =
$top['comm_media']['birthday'];
+ $record['email'] =
$top['comm_media']['work email'];
+ $record['email_home'] =
$top['comm_media']['home email'];
+ $record['url'] =
$top['comm_media']['website'];
+ $record['note'] =
$top['notes'][$note_id]['text'];
+
+ $this->currentrecord = $record;
return $buffer;
}
@@ -136,7 +202,7 @@
reset($this->export);
while (list($name,$value)=each($this->export))
{
- $entries .= $buffer[$i][$value] . ',';
+ $entries .= '"'.$buffer[$i][$value] .
'",';
}
$entries = substr($entries,0,-1);
$entries .= "\r\n";
====================================================
Index: addressbook/inc/export/Palm_PDB
diff -u addressbook/inc/export/Palm_PDB:1.2 addressbook/inc/export/Palm_PDB:1.3
--- addressbook/inc/export/Palm_PDB:1.2 Tue Dec 4 01:26:53 2001
+++ addressbook/inc/export/Palm_PDB Fri Dec 31 04:55:24 2004
@@ -24,39 +24,39 @@
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',
+ 'first_name' => 'First',
+ 'middle_name' => 'Middle',
+ 'last_name' => 'Last',
+ 'suffix' => 'Suffix',
+ 'org_name' => 'Company',
+ 'department' => 'Dept',
+ 'work_add1' => 'Bus. Street',
+ 'work_add2' => 'Bus. St. 2',
+ 'work_add3' => 'Bus. St. 3',
+ 'work_city' => 'Bus. City',
+ 'work_state' => 'Bus. State',
+ 'work_postal_code' => 'Bus. Postal Code',
+ 'work_country' => 'Bus. Country',
+ 'home_add1' => 'Home Street',
+ 'home_city' => 'Home City',
+ 'home_state' => 'Home State',
+ 'home_postal_code' => 'Home Postal Code',
+ 'home_country' => '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
@@ -65,22 +65,30 @@
// Read full list of user's contacts only to get id's for each
function export_start_file($buffer,$ncat_id='')
{
+ $this->contacts = CreateObject('phpgwapi.contacts');
+
$this->id=-1;
+ $fields = array('person_id');
+
if ($ncat_id)
{
- $filter = 'tid=n,cat_id='.$ncat_id;
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL, $ncat_id);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
else
{
- $filter = 'tid=n';
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
- $this->contacts = CreateObject('phpgwapi.contacts');
- $tmp =
$this->contacts->read('','',array('id'=>'id'),'',$filter);
- for ($i=0;$i<count($tmp);$i++)
+ if(is_array($tmp_person))
{
- $this->ids[$i] = $tmp[$i]['id'];
+ foreach($tmp_person as $data)
+ {
+ $this->ids[] = $data['person_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;
@@ -90,8 +98,64 @@
function export_start_record($buffer)
{
$this->id++;
- $top =
$this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
- $this->currentrecord = $top[0];
+
+ $top =
$this->contacts->person_complete_data($this->ids[$this->id]);
+
+ if(is_array($top['locations']))
+ {
+ foreach($top['locations'] as $key => $values)
+ {
+ if($values['type']=='work')
+ {
+ $work_type = $key;
+ }
+ elseif($values['type']=='home')
+ {
+ $home_type = $key;
+ }
+ }
+ }
+
+ if(is_array($top['notes']))
+ {
+ $note_id = key($top['notes']);
+ }
+
+ $record['title'] = $top['title'];
+ $record['first_name'] = $top['first_name'];
+ $record['middle_name'] = $top['middle_name'];
+ $record['last_name'] = $top['last_name'];
+ $record['suffix'] = $top['suffix'];
+ $record['org_name'] = $top['org_name'];
+ $record['department'] = $top['department'];
+ $record['work_add1'] =
$top['locations'][$work_type]['add1'];
+ $record['work_add2'] =
$top['locations'][$work_type]['add2'];
+ $record['work_add3'] =
$top['locations'][$work_type]['add3'];
+ $record['work_city'] =
$top['locations'][$work_type]['city'];
+ $record['work_state'] =
$top['locations'][$work_type]['state'];
+ $record['work_postal_code'] =
$top['locations'][$work_type]['postal_code'];
+ $record['work_country'] =
$top['locations'][$work_type]['country'];
+ $record['home_add1'] =
$top['locations'][$home_type]['add1'];
+ $record['home_city'] =
$top['locations'][$home_type]['city'];
+ $record['home_state'] =
$top['locations'][$home_type]['state'];
+ $record['home_postal_code'] =
$top['locations'][$home_type]['postal_code'];
+ $record['home_country'] =
$top['locations'][$home_type]['country'];
+ $record['tel_fax'] =
$top['comm_media']['work fax'];
+ $record['tel_work'] =
$top['comm_media']['work phone'];
+ $record['tel_msg'] =
$top['comm_media']['msg phone'];
+ $record['tel_car'] =
$top['comm_media']['car phone'];
+ $record['tel_isdn'] =
$top['comm_media']['isdn'];
+ $record['tel_home'] =
$top['comm_media']['home phone'];
+ $record['tel_cell'] =
$top['comm_media']['mobile (cell) phone'];
+ $record['tel_pager'] =
$top['comm_media']['pager'];
+ $record['ophone'] =
$top['comm_media']['voice phone'];
+ $record['bday'] =
$top['comm_media']['birthday'];
+ $record['email'] =
$top['comm_media']['work email'];
+ $record['email_home'] =
$top['comm_media']['home email'];
+ $record['url'] =
$top['comm_media']['website'];
+ $record['note'] =
$top['notes'][$note_id]['text'];
+
+ $this->currentrecord = $record;
return $buffer;
}
====================================================
Index: addressbook/inc/export/Netscape_LDIF
diff -u addressbook/inc/export/Netscape_LDIF:1.2
addressbook/inc/export/Netscape_LDIF:1.3
--- addressbook/inc/export/Netscape_LDIF:1.2 Tue Dec 4 01:26:53 2001
+++ addressbook/inc/export/Netscape_LDIF Fri Dec 31 04:55:24 2004
@@ -24,27 +24,27 @@
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',
+ 'first_name' => 'givenname',
+ 'last_name' => 'sn',
+ 'full_name' => 'cn',
+ 'org_name' => 'o',
+ 'department' => 'ou',
+ 'add1' => 'streetaddress',
+ 'city' => 'locality',
+ 'state' => 'st',
+ 'postal_code' => 'postalcode',
+ 'country' => '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
@@ -53,22 +53,30 @@
// Read full list of user's contacts only to get id's for each
function export_start_file($buffer,$ncat_id='')
{
+ $this->contacts = CreateObject('phpgwapi.contacts');
+
$this->id=-1;
+
+ $fields = array('person_id');
if ($ncat_id)
{
- $filter = 'tid=n,cat_id=' . $ncat_id;
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL, $ncat_id);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
else
{
- $filter = 'tid=n';
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
- $this->contacts = CreateObject('phpgwapi.contacts');
- $tmp =
$this->contacts->read('','',array('id'=>'id'),'',$filter);
- for ($i=0;$i<count($tmp);$i++)
+ if(is_array($tmp_person))
{
- $this->ids[$i] = $tmp[$i]['id'];
+ foreach($tmp_person as $data)
+ {
+ $this->ids[] = $data['person_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;
@@ -78,8 +86,50 @@
function export_start_record($buffer)
{
$this->id++;
- $top =
$this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
- $this->currentrecord = $top[0];
+ //$top =
$this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
+ //$this->currentrecord = $top[0];
+ $record =
$this->contacts->person_complete_data($this->ids[$this->id]);
+
+ if(is_array($record['locations']))
+ {
+ foreach($record['locations'] as $key => $values)
+ {
+ if($values['preferred']=='Y')
+ {
+ $loc_id = $key;
+ }
+ }
+ }
+
+ if(is_array($record['notes']))
+ {
+ $note_id = key($record['notes']);
+ }
+
+ $currentrecord['title'] = $record['title'];
+ $currentrecord['first_name'] = $record['first_name'];
+ $currentrecord['last_name'] = $record['last_name'];
+ $currentrecord['full_name'] = $record['full_name'];
+ $currentrecord['org_name'] = $record['org_name'];
+ $currentrecord['department'] = $record['department'];
+ $currentrecord['add1'] =
$record['locations'][$loc_id]['add1'] .
+
($record['locations'][$loc_id]['add2']?'
'.$record['locations'][$loc_id]['add2']:'') .
+
($record['locations'][$loc_id]['add3']?'
'.$record['locations'][$loc_id]['add3']:'');
+ $currentrecord['city'] =
$record['locations'][$loc_id]['city'];
+ $currentrecord['state'] =
$record['locations'][$loc_id]['state'];
+ $currentrecord['postal_code'] =
$record['locations'][$loc_id]['postal_code'];
+ $currentrecord['country'] =
$record['locations'][$loc_id]['country'];
+ $currentrecord['note'] =
$record['notes'][$note_id]['text'];
+ $currentrecord['tel_work'] =
$record['comm_media']['work phone'];
+ $currentrecord['tel_home'] =
$record['comm_media']['home phone'];
+ $currentrecord['tel_fax'] =
$record['comm_media']['work fax'];
+ $currentrecord['ophone'] =
$record['comm_media']['voice phone'];
+ $currentrecord['tel_cell'] =
$record['comm_media']['mobile (cell) phone'];
+ $currentrecord['ophone'] =
$record['comm_media']['voice phone'];
+ $currentrecord['tel_pager'] =
$record['comm_media']['pager'];
+ $currentrecord['email'] =
$record['comm_media']['work email'];
+ $currentrecord['url'] =
$record['comm_media']['website'];
+ $this->currentrecord = $currentrecord;
return $buffer;
}
====================================================
Index: addressbook/inc/export/Multiple_VCard
diff -u addressbook/inc/export/Multiple_VCard:1.2
addressbook/inc/export/Multiple_VCard:1.3
--- addressbook/inc/export/Multiple_VCard:1.2 Tue Dec 4 01:26:53 2001
+++ addressbook/inc/export/Multiple_VCard Fri Dec 31 04:55:24 2004
@@ -30,60 +30,6 @@
/* 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 = '';
@@ -91,25 +37,34 @@
/* Read full list of user's contacts only to get id's for each
*/
function export_start_file($buffer,$ncat_id='')
{
+ /* 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;
+
$this->id=-1;
+
+ $fields = array('person_id');
if ($ncat_id)
{
- $filter = 'tid=n,cat_id='.$ncat_id;
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL, $ncat_id);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
else
{
- $filter = 'tid=n';
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
- /* 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++)
+ if(is_array($tmp_person))
{
- $this->ids[$i] = $tmp[$i]['id'];
+ foreach($tmp_person as $data)
+ {
+ $this->ids[] = $data['person_id'];
+ }
}
+
+
/*
$ids is now an array of all id's for this user, e.g.
$ids[0] = 21, etc...
$buffer is still empty
@@ -121,8 +76,79 @@
function export_start_record($buffer)
{
$this->id++;
- $top =
$this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
- $this->currentrecord = $top[0];
+ //$top =
$this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
+ $fieldlist =
$this->contacts->person_complete_data($this->ids[$this->id]);
+
+ if(is_array($fieldlist['locations']))
+ {
+ foreach($fieldlist['locations'] as $key =>
$values)
+ {
+ if($values['type']=='work')
+ {
+ $type_work = $key;
+ }
+ elseif($values['type']=='home')
+ {
+ $type_home = $key;
+ }
+ }
+ }
+
+ $fields['first_name'] =
$fieldlist['first_name'];
+ $fields['last_name'] =
$fieldlist['last_name'];
+ $fields['middle_name'] =
$fieldlist['middle_name'];
+
+ $fields['full_name'] =
$fields['first_name'] . ' ';
+ $fields['full_name'] .=
($fields['middle_name'] != '') ? $fields['middle_name'] . ' ' : '';
+ $fields['full_name'] .= $fields['last_name'];
+
+ $fields['prefix'] = $fieldlist['prefix'];
+ $fields['suffix'] = $fieldlist['suffix'];
+ $fields['sound'] = $fieldlist['sound'];
+ $fields['birthday'] =
$fieldlist['birthday'];
+ //$fields['note'] = $fieldlist[''];
+ //$fields['tz'] =
$fieldlist['locations'][$type_work][''];
+ //$fields['geo'] = $fieldlist[''];
+ $fields['pubkey'] = $fieldlist['pubkey'];
+ $fields['org_name'] =
$fieldlist['org_name'];
+ $fields['org_unit'] =
$fieldlist['department'];
+ $fields['title'] = $fieldlist['title'];
+ $fields['adr_one_type'] = 'WORK';
+ $fields['adr_two_type'] = 'HOME';
+ //$fields['tel_prefer'] = $fieldlist[''];
+ $fields['email_type'] = 'INTERNET';
+ $fields['email_home_type'] = 'INTERNET';
+ $fields['adr_one_street'] =
$fieldlist['locations'][$type_work]['add1'];
+ $fields['adr_one_ext'] =
$fieldlist['locations'][$type_work]['add2'];
+ $fields['adr_one_locality'] =
$fieldlist['locations'][$type_work]['city'];
+ $fields['adr_one_region'] =
$fieldlist['locations'][$type_work]['state'];
+ $fields['adr_one_postalcode'] =
$fieldlist['locations'][$type_work]['postal_code'];
+ $fields['adr_one_countryname'] =
$fieldlist['locations'][$type_work]['country'];
+ //$fields['address2'] =
$fieldlist['locations'][$type_work]['add2'];
+ //$fields['label'] =
$fieldlist['locations'][$type_work]['add1'].'
'.$fieldlist['locations'][$type_work]['add2'];;
+ $fields['adr_two_street'] =
$fieldlist['locations'][$type_home]['add1'];
+ $fields['adr_two_ext'] =
$fieldlist['locations'][$type_home]['add2'];
+ $fields['adr_two_locality'] =
$fieldlist['locations'][$type_home]['city'];
+ $fields['adr_two_region'] =
$fieldlist['locations'][$type_home]['state'];
+ $fields['adr_two_postalcode'] =
$fieldlist['locations'][$type_home]['postal_code'];
+ $fields['adr_two_countryname'] =
$fieldlist['locations'][$type_home]['country'];
+ $fields['tel_work'] =
$fieldlist['comm_media']['work phone'];
+ $fields['tel_home'] =
$fieldlist['comm_media']['home phone'];
+ $fields['tel_voice'] =
$fieldlist['comm_media']['voice phone'];
+ $fields['tel_work_fax'] =
$fieldlist['comm_media']['work fax'];
+ $fields['tel_home_fax'] =
$fieldlist['comm_media']['home fax'];
+ $fields['tel_msg'] =
$fieldlist['comm_media']['msg phone'];
+ $fields['tel_cell'] =
$fieldlist['comm_media']['mobile (cell) phone'];
+ $fields['tel_pager'] =
$fieldlist['comm_media']['pager'];
+ $fields['tel_bbs'] =
$fieldlist['comm_media']['bbs'];
+ $fields['tel_modem'] =
$fieldlist['comm_media']['modem'];
+ $fields['tel_car'] =
$fieldlist['comm_media']['car phone'];
+ $fields['tel_isdn'] =
$fieldlist['comm_media']['isdn'];
+ $fields['tel_video'] =
$fieldlist['comm_media']['video'];
+ $fields['email'] =
$fieldlist['comm_media']['work email'];
+ $fields['email_home'] =
$fieldlist['comm_media']['home email'];
+ $fields['url'] =
$fieldlist['comm_media']['website'];
+ $this->currentrecord = $fields;
return $buffer;
}
====================================================
Index: addressbook/inc/export/phpgw_LDIF
diff -u addressbook/inc/export/phpgw_LDIF:1.2
addressbook/inc/export/phpgw_LDIF:1.3
--- addressbook/inc/export/phpgw_LDIF:1.2 Tue Dec 4 01:26:53 2001
+++ addressbook/inc/export/phpgw_LDIF Fri Dec 31 04:55:24 2004
@@ -24,61 +24,30 @@
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...
+ 'contact_id' => 'employeeNumber',
+ 'uid' => 'uid',
+ 'full_name_cn' => 'cn',
+ 'full_name_sn' => 'sn',
+ 'first_name' => 'displayName',
+ 'last_name' => 'givenName',
+ 'initials' => 'initials',
+ 'org_name' => 'o',
+ 'title' => 'title',
+ 'department' => 'ou',
+ 'street' => 'street',
+ 'address' => 'postalAddress',
+ 'city' => 'l',
+ 'state' => 'st',
+ 'postal_code' => 'postalCode',
+ 'email' => 'mail',
+ 'home_phone' => 'homePhone',
+ 'work_phone' => 'telephoneNumber',
+ 'pager' => 'pager',
+ 'isdn' => 'internationaliSDNNumber',
+ 'fax' => 'facsimileTelephoneNumber',
+ 'mobile_phone' => 'mobile',
+ 'car_ phone' => 'telephoneNumber',
+ 'website' => 'labeledURI'
);
// This will store the contacts object
@@ -87,22 +56,30 @@
// Read full list of user's contacts only to get id's for each
function export_start_file($buffer,$ncat_id='')
{
+ $this->contacts = CreateObject('phpgwapi.contacts');
+
$this->id=-1;
+ $fields = array('person_id');
+
if ($ncat_id)
{
- $filter = 'tid=n,cat_id='.$ncat_id;
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL, $ncat_id);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
else
{
- $filter = 'tid=n';
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
- $this->contacts = CreateObject('phpgwapi.contacts');
- $tmp =
$this->contacts->read('','',array('id'=>'id'),'',$filter);
- for ($i=0;$i<count($tmp);$i++)
+ if(is_array($tmp_person))
{
- $this->ids[$i] = $tmp[$i]['id'];
+ foreach($tmp_person as $data)
+ {
+ $this->ids[] = $data['person_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;
@@ -112,8 +89,51 @@
function export_start_record($buffer)
{
$this->id++;
- $top =
$this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
- $this->currentrecord = $top[0];
+
+ $top =
$this->contacts->person_complete_data($this->ids[$this->id]);
+
+ if(is_array($top['locations']))
+ {
+ foreach($top['locations'] as $key => $values)
+ {
+ if($values['preferred']=='Y')
+ {
+ $loc_id = $key;
+ }
+ }
+ }
+
+
+ $record['contact_id'] = $top['contact_id'];
+ $record['uid'] =
$top['contact_id'].':'.$top['full_name'];
+ $record['full_name_cn'] = $top['full_name'];
+ $record['full_name_sn'] = $top['full_name'];
+ $record['first_name'] = $top['first_name'];
+ $record['last_name'] = $top['last_name'];
+ $record['initials'] = $top['initials'];
+ $record['org_name'] = $top['org_name'];
+ $record['title'] = $top['title'];
+ $record['department'] = $top['department'];
+ $record['street'] =
$top['locations'][$loc_id]['add1'] .
+
($top['locations'][$loc_id]['add2']?' '.$top['locations'][$loc_id]['add2']:'') .
+
($top['locations'][$loc_id]['add3']?' '.$top['locations'][$loc_id]['add3']:'');
+ $record['address'] =
$top['locations'][$loc_id]['add1'] .
+
($top['locations'][$loc_id]['add2']?' '.$top['locations'][$loc_id]['add2']:'') .
+
($top['locations'][$loc_id]['add3']?' '.$top['locations'][$loc_id]['add3']:'');
+ $record['city'] =
$top['locations'][$loc_id]['city'];
+ $record['state'] =
$top['locations'][$loc_id]['state'];
+ $record['postal_code'] =
$top['locations'][$loc_id]['postal_code'];
+ $record['email'] = $top['comm_media']['work
email']?$top['comm_media']['work email']:$top['comm_media']['home email'];
+ $record['home_phone'] = $top['comm_media']['home
phone'];
+ $record['work_phone'] = $top['comm_media']['work
phone'];
+ $record['pager'] = $top['comm_media']['pager'];
+ $record['isdn'] = $top['comm_media']['isdn'];
+ $record['fax'] = $top['comm_media']['work
fax']?$top['comm_media']['work fax']:$top['comm_media']['home fax'];
+ $record['mobile_phone'] = $top['comm_media']['mobile
(cell) phone'];
+ $record['car_phone'] = $top['comm_media']['car
phone'];
+ $record['website'] = $top['comm_media']['website'];
+
+ $this->currentrecord = $record;
return $buffer;
}
@@ -138,13 +158,8 @@
}
$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']);
+ $buffer[$this->id]['dn'] =
'uid='.$buffer[$this->id]['uid'].','.$context;
+// $buffer[$this->id]['description'] =
ereg_replace("\r\n",';',$buffer[$this->id]['description']);
//echo '<br>'.$this->id.' - '.$buffer[$this->id]['dn'];
return $buffer;
}
@@ -167,7 +182,6 @@
$entries .= 'objectClass: person' . "\n";
$entries .= 'objectClass: organizationalPerson'
. "\n";
$entries .= 'objectClass: inetOrgPerson' . "\n";
- $entries .= 'objectClass: phpgwContact' . "\n";
$entries .= "\n";
}
$buffer = $entries;
====================================================
Index: addressbook/inc/export/phpgw_SQL
diff -u addressbook/inc/export/phpgw_SQL:1.2
addressbook/inc/export/phpgw_SQL:1.3
--- addressbook/inc/export/phpgw_SQL:1.2 Tue Dec 4 01:26:53 2001
+++ addressbook/inc/export/phpgw_SQL Fri Dec 31 04:55:24 2004
@@ -23,62 +23,7 @@
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'
- );
+ var $export= array();
// This will store the contacts object
var $contacts = '';
@@ -86,22 +31,30 @@
// Read full list of user's contacts only to get id's for each
function export_start_file($buffer,$ncat_id='')
{
+ $this->contacts = CreateObject('phpgwapi.contacts');
+
$this->id=-1;
+ $fields = array('person_id');
+
if ($ncat_id)
{
- $filter = 'tid=n,cat_id=' . $ncat_id;
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL, $ncat_id);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
else
{
- $filter = 'tid=n';
+ $criteria =
$this->contacts->criteria_for_index($GLOBALS['phpgw_info']['user']['account_id'],
PHPGW_CONTACTS_ALL);
+ $tmp_person =
$this->contacts->get_persons($fields, '', '', '', '', '', $criteria);
}
- $this->contacts = CreateObject('phpgwapi.contacts');
- $tmp =
$this->contacts->read('','',array('id'=>'id'),'',$filter);
- for ($i=0;$i<count($tmp);$i++)
+ if(is_array($tmp_person))
{
- $this->ids[$i] = $tmp[$i]['id'];
+ foreach($tmp_person as $data)
+ {
+ $this->ids[] = $data['person_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;
@@ -111,8 +64,166 @@
function export_start_record($buffer)
{
$this->id++;
- $top =
$this->contacts->read_single_entry($this->ids[$this->id],$this->qfields);
- $this->currentrecord = $top[0];
+ $fields =
$this->contacts->person_complete_data($this->ids[$this->id]);
+
+ $contact['contact_id'] = $fields['contact_id'];
+ $contact['access'] = $fields['access'];
+ $contact['owner'] = $fields['owner'];
+ $contact['per_first_name'] = $fields['first_name'];
+ $contact['per_last_name'] = $fields['last_name'];
+ $contact['per_middle_name'] =
$fields['middle_name'];
+ $contact['per_suffix'] = $fields['suffix'];
+ $contact['per_prefix'] = $fields['prefix'];
+ $contact['per_birthday'] = $fields['birthday'];
+ $contact['per_pubkey'] = $fields['pubkey'];
+ $contact['per_title'] = $fields['title'];
+ $contact['per_department'] = $fields['department'];
+ $contact['per_initials'] = $fields['initials'];
+ $contact['per_sound'] = $fields['sound'];
+ $contact['per_active'] = $fields['active'];
+ $contact['preferred_org'] =
$fields['preferred_org'];
+ $contact['preferred_address'] =
$fields['preferred_address'];
+ $contact['relations'] =
$fields['organizations'];
+ $contact['categories'] = $fields['categories'];
+ $contact['access'] = $fields['access'];
+
+ unset( $fields['contact_id'],
+ $fields['first_name'],
+ $fields['last_name'],
+ $fields['middle_name'],
+ $fields['suffix'],
+ $fields['prefix'],
+ $fields['birthday'],
+ $fields['pubkey'],
+ $fields['title'],
+ $fields['department'],
+ $fields['initials'],
+ $fields['sound'],
+ $fields['active'],
+ $fields['preferred_org'],
+ $fields['preferred_address'],
+ $fields['organizations'],
+ $fields['categories'],
+ $fields['access'],
+ $fields['full_name'],
+ $fields['owner'],
+ $fields['createon'],
+ $fields['createby'],
+ $fields['modon'],
+ $fields['modby'],
+ $fields['account_id'],
+ $fields['org_name']);
+
+ // Locations info
+ if(is_array($fields['locations']))
+ {
+ foreach($fields['locations'] as $location_input)
+ {
+ // Go for a _good_ address type
+ $addr_type =
$this->contacts->search_location_type($location_input['type']);
+ if(!empty($addr_type))
+ {
+ $location['addr_type']
= $addr_type;
+ }
+ else
+ {
+ $addr_type =
$this->contacts->search_location_type('work');
+ if(!empty($addr_type))
+ {
+
$location['addr_type'] = $addr_type;
+ }
+ else
+ {
+ //return
PHPGW_CONTACTS_ERROR_LOCATION_TYPE_MISSING;
+ return -1;
+ }
+ }
+ $location['addr_add1']
= $location_input['add1'];
+ $location['addr_add2']
= $location_input['add2'];
+ $location['addr_add3']
= $location_input['add3'];
+ $location['addr_city']
= $location_input['city'];
+ $location['addr_state']
= $location_input['state'];
+ $location['addr_postal_code']
= $location_input['postal_code'];
+ $location['addr_country']
= $location_input['country'];
+ $location['addr_preferred']
= $location_input['preferred'];
+ $locations[]
= $location;
+ }
+ }
+ unset($fields['locations']);
+
+ // Notes
+ if(is_array($fields['notes']))
+ {
+ foreach($fields['notes'] as $note_input)
+ {
+ $note_type =
$this->contacts->search_note_type($note_input['type']);
+ if(!empty($note_type))
+ {
+ $note['note_type'] =
$note_type;
+ }
+ else
+ {
+ // FIXME: what is the
default value for note_type?
+ $note_type =
$this->contacts->search_note_type('general');
+ if(!empty($note_type))
+ {
+
$note['note_type'] = $note_type;
+ }
+ else
+ {
+ //return
PHPGW_CONTACTS_ERROR_NOTE_TYPE_MISSING;
+ return -1;
+ }
+ }
+ }
+ $note['note_text'] = $note_input['note'];
+ $notes[] = $note;
+ }
+ unset($fields['notes']);
+
+ // Communcation media fields
+ if(is_array($fields['comm_media']))
+ {
+ foreach($fields['comm_media'] as
$description_input => $comm_input)
+ {
+ $description_id =
$this->contacts->search_comm_descr($description_input);
+ if(!empty($description_id))
+ {
+ $comm['comm_descr']
= $description_id;
+ $comm['comm_data']
= $comm_input;
+ $comm_media[]
= $comm;
+ }
+ else
+ {
+ // Promote to others
+
$fields[$description_input] = $comm_input;
+ }
+ }
+ }
+ unset($fields['comm_media']);
+
+ // Other fields
+ $others=array();
+ if(count($fields) > 0)
+ {
+ foreach($fields as $field_name => $field_value)
+ {
+ $other['other_name'] =
$field_name;
+ $other['other_value'] =
$field_value;
+ $other['other_owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $others[] =
$other;
+ }
+ }
+
+ $record = array('contact' => $contact,
+ 'comm_media' => $comm_media,
+ 'locations' => $locations,
+ 'categories' => $contact['categories'],
+ 'others' => $others,
+ 'relations' => $contact['relations'],
+ 'notes' => $notes);
+
+ $this->currentrecord = $record;
return $buffer;
}
@@ -120,11 +231,7 @@
// 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]];
- }
+ $buffer[$this->id][$name] = $value;
return $buffer;
}
@@ -137,20 +244,60 @@
// 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))
+ $type = 1;
+ for ($i=0;$i<count($this->ids);$i++)
+ {
+ $contact_sql='';
+ $person_sql='';
+ $comm_sql='';
+ $loc_sql='';
+ $other_sql='';
+ $notes_sql='';
+
+ $cid = $buffer[$i]['contact']['contact_id'];
+
+ $contact_table =
CreateObject('phpgwapi.contact_central');
+ $contact_sql =
$contact_table->insert(array('contact_id' =>
$buffer[$i]['contact']['contact_id'],
+
'owner' => $buffer[$i]['contact']['owner'],
+
'access' => $buffer[$i]['contact']['access'],
+
'cat_id' => $this->contacts->get_categories($buffer[$i]['categories']),
+
'contact_type' => $type), PHPGW_SQL_RETURN_SQL) . "; \n";
+
+ $person_sql =
$this->contacts->add_person($buffer[$i]['contact'], $cid, PHPGW_SQL_RETURN_SQL)
. "; \n";
+
+ if(is_array($buffer[$i]['comm_media']))
+ {
+ foreach($buffer[$i]['comm_media'] as
$comm)
+ {
+ $comm_sql .=
$this->contacts->add_communication_media($comm, $cid, PHPGW_SQL_RETURN_SQL) .
"; \n";
+ }
+ }
+
+ if(is_array($buffer[$i]['locations']))
+ {
+ foreach($buffer[$i]['locations'] as
$location)
+ {
+ $loc_sql .=
$this->contacts->add_location($location, $cid, PHPGW_SQL_RETURN_SQL) . "; \n";
+ }
+ }
+
+ if(is_array($buffer[$i]['others']))
+ {
+ foreach($buffer[$i]['others'] as $other)
+ {
+ $other_sql .=
$this->contacts->add_others($other, $cid, PHPGW_SQL_RETURN_SQL) . "; \n";
+ }
+ }
+
+ if(is_array($buffer[$i]['notes']))
{
- $fields .= $value . ",";
- $values .= "'" . $buffer[$i][$value] .
"',";
+ foreach($buffer[$i]['notes'] as $note)
+ {
+ $notes_sql .=
$this->contacts->add_notes($notes, $cid, PHPGW_SQL_RETURN_SQL) . "; \n";
+ }
}
- $fields = substr($fields,0,-1) . ")\n VALUES(";
- $values = substr($values,0,-1) . ");\n";
- $entries .= $top . $fields . $values;
+
+ $entries .=
$contact_sql.$person_sql.$comm_sql.$loc_sql.$other_sql.$notes_sql;
}
$buffer = $entries;
return $buffer;
====================================================
Index: OpenOffice_-_writer
<?php
/***
This is going to be different than the other export functions.
It will ignore the output file name.
It will output the fields selected for display in the addressbook app
prior to hitting the export button
(instead of a static list)
It will use the filters selected in the addressbook app prior to
hitting the export button
(instead of a static set)
It will use the cat filter selected in the addressbook app prior to
hitting the export button unless
cats are selected in the export screen -- Currently not a multiple cat
selector so will ignore for now
It will also ignore the download checkbox and download it anyway :)
***/
// FIXME: the unzip/zip system should be replaced with a php class
(maybe pclzip. There was also a php file manager that included zip handling
somewhere)
// FIXME: the current way we extract to a tmp dir will cause a problem
with multiple users trying to
// export at the same time. Maybe we need to add a time stamp to the
tmp file name. Maybe we should
// also delete all tmp files that have existed for more than a few hours
class export_conv
{
function do_it($both_types='',$sub_cats='')
{
$this->bo = CreateObject('addressbook.boaddressbook');
//$this->contacts =
CreateObject('addressbook.boaddressbook');
$export_vars =
$GLOBALS['phpgw']->session->appsession('export_vars','addressbook');
//echo "<pre>Export_vars: "; print_r($export_vars);
echo "</pre> \n";
$filename1 = 'sample.sxw';
$filename2 = 'content.xml';
$tempdir1 = 'sample';
$tempdir2 = $tempdir1 . date("Y-m-d-G:i:s");
$startpointer = 0;
$endpointer = 0;
$newcontents = '';
$cols = 0;
$rows = 0;
//echo "<pre>here2 $both_types $sub_cats</pre>";
//unzip it to the temp dir
//rm -rf ' .
$GLOBALS['phpgw_info']['server']['temp_dir'] . '/' . $tempdir . '*';
system('find ' .
$GLOBALS['phpgw_info']['server']['temp_dir'] . '/ -mtime +1 -name "' .
$tempdir1 . '*" -exec rm -rf {} \;', $null);
//echo 'find ' .
$GLOBALS['phpgw_info']['server']['temp_dir'] . '/ -mtime +1 -name "' .
$tempdir1 . '*" -exec rm -rf {} \;';
//echo '/usr/bin/unzip -o addressbook/inc/export/'.
$filename1 .' -d ' . $GLOBALS['phpgw_info']['server']['temp_dir'] . '/' .
$tempdir2 . ' &> /dev/null';
system('/usr/bin/unzip -o addressbook/inc/export/'.
$filename1 .' -d ' . $GLOBALS['phpgw_info']['server']['temp_dir'] . '/' .
$tempdir2 . ' &> /dev/null', $null);
// get the data
//echo "<pre></pre> \n";
$get_data_function = $export_vars['get_data_function'];
$fields = $export_vars['fields'];
$this->limit = $export_vars['limit'];
$this->start = $export_vars['start'];
$this->order = $export_vars['order'];
$this->sort = $export_vars['sort'];
$criteria = $export_vars['criteria'];
$fields_comms = $export_vars['fields_comms'];
$category_filter = $export_vars['category_filter'];
$contacts = CreateObject('phpgwapi.contacts');
if( $sub_cats )
{
// somehow we have to add the category as a
field, get the sub-cat category names,
// add them into $enties
//echo "<pre>Criteria:
";print_r($criteria);echo"</pre> \n";
$categories =
CreateObject('phpgwapi.categories');
//echo "<pre>category_filter:
";print_r($category_filter);echo"</pre> \n";
//echo "<pre>Sub_cats:
";print_r($contacts->get_sub_cats($category_filter));echo"</pre> \n";
$subcats =
$contacts->get_sub_cats($category_filter);
$fields[] = 'cat_id';
//echo "<pre>Sub_cats:
";print_r($contacts->get_categories($contacts->get_sub_cats($category_filter)));echo"</pre>
\n";
//echo "<pre>Sub_cats:
";print_r($categories->return_single($contacts->get_sub_cats($category_filter)));echo"</pre>
\n";
}
if( $both_types )
{
// somehow we have to get the field prefs for
the other section, add them
if( $get_data_function != 'get_persons' )
{
$columns_to_display =
$this->bo->get_columns_to_display($this->bo->tab_main_persons);
$get_data_function2 = 'get_persons';
}
else
{
$columns_to_display =
$this->bo->get_columns_to_display($this->bo->tab_main_organizations);
//echo "<pre>columns_to_display: ";
print_r($columns_to_display); echo "</pre>";
$get_data_function2 = 'get_orgs';
}
$comms_array =
$columns_to_display['comm_types']?$columns_to_display['comm_types']:array();
//echo "<pre>comms_array: ";
print_r($comms_array); echo "</pre>";
unset($columns_to_display['comm_types']);
//$columns_to_display?$columns_to_display:array();
if(is_array($columns_to_display))
{
$fields2 =
array_keys($columns_to_display);
$fields_comms2 =
array_keys($comms_array);
}
//$entries2 =
$this->bo->$get_data_function($fields2, '', $this->start, $this->order,
$this->sort, '', $criteria);
// now we have to merge the arrays
}
//$fields['preferred_org'] = 'preferred_org';
//$fields['org_id'] = 'org_id';
//$fields['person_id'] = 'person_id';
//$fields['my_preferred'] = 'my_preferred';
//echo "<pre>fields "; print_r($fields); echo "</pre>";
//echo "<pre>fields_comms "; print_r($fields_comms);
echo "</pre>";
//echo "<pre>fields2 "; print_r($fields2); echo
"</pre>";
//echo "<pre>fields_comms2 "; print_r($fields_comms2);
echo "</pre>";
//echo "<pre>Getting contacts data (This could take a
while)</pre> \n";
//$entries = $this->bo->$get_data_function($fields, 13,
$this->start, $this->order, $this->sort, '', $criteria);
//$entries = $this->bo->$get_data_function($fields,
$this->limit, $this->start, $this->order, $this->sort, '', $criteria);
$entries = $this->bo->$get_data_function($fields, '',
$this->start, $this->order, $this->sort, '', $criteria);
//echo "<pre>" . count($entries) . " entries: ";
print_r($entries); echo "</pre> \n";
//echo "<pre>" . count($entries) . " entries: ";
print_r(array_keys($entries)); echo "</pre> \n";
//echo "<pre>criteria: "; print_r($criteria); echo
"</pre> \n";
unset($fields['owner']);
unset($fields['contact_id']);
if (!is_array($entries))
{
$entries=array();
}
if( count($fields_comms)>0 )
{
//$test =
$this->bo->get_comm_contact_data(array_keys($entries), $fields_comms);
$test =
$this->bo->get_comm_contact_data(array_keys($entries), $fields_comms);
//echo "<pre>get_comm_contact_data: ";
print_r($test); echo "</pre> \n";;
}
// need to get org info
//getting entire list doesn't work since criteria
should be met by first entries selection
//echo $get_data_function2;
//$entries2 = $this->bo->$get_data_function2($fields2,
$this->limit, $this->start, $this->order, $this->sort, '', $criteria);
//echo "<pre>organizations_info: "; print_r($entries2
); echo "</pre> \n";
//if( count($fields_comms2)>0 )
//{
//array_merge($test,$this->bo->get_comm_contact_data(array_keys($entries),
$fields_comms2));
//echo "<pre>get_comm_contact_data: ";
print_r($test); echo "</pre> \n";;
//}
if(count($fields_comms)>0 || count($fields2)>0 ||
count($fields_comms2)>0)
{
//echo "<pre>Getting contacts comm data (This
could take a while as well)</pre> \n";
//$entries_comms =
$this->bo->get_comm_contact_data($contacts, $fields_comms);
foreach($entries as $entry)
//for ($i=0; $i<count($entries); $i++)
{
//echo "<pre>entry: "; print_r($entry);
echo "</pre> \n";;
// merge in the fields_comms data
$entries[$entry['contact_id']] =
array_merge($entries[$entry['contact_id']],$test[$entry['contact_id']]);
//$contact[0] =
$entries[$i]['contact_id'];
//echo $entry['contact_id'] . ' ';
//$entries[$entry['contact_id']][] =
$test[$entry['contact_id']];
//for ($j=0; $j<count($fields_comms);
$j++)
//{
//$fields_comm[0] =
$fields_comms[$j];
//echo $j . '
'.$fields_comms[$j];
//$test =
$this->bo->get_comm_contact_data(array_keys($entries), $fields_comm);
//$entries[$i][$fields_comms[$j]] = $test[0]['comm_data'];
//echo
"<pre>get_comm_contact_data: "; print_r($test); echo "</pre> \n";;
//}
//$contact[0] =
$entries[$i]['contact_id'];
// get the link to the person's
organization
//echo 'here1' . ' ';
$crap =
$contacts->get_organizations_by_person($entry['contact_id']);
//echo
"<pre>get_organizations_by_person: "; print_r($crap[0]['my_org_id']); echo
"</pre> \n";;
$entries[$entry['contact_id']]['my_org_id'] = $crap[0]['my_org_id'];
//echo 'here2' . ' ';
//echo "<pre>get_organizations_info: ";
print_r($this->bo->$get_data_function2($fields2, $this->limit, $this->start,
$this->order, $this->sort, '', $criteria)); echo "</pre> \n";
if($crap[0]['my_org_id'] &&
is_array($fields2))
{
//echo
"<pre>get_organizations_info: "; print_r($fields2); echo "</pre> \n";
$crap2 =
array_values($this->bo->$get_data_function2($fields2, '', '', '', '',
array('contact_id'=>$crap[0]['my_org_id'])));
//echo
"<pre>get_organizations_info: ";
print_r($this->bo->get_principal_organizations_data($crap[0]['my_org_id']));
echo "</pre> \n";
//echo
"<pre>get_organizations_info: "; print_r($crap2); echo "</pre> \n";
//echo
"<pre>get_organizations_info: "; var_dump($crap2); echo "</pre> \n";
//echo
"<pre>get_organizations_info: "; print_r(array_values($crap2)); echo "</pre>
\n";
//if ($crap[0]['my_org_id'] =
15)
//{
//echo
"<pre>get_organizations_info: "; print_r($crap2); echo "</pre> \n";
//}
if( is_array($crap2) )
{
$entries[$entry['contact_id']] =
array_merge($entries[$entry['contact_id']],$crap2[0]);
}
}
// merge in the fields_comms2 data
$crap =
$this->bo->get_comm_contact_data($entries[$entry['contact_id']]['my_org_id'],
$fields_comm2);
//$entries[$entry['contact_id']][] =
$crap[$entries[$entry['contact_id']]['my_org_id']];
$entries[$entry['contact_id']] =
array_merge($entries[$entry['contact_id']],$crap[$entries[$entry['contact_id']]['my_org_id']]);
//for ($j=0; $j<count($fields2); $j++)
//{
//$fields2[0] = $fields2[$j];
//$test =
$this->bo->get_comm_contact_data($entries[$i]['contact_id'], $fields_comm);
//$entries[$i][$fields_comms[$j]] = $test[0]['comm_data'];
//echo
"<pre>get_comm_contact_data: "; print_r($test); echo "</pre> \n";;
//}
//for ($j=0; $j<count($fields_comms2);
$j++)
//{
//$fields_comm2[0] =
$fields_comms2[$j];
//$test =
$this->bo->get_comm_contact_data($entries[$i]['contact_id'], $fields_comm2);
//echo
"<pre>get_comm_contact_data: "; print_r($test); echo "</pre> \n";;
//$entries[$i][$fields_comms2[$j]] = $test[0]['comm_data'];
//echo
"<pre>get_comm_contact_data: "; print_r($test); echo "</pre> \n";;
//}
if($entry['cat_id'])
{
//echo "<pre>cat_info: ";
print_r($entry['cat_id']); echo "</pre> \n";
//$cats =
$GLOBALS['phpgw']->categories->return_sorted_array(0,False,'','','',!$type);
$cats =
explode(',',$entry['cat_id']);
//echo "<pre>cat_info: ";
print_r($cats); echo "</pre> \n";
//$c = 0;
$catname = '';
// get category names
if( ! is_array($subcats) )
{
$subcats = array();
}
while (list($key,$contactscat)
= each($cats))
{
if ($contactscat &&
in_array(intval($contactscat),$subcats))
{
//$catinfo =
$this->cat->return_single(intval($contactscat));
//$catinfo =
$categories->return_single(intval($contactscat));
//$catname .=
$catinfo[0]['name'] . '; ';
//$GLOBALS['phpgw']->categories->id2name($key);
$catname .=
$categories->id2name(intval($contactscat)) . '; ';
}
//$c++;
}
//echo "<pre>cat_info: ";
print_r($catname); echo "</pre> \n";
//$entries[$entry['contact_id']]['cat_id'] = explode(',',$cats);
$entries[$entry['contact_id']]['cat_id'] = $catname;
//$fields['cat_id'] =
count($fcat_id) > 1 ? ','.implode(',',$fcat_id).',' : $fcat_id[0];
}
}
}
$fields = array_merge($fields, $fields_comms);
$fields2 = array_merge($fields2, $fields_comms2);
//echo "<pre>fields: "; print_r($fields); echo "</pre>
\n";
//echo "<pre>fields2: "; print_r($fields2); echo
"</pre> \n";
//echo "<pre>entries_comms: "; print_r($entries_comms);
echo "</pre> \n";
//echo "<pre>entries: "; print_r($entries); echo
"</pre> \n";
$cols = count($fields) + count($fields2);
$rows = count($entries);
//echo "cols: " . $cols . " \n";
//open the xml file and edit it
// get contents of a file into a string
//echo "<pre>Reading OpenOffice file</pre> \n";
$file = $GLOBALS['phpgw_info']['server']['temp_dir'] .
'/' . $tempdir2 . '/' . $filename2;
$f = fopen ($file, "r+b");
$contents = fread ($f, filesize ($file));
rewind($f);
//substr ( string string, int start [, int length])
//strpos ( string haystack, string needle [, int
offset])
/*
<table:table table:name="Table1"
table:style-name="Table1">
<table:table-column table:style-name="Table1.A"/>
*/
//echo $contents;
//print_r($contents);
//echo "<pre>Merging data into OpenOffice file</pre>
\n";
$endpointer = strpos( $contents, '<table:table-column'
);
$newcontents = substr( $contents, $startpointer,
$endpointer - $startpointer);
//echo $endpointer . ' ' . $startpointer . ' ';
//echo "<pre>newcontents: "; print_r($newcontents);
echo "</pre> \n";
$startpointer = $endpointer;
$endpointer = strpos( $contents, '/>', $startpointer );
//echo $endpointer . ' ' . $startpointer . ' ';
$newcontents .= substr( $contents, $startpointer,
$endpointer - $startpointer);
//echo "<pre>newcontents: "; print_r($newcontents);
echo "</pre> \n";
$startpointer = $endpointer;
$newcontents .= ' table:number-columns-repeated="' .
$cols . '"';
//echo "<pre>newcontents: "; print_r($newcontents);
echo "</pre> \n";
$endpointer = strpos( $contents, '>header',
$startpointer ) + 1 ;
$newcontents .= substr( $contents, $startpointer,
$endpointer - $startpointer);
$startpointer = $endpointer;
// skip template text
$endpointer = strpos( $contents, '<', $startpointer );
$startpointer = $endpointer;
// add new text
if( $fields[0] )
{
$newcontents .=
utf8_encode(htmlentities($fields[0]));
}
elseif( $fields2[0] )
{
$newcontents .=
utf8_encode(htmlentities($fields2[0]));
}
else
{
$newcontents .= 'no header';
}
//$newcontents .= '>';
// add more columns
for($i=1; $i<$cols; $i++)
{
$newcontents .= '</text:p>' . "\n";
$newcontents .= '</table:table-cell>' . "\n";
$newcontents .= '<table:table-cell
table:value-type="string">' . "\n";
$newcontents .= '<text:p text:style-name="Table
Heading">' . "\n";
//$newcontents .= 'Field name ' . $i;
if( $i < count($fields) )
{
$newcontents .=
utf8_encode(htmlentities($fields[$i]));
}
elseif( $i < (count($fields) + count($fields2))
)
{
$newcontents .=
utf8_encode(htmlentities($fields2[$i-count($fields)]));
//$newcontents .=
$this->get_comm_value($myid, $column[key])
}
else
{
$newcontents .= 'no header'; //
shouldn't ever be called
}
}
$endpointer = strpos( $contents, '>data', $startpointer
) + 1 ;
$newcontents .= substr( $contents, $startpointer,
$endpointer - $startpointer );
$startpointer = $endpointer;
// skip template text
$endpointer = strpos( $contents, '<', $startpointer );
$startpointer = $endpointer;
// add new text
$process = array_shift($entries);
//print_r($process);
//$newcontents .= 'Data: Row ' . '0' . ' Column ' . '0';
if( $fields[0] && $rows > 0 )
{
$newcontents .=
utf8_encode(htmlentities($process[$fields[0]]));
}
elseif( $fields2[0] && $rows > 0 )
{
$newcontents .=
utf8_encode(htmlentities($process[$fields2[0]]));
}
else
{
$newcontents .= 'no data';
}
//$newcontents .= 'Data: Row 0 Column 0';
//$newcontents .= '>';
// add more columns
for($i=1; $i<$cols; $i++)
{
$newcontents .= '</text:p>' . "\n";
$newcontents .= '</table:table-cell>' . "\n";
$newcontents .= '<table:table-cell
table:value-type="string">' . "\n";
$newcontents .= '<text:p text:style-name="Table
Contents">' . "\n";
//$newcontents .= 'Data: Row ' . '0' . ' Column
' . $i;
if( $i < count($fields) )
{
$newcontents .=
utf8_encode(htmlentities($process[$fields[$i]]));
//$newcontents .=
$entries[0][$fields[$i]];
}
elseif( $i < (count($fields)+count($fields2)) )
{
$newcontents .=
utf8_encode(htmlentities($process[$fields2[$i-count($fields)]]));
//$newcontents .=
$entries[0][$fields2[$i-count($fields)]];
//echo $i-count($fields) .
$fields_comms[$i-count($fields)];
}
else
{
$newcontents .= 'no data';
}
}
// add extra rows of columns
//$newcontents .= '</text:p>';
//$newcontents .= '</table:table-cell>';
//$newcontents .= '</table:table-row>';
for($r=1; $r<$rows; $r++)
{
$newcontents .= '</text:p>' . "\n";
$newcontents .= '</table:table-cell>' . "\n";
$newcontents .= '</table:table-row>' . "\n";
$newcontents .= '<table:table-row>' . "\n";
$process = array_shift($entries);
for($i=0; $i<$cols; $i++)
{
$newcontents .= '<table:table-cell
table:value-type="string">' . "\n";
$newcontents .= '<text:p
text:style-name="Table Contents">' . "\n";
//$newcontents .= 'Data: Row ' . $r . '
Column ' . $i;
if( $i < count($fields) )
{
$newcontents .=
utf8_encode(htmlentities($process[$fields[$i]]));
//$newcontents .=
$entries[$r][$fields[$i]];
}
elseif( $i <
(count($fields)+count($fields2)) )
{
//$newcontents .=
$entries[$r][$fields2[$i-count($fields)]];
$newcontents .=
utf8_encode(htmlentities($process[$fields2[$i-count($fields)]]));
}
else
{
$newcontents .= 'no data'; //
shouldn't get used
}
if( $i != ($cols-1) ) // don't add this
last time through
{
$newcontents .= '</text:p>' .
"\n";
$newcontents .=
'</table:table-cell>' . "\n";
}
}
}
// skip the last </text:p></table:table-cell>
//$endpointer = strpos( $contents,
'</table:table-row>', $startpointer );
//$startpointer = $endpointer;
// add the rest of the file
$newcontents .= substr( $contents, $startpointer );
// empty file and write in new contents
//echo "<pre>Writing data into OpenOffice file</pre>
\n";
rewind($f);
fwrite($f,$newcontents);
fflush($f);
ftruncate($f, ftell($f));
/*
from http://ca3.php.net/manual/en/function.fopen.php
To overwrite a file with a new content without deleting
it, and without changing the owner or access rights, it's best to not use:
$file = fopen($filename, 'r+b); // binary update mode
...
ftruncate($file, 0);
fwrite($file, $my_stuff);
...
fclose($file);
but instead the faster one:
$file = fopen($filename, 'r+b); // binary update mode
...
rewind($file);
fwrite($file, $my_stuff);
fflush($file);
ftruncate($file, ftell($file));
...
fclose($file);
The reason is that truncating a file at size 0 forces
the OS to deallocate all storage clusters used by the file, before you write
your content which will be reallocated on disk.
The second code simply overwrites the existing content
where it is already located on disk, and truncates any remaining bytes that may
exist (if the new content is shorter than the old content). The "r+b" mode
allows access for both read and write: the file can be kept opened after
reading it and before rewriting the modified content.
It's particularly useful for files that are accessed
often or have a size larger than a few kilobytes, as it saves lots of system
I/O, and also limits the filesystem fragmentation if the updated file is quite
large.
And this method also works if the file is locked
exclusively once opened (but I would rather recommend using another empty file
for locking purpose, opened with "a+" access mode, in "/var/lock/yourapp/*" or
other fast filesystems where filelocks are easily monitored and where the
webserver running PHP is allowed to create and update lock files, and not
forgetting to close the lock file after closing the content file).
*/
fclose ($f);
// clean up my ab tables
//select * from phpgw_contact LEFT JOIN
phpgw_ttrack_jobs ON phpgw_contact.contact_id=phpgw_ttrack_jobs.company_id
WHERE phpgw_ttrack_jobs.company_id IS NULL;
//zip it up again
//echo "<pre></pre>";
//echo $GLOBALS['phpgw_info']['server']['temp_dir'] .
'/' . $tempdir2;
chdir($GLOBALS['phpgw_info']['server']['temp_dir'] .
'/' . $tempdir2);
//echo '/usr/bin/zip -r ' .
$GLOBALS['phpgw_info']['server']['temp_dir'] . '/' . $filename1 . ' *' . ' &>
/dev/null';
system('/usr/bin/zip -r ' .
$GLOBALS['phpgw_info']['server']['temp_dir'] . '/' . $filename1 . ' *' . ' &>
/dev/null', $null );
//system('/usr/bin/unzip -o addressbook/inc/export/'.
$filename1 .' -d ' . $GLOBALS['phpgw_info']['server']['temp_dir'] . '/' .
$tempdir2 . ' &> /dev/null', $null);
//echo "<pre>Export_vars: "; print_r($export_vars);
echo "</pre> \n";
//return $buffer;
return $GLOBALS['phpgw_info']['server']['temp_dir'] .
'/' . $filename1;
}
}
?>
====================================================
Index: OpenOffice_-_calc
<?php
/***
This is going to be different than the other export functions.
It will ignore the output file name.
It will output the fields selected for display in the addressbook app
prior to hitting the export button
(instead of a static list)
It will use the filters selected in the addressbook app prior to
hitting the export button
(instead of a static set)
It will use the cat filter selected in the addressbook app prior to
hitting the export button unless
cats are selected in the export screen -- Currently not a multiple cat
selector so will ignore for now
It will also ignore the download checkbox and download it anyway :)
***/
// FIXME: the unzip/zip system should be replaced with a php class
(maybe pclzip. There was also a php file manager that included zip handling
somewhere)
// FIXME: the current way we extract to a tmp dir will cause a problem
with multiple users trying to
// export at the same time. Maybe we need to add a time stamp to the
tmp file name. Maybe we should
// also delete all tmp files that have existed for more than a few hours
class export_conv
{
function do_it($both_types='',$sub_cats='')
{
$this->bo = CreateObject('addressbook.boaddressbook');
//$this->contacts =
CreateObject('addressbook.boaddressbook');
$export_vars =
$GLOBALS['phpgw']->session->appsession('export_vars','addressbook');
//echo "<pre>Export_vars: "; print_r($export_vars);
echo "</pre> \n";
$filename1 = 'sample.sxc';
$filename2 = 'content.xml';
$tempdir1 = 'sample';
$tempdir2 = $tempdir1 . date("Y-m-d-G:i:s");
$startpointer = 0;
$endpointer = 0;
$newcontents = '';
$cols = 0;
$rows = 0;
//echo "<pre>here2 $both_types $sub_cats</pre>";
//unzip it to the temp dir
//rm -rf ' .
$GLOBALS['phpgw_info']['server']['temp_dir'] . '/' . $tempdir . '*';
system('find ' .
$GLOBALS['phpgw_info']['server']['temp_dir'] . '/ -mtime +1 -name "' .
$tempdir1 . '*" -exec rm -rf {} \;', $null);
//echo 'find ' .
$GLOBALS['phpgw_info']['server']['temp_dir'] . '/ -mtime +1 -name "' .
$tempdir1 . '*" -exec rm -rf {} \;';
//echo '/usr/bin/unzip -o addressbook/inc/export/'.
$filename1 .' -d ' . $GLOBALS['phpgw_info']['server']['temp_dir'] . '/' .
$tempdir2 . ' &> /dev/null';
system('/usr/bin/unzip -o addressbook/inc/export/'.
$filename1 .' -d ' . $GLOBALS['phpgw_info']['server']['temp_dir'] . '/' .
$tempdir2 . ' &> /dev/null', $null);
// get the data
//echo "<pre></pre> \n";
$get_data_function = $export_vars['get_data_function'];
$fields = $export_vars['fields'];
$this->limit = $export_vars['limit'];
$this->start = $export_vars['start'];
$this->order = $export_vars['order'];
$this->sort = $export_vars['sort'];
$criteria = $export_vars['criteria'];
$fields_comms = $export_vars['fields_comms'];
$category_filter = $export_vars['category_filter'];
// let's do some contact cleanup on my system while
we're here
$contacts = CreateObject('phpgwapi.contacts');
/*
echo 'Deleting these people: ';
$GLOBALS['phpgw']->db2 = $GLOBALS['phpgw']->db;
$GLOBALS['phpgw']->db2->query('SELECT * FROM
phpgw_contact_person LEFT JOIN phpgw_ttrack_jobs AS one ON
one.company_id=phpgw_contact_person.person_id LEFT JOIN phpgw_ttrack_jobs AS
two ON two.contact_id=phpgw_contact_person.person_id WHERE one.job_id IS NULL
AND two.job_id IS NULL');
while ( $GLOBALS['phpgw']->db2->next_record() )
{
$contact_id =
$GLOBALS['phpgw']->db2->f('person_id');
echo $contact_id . ' ';
//echo
$this->bo->search_contact_type_id($this->bo->get_type_contact($contact_id));
$this->bo->delete($contact_id,'Persons');
}
echo "<pre>";echo "</pre> \n";
echo 'Deleting these orgs: ';
$GLOBALS['phpgw']->db2->query('SELECT * FROM
phpgw_contact_org LEFT JOIN phpgw_ttrack_jobs ON
phpgw_ttrack_jobs.company_id=phpgw_contact_org.org_id WHERE job_id IS NULL');
while ($GLOBALS['phpgw']->db2->next_record())
{
$contact_id =
$GLOBALS['phpgw']->db2->f('org_id');
//check that no persons link to this org before
deleting
//echo $contact_id . ' ';
if ( !
$this->bo->get_person_orgs_data($contact_id) )
{
echo $contact_id . ' ';
//echo
$this->bo->search_contact_type_id($this->bo->get_type_contact($contact_id));
$contacts->delete($contact_id,'Organizations');
}
}
echo
"<pre>";print_r($this->bo->get_person_orgs_data($contact_id));echo "</pre> \n";
echo 'here3';
*/
if( $sub_cats )
{
// somehow we have to add the category as a
field, get the sub-cat category names,
// add them into $enties, and sort by them
//echo "<pre>Criteria:
";print_r($criteria);echo"</pre> \n";
$categories =
CreateObject('phpgwapi.categories');
//echo "<pre>category_filter:
";print_r($category_filter);echo"</pre> \n";
//echo "<pre>Sub_cats:
";print_r($contacts->get_sub_cats($category_filter));echo"</pre> \n";
$subcats =
$contacts->get_sub_cats($category_filter);
$fields[] = 'cat_id';
//echo "<pre>Sub_cats:
";print_r($contacts->get_categories($contacts->get_sub_cats($category_filter)));echo"</pre>
\n";
//echo "<pre>Sub_cats:
";print_r($categories->return_single($contacts->get_sub_cats($category_filter)));echo"</pre>
\n";
}
if( $both_types )
{
// somehow we have to get the field prefs for
the other section, add them
if( $get_data_function != 'get_persons' )
{
$columns_to_display =
$this->bo->get_columns_to_display($this->bo->tab_main_persons);
$get_data_function2 = 'get_persons';
}
else
{
$columns_to_display =
$this->bo->get_columns_to_display($this->bo->tab_main_organizations);
//echo "<pre>columns_to_display: ";
print_r($columns_to_display); echo "</pre>";
$get_data_function2 = 'get_orgs';
}
$comms_array =
$columns_to_display['comm_types']?$columns_to_display['comm_types']:array();
//echo "<pre>comms_array: ";
print_r($comms_array); echo "</pre>";
unset($columns_to_display['comm_types']);
//$columns_to_display?$columns_to_display:array();
if(is_array($columns_to_display))
{
$fields2 =
array_keys($columns_to_display);
$fields_comms2 =
array_keys($comms_array);
}
//$entries2 =
$this->bo->$get_data_function($fields2, '', $this->start, $this->order,
$this->sort, '', $criteria);
// now we have to merge the arrays
}
//$fields['preferred_org'] = 'preferred_org';
//$fields['org_id'] = 'org_id';
//$fields['person_id'] = 'person_id';
//$fields['my_preferred'] = 'my_preferred';
//echo "<pre>fields "; print_r($fields); echo "</pre>";
//echo "<pre>fields_comms "; print_r($fields_comms);
echo "</pre>";
//echo "<pre>fields2 "; print_r($fields2); echo
"</pre>";
//echo "<pre>fields_comms2 "; print_r($fields_comms2);
echo "</pre>";
//echo "<pre>Getting contacts data (This could take a
while)</pre> \n";
//$entries = $this->bo->$get_data_function($fields, 13,
$this->start, $this->order, $this->sort, '', $criteria);
//$entries = $this->bo->$get_data_function($fields,
$this->limit, $this->start, $this->order, $this->sort, '', $criteria);
$entries = $this->bo->$get_data_function($fields, '',
$this->start, $this->order, $this->sort, '', $criteria);
//echo "<pre>" . count($entries) . " entries: ";
print_r($entries); echo "</pre> \n";
//echo "<pre>" . count($entries) . " entries: ";
print_r(array_keys($entries)); echo "</pre> \n";
//echo "<pre>criteria: "; print_r($criteria); echo
"</pre> \n";
unset($fields['owner']);
unset($fields['contact_id']);
if (!is_array($entries))
{
$entries=array();
}
if( count($fields_comms)>0 )
{
//$test =
$this->bo->get_comm_contact_data(array_keys($entries), $fields_comms);
$test =
$this->bo->get_comm_contact_data(array_keys($entries), $fields_comms);
//echo "<pre>get_comm_contact_data: ";
print_r($test); echo "</pre> \n";;
}
// need to get org info
//getting entire list doesn't work since criteria
should be met by first entries selection
//echo $get_data_function2;
//$entries2 = $this->bo->$get_data_function2($fields2,
$this->limit, $this->start, $this->order, $this->sort, '', $criteria);
//echo "<pre>organizations_info: "; print_r($entries2
); echo "</pre> \n";
//if( count($fields_comms2)>0 )
//{
//array_merge($test,$this->bo->get_comm_contact_data(array_keys($entries),
$fields_comms2));
//echo "<pre>get_comm_contact_data: ";
print_r($test); echo "</pre> \n";;
//}
if(count($fields_comms)>0 || count($fields2)>0 ||
count($fields_comms2)>0)
{
//echo "<pre>Getting contacts comm data (This
could take a while as well)</pre> \n";
//$entries_comms =
$this->bo->get_comm_contact_data($contacts, $fields_comms);
foreach($entries as $entry)
//for ($i=0; $i<count($entries); $i++)
{
//echo "<pre>entry: "; print_r($entry);
echo "</pre> \n";;
// merge in the fields_comms data
$entries[$entry['contact_id']] =
array_merge($entries[$entry['contact_id']],$test[$entry['contact_id']]);
//$contact[0] =
$entries[$i]['contact_id'];
//echo $entry['contact_id'] . ' ';
//$entries[$entry['contact_id']][] =
$test[$entry['contact_id']];
//for ($j=0; $j<count($fields_comms);
$j++)
//{
//$fields_comm[0] =
$fields_comms[$j];
//echo $j . '
'.$fields_comms[$j];
//$test =
$this->bo->get_comm_contact_data(array_keys($entries), $fields_comm);
//$entries[$i][$fields_comms[$j]] = $test[0]['comm_data'];
//echo
"<pre>get_comm_contact_data: "; print_r($test); echo "</pre> \n";;
//}
//$contact[0] =
$entries[$i]['contact_id'];
// get the link to the person's
organization
//echo 'here1' . ' ';
$crap =
$contacts->get_organizations_by_person($entry['contact_id']);
//echo
"<pre>get_organizations_by_person: "; print_r($crap[0]['my_org_id']); echo
"</pre> \n";;
$entries[$entry['contact_id']]['my_org_id'] = $crap[0]['my_org_id'];
//echo 'here2' . ' ';
//echo "<pre>get_organizations_info: ";
print_r($this->bo->$get_data_function2($fields2, $this->limit, $this->start,
$this->order, $this->sort, '', $criteria)); echo "</pre> \n";
if($crap[0]['my_org_id'] &&
is_array($fields2))
{
//echo
"<pre>get_organizations_info: "; print_r($fields2); echo "</pre> \n";
$crap2 =
array_values($this->bo->$get_data_function2($fields2, '', '', '', '',
array('contact_id'=>$crap[0]['my_org_id'])));
//echo
"<pre>get_organizations_info: ";
print_r($this->bo->get_principal_organizations_data($crap[0]['my_org_id']));
echo "</pre> \n";
//echo
"<pre>get_organizations_info: "; print_r($crap2); echo "</pre> \n";
//echo
"<pre>get_organizations_info: "; var_dump($crap2); echo "</pre> \n";
//echo
"<pre>get_organizations_info: "; print_r(array_values($crap2)); echo "</pre>
\n";
//if ($crap[0]['my_org_id'] =
15)
//{
//echo
"<pre>get_organizations_info: "; print_r($crap2); echo "</pre> \n";
//}
if( is_array($crap2) )
{
$entries[$entry['contact_id']] =
array_merge($entries[$entry['contact_id']],$crap2[0]);
}
}
// merge in the fields_comms2 data
$crap =
$this->bo->get_comm_contact_data($entries[$entry['contact_id']]['my_org_id'],
$fields_comm2);
//$entries[$entry['contact_id']][] =
$crap[$entries[$entry['contact_id']]['my_org_id']];
$entries[$entry['contact_id']] =
array_merge($entries[$entry['contact_id']],$crap[$entries[$entry['contact_id']]['my_org_id']]);
//for ($j=0; $j<count($fields2); $j++)
//{
//$fields2[0] = $fields2[$j];
//$test =
$this->bo->get_comm_contact_data($entries[$i]['contact_id'], $fields_comm);
//$entries[$i][$fields_comms[$j]] = $test[0]['comm_data'];
//echo
"<pre>get_comm_contact_data: "; print_r($test); echo "</pre> \n";;
//}
//for ($j=0; $j<count($fields_comms2);
$j++)
//{
//$fields_comm2[0] =
$fields_comms2[$j];
//$test =
$this->bo->get_comm_contact_data($entries[$i]['contact_id'], $fields_comm2);
//echo
"<pre>get_comm_contact_data: "; print_r($test); echo "</pre> \n";;
//$entries[$i][$fields_comms2[$j]] = $test[0]['comm_data'];
//echo
"<pre>get_comm_contact_data: "; print_r($test); echo "</pre> \n";;
//}
if($entry['cat_id'])
{
//echo "<pre>cat_info: ";
print_r($entry['cat_id']); echo "</pre> \n";
//$cats =
$GLOBALS['phpgw']->categories->return_sorted_array(0,False,'','','',!$type);
$cats =
explode(',',$entry['cat_id']);
//echo "<pre>cat_info: ";
print_r($cats); echo "</pre> \n";
//$c = 0;
$catname = '';
// get category names
if( ! is_array($subcats) )
{
$subcats = array();
}
while (list($key,$contactscat)
= each($cats))
{
if ($contactscat &&
in_array(intval($contactscat),$subcats))
{
//$catinfo =
$this->cat->return_single(intval($contactscat));
//$catinfo =
$categories->return_single(intval($contactscat));
//$catname .=
$catinfo[0]['name'] . '; ';
//$GLOBALS['phpgw']->categories->id2name($key);
$catname .=
$categories->id2name(intval($contactscat)) . '; ';
}
//$c++;
}
//echo "<pre>cat_info: ";
print_r($catname); echo "</pre> \n";
//$entries[$entry['contact_id']]['cat_id'] = explode(',',$cats);
$entries[$entry['contact_id']]['cat_id'] = $catname;
//$fields['cat_id'] =
count($fcat_id) > 1 ? ','.implode(',',$fcat_id).',' : $fcat_id[0];
}
}
}
$fields = array_merge($fields, $fields_comms);
$fields2 = array_merge($fields2, $fields_comms2);
//echo "<pre>fields: "; print_r($fields); echo "</pre>
\n";
//echo "<pre>fields2: "; print_r($fields2); echo
"</pre> \n";
//echo "<pre>entries_comms: "; print_r($entries_comms);
echo "</pre> \n";
//echo "<pre>entries: "; print_r($entries); echo
"</pre> \n";
$cols = count($fields) + count($fields2);
$rows = count($entries);
//echo "cols: " . $cols . " \n";
//open the xml file and edit it
// get contents of a file into a string
//echo "<pre>Reading OpenOffice file</pre> \n";
$file = $GLOBALS['phpgw_info']['server']['temp_dir'] .
'/' . $tempdir2 . '/' . $filename2;
$f = fopen ($file, "r+b");
$contents = fread ($f, filesize ($file));
rewind($f);
//substr ( string string, int start [, int length])
//strpos ( string haystack, string needle [, int
offset])
/*
<table:table table:name="Table1"
table:style-name="Table1">
<table:table-column table:style-name="Table1.A"/>
*/
//echo $contents;
//print_r($contents);
//echo "<pre>Merging data into OpenOffice file</pre>
\n";
$endpointer = strpos( $contents, '<table:table' );
$newcontents = substr( $contents, $startpointer,
$endpointer - $startpointer);
//echo $endpointer . ' ' . $startpointer . ' ';
//echo "<pre>newcontents: "; print_r($newcontents);
echo "</pre> \n";
$startpointer = $endpointer;
$endpointer = strpos( $contents, '>Header<',
$startpointer ) + 1 ;
$newcontents .= substr( $contents, $startpointer,
$endpointer - $startpointer);
$startpointer = $endpointer;
// skip template text
$endpointer = strpos( $contents, '<', $startpointer );
$startpointer = $endpointer;
// add new text
if( $fields[0] )
{
$newcontents .=
utf8_encode(htmlentities($fields[0]));
}
elseif( $fields2[0] )
{
$newcontents .=
utf8_encode(htmlentities($fields2[0]));
}
else
{
$newcontents .= 'no header';
}
//$newcontents .= '>';
// add more columns
for($i=1; $i<$cols; $i++)
{
$newcontents .= '</text:p>' . "\n";
$newcontents .= '</table:table-cell>' . "\n";
$newcontents .= '<table:table-cell>' . "\n";
$newcontents .= '<text:p>' . "\n";
//$newcontents .= 'Field name ' . $i;
if( $i < count($fields) )
{
$newcontents .=
utf8_encode(htmlentities($fields[$i]));
}
elseif( $i < (count($fields) + count($fields2))
)
{
$newcontents .=
utf8_encode(htmlentities($fields2[$i-count($fields)]));
//$newcontents .=
$this->get_comm_value($myid, $column[key])
}
else
{
$newcontents .= 'no header'; //
shouldn't ever be called
}
}
$endpointer = strpos( $contents, '>Data<',
$startpointer ) + 1 ;
$newcontents .= substr( $contents, $startpointer,
$endpointer - $startpointer );
$startpointer = $endpointer;
// skip template text
$endpointer = strpos( $contents, '<', $startpointer );
$startpointer = $endpointer;
// add new text
$process = array_shift($entries);
//print_r($process);
//$newcontents .= 'Data: Row ' . '0' . ' Column ' . '0';
if( $fields[0] && $rows > 0 )
{
$newcontents .=
utf8_encode(htmlentities($process[$fields[0]]));
}
elseif( $fields2[0] && $rows > 0 )
{
$newcontents .=
utf8_encode(htmlentities($process[$fields2[0]]));
}
else
{
$newcontents .= 'no data';
}
//$newcontents .= 'Data: Row 0 Column 0';
//$newcontents .= '>';
// add more columns
for($i=1; $i<$cols; $i++)
{
$newcontents .= '</text:p>' . "\n";
$newcontents .= '</table:table-cell>' . "\n";
$newcontents .= '<table:table-cell>' . "\n";
$newcontents .= '<text:p>' . "\n";
//$newcontents .= 'Data: Row ' . '0' . ' Column
' . $i;
if( $i < count($fields) )
{
$newcontents .=
utf8_encode(htmlentities($process[$fields[$i]]));
//$newcontents .=
$entries[0][$fields[$i]];
}
elseif( $i < (count($fields)+count($fields2)) )
{
$newcontents .=
utf8_encode(htmlentities($process[$fields2[$i-count($fields)]]));
//$newcontents .=
$entries[0][$fields2[$i-count($fields)]];
//echo $i-count($fields) .
$fields_comms[$i-count($fields)];
}
else
{
$newcontents .= 'no data';
}
}
// add extra rows of columns
//$newcontents .= '</text:p>';
//$newcontents .= '</table:table-cell>';
//$newcontents .= '</table:table-row>';
for($r=1; $r<$rows; $r++)
{
$newcontents .= '</text:p>' . "\n";
$newcontents .= '</table:table-cell>' . "\n";
$newcontents .= '</table:table-row>' . "\n";
$newcontents .= '<table:table-row>' . "\n";
$process = array_shift($entries);
for($i=0; $i<$cols; $i++)
{
$newcontents .= '<table:table-cell>' .
"\n";
$newcontents .= '<text:p>' . "\n";
//$newcontents .= 'Data: Row ' . $r . '
Column ' . $i;
if( $i < count($fields) )
{
$newcontents .=
utf8_encode(htmlentities($process[$fields[$i]]));
//$newcontents .=
$entries[$r][$fields[$i]];
}
elseif( $i <
(count($fields)+count($fields2)) )
{
//$newcontents .=
$entries[$r][$fields2[$i-count($fields)]];
$newcontents .=
utf8_encode(htmlentities($process[$fields2[$i-count($fields)]]));
}
else
{
$newcontents .= 'no data'; //
shouldn't get used
}
if( $i != ($cols-1) ) // don't add this
last time through
{
$newcontents .= '</text:p>' .
"\n";
$newcontents .=
'</table:table-cell>' . "\n";
}
}
}
// skip the last </text:p></table:table-cell>
//$endpointer = strpos( $contents,
'</table:table-row>', $startpointer );
//$startpointer = $endpointer;
// add the rest of the file
$newcontents .= substr( $contents, $startpointer );
// empty file and write in new contents
//echo "<pre>Writing data into OpenOffice file</pre>
\n";
rewind($f);
fwrite($f,$newcontents);
fflush($f);
ftruncate($f, ftell($f));
/*
from http://ca3.php.net/manual/en/function.fopen.php
To overwrite a file with a new content without deleting
it, and without changing the owner or access rights, it's best to not use:
$file = fopen($filename, 'r+b); // binary update mode
...
ftruncate($file, 0);
fwrite($file, $my_stuff);
...
fclose($file);
but instead the faster one:
$file = fopen($filename, 'r+b); // binary update mode
...
rewind($file);
fwrite($file, $my_stuff);
fflush($file);
ftruncate($file, ftell($file));
...
fclose($file);
The reason is that truncating a file at size 0 forces
the OS to deallocate all storage clusters used by the file, before you write
your content which will be reallocated on disk.
The second code simply overwrites the existing content
where it is already located on disk, and truncates any remaining bytes that may
exist (if the new content is shorter than the old content). The "r+b" mode
allows access for both read and write: the file can be kept opened after
reading it and before rewriting the modified content.
It's particularly useful for files that are accessed
often or have a size larger than a few kilobytes, as it saves lots of system
I/O, and also limits the filesystem fragmentation if the updated file is quite
large.
And this method also works if the file is locked
exclusively once opened (but I would rather recommend using another empty file
for locking purpose, opened with "a+" access mode, in "/var/lock/yourapp/*" or
other fast filesystems where filelocks are easily monitored and where the
webserver running PHP is allowed to create and update lock files, and not
forgetting to close the lock file after closing the content file).
*/
fclose ($f);
// clean up my ab tables
//select * from phpgw_contact LEFT JOIN
phpgw_ttrack_jobs ON phpgw_contact.contact_id=phpgw_ttrack_jobs.company_id
WHERE phpgw_ttrack_jobs.company_id IS NULL;
//zip it up again
//echo "<pre></pre>";
//echo $GLOBALS['phpgw_info']['server']['temp_dir'] .
'/' . $tempdir2;
chdir($GLOBALS['phpgw_info']['server']['temp_dir'] .
'/' . $tempdir2);
//echo '/usr/bin/zip -r ' .
$GLOBALS['phpgw_info']['server']['temp_dir'] . '/' . $filename1 . ' *' . ' &>
/dev/null';
system('/usr/bin/zip -r ' .
$GLOBALS['phpgw_info']['server']['temp_dir'] . '/' . $filename1 . ' *' . ' &>
/dev/null', $null );
//system('/usr/bin/unzip -o addressbook/inc/export/'.
$filename1 .' -d ' . $GLOBALS['phpgw_info']['server']['temp_dir'] . '/' .
$tempdir2 . ' &> /dev/null', $null);
//echo "<pre>Export_vars: "; print_r($export_vars);
echo "</pre> \n";
//return $buffer;
return $GLOBALS['phpgw_info']['server']['temp_dir'] .
'/' . $filename1;
}
}
?>
====================================================
Index: sample.sxc
PKbB,Ëö÷ùOWÇ®eÒöJSó(&©ÒBQÁ®|ÝÁjy^çź|ÝnX«Þ,·Ãâ\ìÙvwÿô¸f0C,¤¢®U%#mļÌÙ¹Ïuuè$9
g`0"áÇ%:üFýØì3D,úÛrÇ1;0[EïÓ÷>ò·§åy$x#û¥¦tÄ;Áã$¸ð#õ¶æm/ÿ½i¬>ÏüâEðå'PKíË+×à$aÇTå:$køF?½8ûa}()ÿ`a#!Ó(^N{6³è¢Wï¸õF±PÓ·:ÉÕ±NLëò8è=ãÈ=Í¥çù0Þ"Z¸¦7zm0àGè5P[tâ¤n59æi
S Ù
ÆòVhr\Tð08ö²\¬ myQÍ´2+S)ª²ÆL;3Â)ùHWÈZîG¼ws
TnS[O,È=;CÎ+Âb.0Wèg°ù½§5úã}¾ÀÖøåðaJ9Léû&address@hidden"¯
4
d¥"address@hidden:<?cd-ßl´MöÙ&EÝgáäļçYÂ*öÇîÍi¿,´¹j¤Üt_Ýí±¶<øa
r£ØS¤Òn)Á]QK
#ú(aZ
ÐÆ=®ZTbB,Ëö÷ùOWÇ®eÒöJSó(&©ÒBQÁ®|ÝÁjy^çź|ÝnX«Þ,·Ãâ\ìÙvwÿô¸f0C,¤¢®U%#mļÌÙ¹Ïuuè$9
g`0"áÇ%:üFýØì3D,úÛrÇ1;0[EïÓ÷>ò·§åy$x#û¥¦tÄ;Áã$¸ð#õ¶æm/ÿ½i¬>ÏüâEðå'PKíË+×à¸
å4Bº³W,ÚyéJÂO3C!Ó"±síH
éô~¦©ÖW2²Áj¼He©Ð²¦êwZKSyYÅÒI;Vlò>{¸8|ݵҩ-ÚÀÄd°Úê.§¦%Öæ¹·69g©®Ñò>âÈ\Ê¢t¸6´D»Î¿<¹;E
ï¼á]èÍ7'ïmX·h£lxÇqÊ;ìA,w
Qͽ¡ÑÑrí§=J/áÁZù=)!¼J2'¿kòPKCSãýV¸¸xí]2ºÍ·lÀ/2L1'ÉÌçZÝW÷3
óMÌòÈáÕTÕÎÃO¡|°I¢kZËÆ/PbguT ç2ÏÜCrA;«#!Ê2G
®fþ¤cdßëѬF¬aÕTp8ïîfcc*èÕX«ÏB)address@hidden
address@hidden@¾èi*e'(ÆÈïIVL
address@hidden)¶Æ
Ú6&©9®ü8dN\d$+#AdϼîÚ¨,îYn-î¦Å¶Reþ£³¼§bTeÈJ3ÎêRM%Ê.q]>º±Ü¸pêºä
èóÅC¤MqÊ)address@hiddenaddress@hidden:Õl £
=íÖ±ÝÔi×'_ä{¶æ´¢ºø_1JÕ|û0¯Â3ÈĶcÞáVIÕ\öyhȰ¿ÓÝþä÷ã/òßr·Ýÿpèç;gÉÅ<!DOCTYPE
office:document-meta PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN"
"office.dtd">
<office:document-meta xmlns:office="http://openoffice.org/2000/office"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:meta="http://openoffice.org/2000/meta" office:version="1.0">
<office:meta>
<meta:generator>OpenOffice.org 1.1.0 (Linux)
</meta:generator><!--645m19(Build:8693)-->
<meta:creation-date>2003-11-26T21:58:24</meta:creation-date>
<dc:date>2003-11-27T11:47:28</dc:date>
<dc:language>en-US</dc:language>
<meta:editing-cycles>11</meta:editing-cycles>
<meta:editing-duration>PT23M19S</meta:editing-duration>
<meta:user-defined meta:name="Info 1"/>
<meta:user-defined meta:name="Info 2"/>
<meta:user-defined meta:name="Info 3"/>
<meta:user-defined meta:name="Info 4"/>
<meta:document-statistic meta:table-count="3" meta:cell-count="7"/>
</office:meta>
</office:document-meta>address@hidden
7"öXÜBЩÒ$"VaFxqq&BÖ³ -´HeQè÷Ym.ãíÇ
Þyz(«!·¾-ã7I¶¸Ç!±"ÛÅsæºrTí¶¼2ðCkAYÀ(~Eh;%¹*Ëcú.`8öïü
kDLfßGHM'¦bÓRÑIé+RÒ·>|rl<û<ü±ò]ñÙîËrÝdº¯És_å¾ Çá
Ïo_Ý>>)Gi8a¥®8q:¢s×EvJKÍ©Äv6_Ø0Dç*¦0XHµhzû·¬¸Äö8ºZ7¾M{Äÿå5PÜf¨ÖðcÕ&zó÷¡£ØIÿºßÖAx§ÅqÒÏÖ«>]}Z½{2ÛN«N&ÄzÿWà¨bjìTÎSÛMß\2¨Iß¿<ôÐÅ?Ф
Ï¥ÿ±ºÞ;&[Ù]°Ìú8µ$x&èzÓNaTCè¿UCÑyê?1Ðh\Ô|,!
êÃb6tD¬Ñç(L2Ág^ÑíÚ( Äv#êðny¿~¬Às4Ì>|ÞS°°¨b#+cóúÈóßË=BDa¤
fk:|éãÝüæÓðúÑoݵPKE£3®
====================================================
Index: sample.sxw
PKbB,Ëö÷ùOWÇ®eÒöJSó(&©ÒBQÁ®|ÝÁjy^çź|ÝnX«Þ,·Ãâ\ìÙvwÿô¸f0C,¤¢®U%#mļÌÙ¹Ïuuè$9
g`0"áÇ%:üFýØì3D,úÛrÇ1;0[EïÓ÷>ò·§åy$x#û¥¦tÄ;Áã$¸ð#õ¶æm/ÿ½i¬>ÏüâEðå'PKíË+×àÂ(z(°°YÆ#äG~?QôñKg¯è$,q&qѲVÐJyeÒAÖ1ýÐG}s)-×6CèÄ·)c¼zõ{cڨȷÄd÷ݸYNýO#ü«I!ôÇ0,µÕßK¥i:xv+¨¸
ÅL½»àƵoæÿ0ÝM?ÜÒúê®8ÉÜ®5dÏù£÷²¸·)%TÏCQjpIÈàÊgp§vI¹e
,ÝíÁàxqýSKfwöahä_ü´$Òù(ÜÂå"F5O)
oEt 8 ²qô< ¹(Q
¹îy/Å.ÃÑNÏ·Ú¸gSÍBÜ"3øURAgD©/ðÙã¾ µJÃshFv
Ez52ÅÀYr¯MìÜÇäďӸeaA óKyIPj_ÚàwÖCoh^Ibܧ"q)©WUÂ
®¨ªËº~¢ám
address@hidden @Jl4¿ÍÉRHÈE½hMÑ5¥
X!&bB,Ëö÷ùOWÇ®eÒöJSó(&©ÒBQÁ®|ÝÁjy^çź|ÝnX«Þ,·Ãâ\ìÙvwÿô¸f0C,¤¢®U%#mļÌÙ¹Ïuuè$9
g`0"áÇ%:üFýØì3D,úÛrÇ1;0[EïÓ÷>ò·§åy$x#û¥¦tÄ;Áã$¸ð#õ¶æm/ÿ½i¬>ÏüâEðå'PKíË+×à¸
å4Bº³W,ÚyéJÂO3C!Ó"±síH
éô~¦©ÖW2²Áj¼He©Ð²¦êwZKSyYÅÒI;Vlò>{¸8|ݵҩ-ÚÀÄd°Úê.§¦%Öæ¹·69g©®Ñò>âÈ\Ê¢t¸6´D»Î¿<¹;E
ï¼á]èÍ7'ïmX·h£lxÇqÊ;ìA,w
Qͽ¡ÑÑrí§=J/áÁZù=)!¼JÅÉÿüPÍ/address@hidden" Ñ9ÓQ¬óMQ
address@hidden'ynH
ò Î,address@hidden)«ë!þ]\iÀipgD°[PÓÆ?üî\Ä̹$X:
YïæÆHý§g½eIè|(!AcF{L1'ÁÊbÒÁ3¿OYVn¦:6æâåIéå.ÝÞpÅ$J¯ÕÚ¹$
U2Ô=¡3N¾u¬Üùl±X©H»øâzÑàî
ûay0¨i?ÍõO+¨I"È7è^¨Ü¶ÑM6ÐiÉSÉ!z·×Z h¯JÚâ|yhâØ
Öt>`6nùP%&
'Ìx¶899~À´»j÷YÖ¥£:]÷);½4OªGe¡üqæDÆÕw1ÉsüØÕ¼´zÊRT¢øVjrGx¤ï7êàçx'sÐÌÑàòXªÅPú,/ú&ª²¬{ty³wÉùÓ¦¹GÚõÇé!Sí¦HûßAÕd^Hy¦·ÍVù±r×pàï¹
IBº73ÐW¹1LPAøe6¯l7È`nÇýI¢{ݾÕ;nËÈb12=ËJ
2N`¨\YÆaC%ÒÝÝ<Cûf§CI½
t¶Z^zVu7ún¸Uµ7âÝU33¾ÖQ
8³¬&>°Ï_´BaoÚÞCDô
;<]öÂP«3B¡:LuvÉ\zppüsýàÑzC{β3á\¬Ì«¿Ù¡¦Üê¨xjM5eÙ£B+PlW£ï
^ßVRì¨Úwþ·÷ê_PKÑÛÙã!<!DOCTYPE office:document-meta PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "office.dtd">
<office:document-meta xmlns:office="http://openoffice.org/2000/office"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:meta="http://openoffice.org/2000/meta" office:version="1.0">
<office:meta>
<meta:generator>OpenOffice.org 1.1.0 (Linux)
</meta:generator><!--645m19(Build:8693)-->
<meta:creation-date>2003-11-07T13:50:21</meta:creation-date>
<dc:date>2003-11-27T11:39:18</dc:date>
<dc:language>en-US</dc:language>
<meta:editing-cycles>28</meta:editing-cycles>
<meta:editing-duration>PT46M22S</meta:editing-duration>
<meta:user-defined meta:name="Info 1"/>
<meta:user-defined meta:name="Info 2"/>
<meta:user-defined meta:name="Info 3"/>
<meta:user-defined meta:name="Info 4"/>
<meta:document-statistic meta:table-count="1" meta:image-count="0"
meta:object-count="0" meta:page-count="1" meta:paragraph-count="13"
meta:word-count="90" meta:character-count="479"/>
</office:meta>
</office:document-meta>PK
Ò£Zbx^3èFi%»¿UÍGn8ÝÙýbr}¹x¼
þ¿¼&o1þt¦ë÷üáȪ6,ÝOøë;ÐõQض¥=ôµ
¾öº6ÿæ4Õi2ÿv=l¢Ä·§3lòþ)·40k&ý©±òðpó0CvW÷Cã8Ýï³5ê;·îÌÚÌ«(ÛÖ?þ·®æñmÝÒß
úîV×+/äò¾þØÑø\~¸ö´:¥Í{ý¥ßÑ÷ùXKMdîJìì¾Ý¹ØO»'çc{ª9ëz;<IGÜ
Ý&YÓ®é^ÚÒÄçõÃ}7ä}ðò¡ñTw$)¢ÝéßôFÿȲþ[Ñorëdýfº£l«âó§®6Únª[{ü÷Û×Íz¶ú\ääþÁÞü²õt~Æë1D_=q!?-k^{r}âîc½\öÞx)ª¸õÄëÔÛIÍ1ùèWÝ1a2Êÿ²Eh3!mÊñfVËN|)Öã¨oÝÃhw°`C
iàU¶mÓë|^o³¬K̼ø¸ðYcËËT÷/ÏÉJMÂ)#^ùÉæ
Z^I»£#DRÉWF&ÀDÆìxÍì©÷äqJÑjRû0üƽ$Ødvfé±P¿p=¶ð$8· /XcaqЦ
åUâ²±xåò¾hõSKõàçOEµþPKçWÊ~íª1&^4©Õ¤ºè3
8ãåíNÇ©ib츾ÿ?ôûB[á¼4:ÃÝ´ÐÌp©¯OÉ#îú÷ùxù¾¢
Õ2zu-V£ç1 !s+ô<Ï%©q!åÍêuMÈô#\O¥8ðßÌ`Jûó0Ãkë
LnÒ¸NË¢t'm+ÄH0z=TÂ~jÅ1Eq]ßjN?K|´'j×¶p¦´;êDæ/d¢£ÀAéDä²cFCØí0GÔKÖÔgNZQ£b×ãÝÀ{Q_ÇçvF3U´)ÕVâß5¥JøDþ7v#Fzþî³Û>i
_Á'PKx)n
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] addressbook/inc/export Outlook_CSV_-_Deutsch, 1.3 Outlook_CSV_-_English, 1.3 Palm_PDB, 1.3 Netscape_LDIF, 1.3 Multiple_VCard, 1.3 phpgw_LDIF, 1.3 phpgw_SQL, 1.3 OpenOffice_-_writer, 1.2 OpenOffice_-_calc, 1.2 sample.sxc, 1.2 sample.sxw, 1.2,
skwashd <=
- Prev by Date:
[Phpgroupware-cvs] addressbook/templates/idots/images navbar.png, 1.2
- Next by Date:
[Phpgroupware-cvs] addressbook/setup setup.inc.php, 1.31 phpgw_es.lang, 1.9 phpgw_fr.lang, 1.11 phpgw_ja.lang, 1.9 phpgw_en.lang, 1.26 phpgw_de.lang, 1.11 phpgw_tr.lang, 1.2
- Previous by thread:
[Phpgroupware-cvs] addressbook/templates/idots/images navbar.png, 1.2
- Next by thread:
[Phpgroupware-cvs] addressbook/setup setup.inc.php, 1.31 phpgw_es.lang, 1.9 phpgw_fr.lang, 1.11 phpgw_ja.lang, 1.9 phpgw_en.lang, 1.26 phpgw_de.lang, 1.11 phpgw_tr.lang, 1.2
- Index(es):