mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
Formatting and some adjustment to start making actual imports work again
This commit is contained in:
parent
ed3da58048
commit
3d06057c20
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
// This file defines a set of functions and an associative array.
|
// This file defines a set of functions and an associative array.
|
||||||
// The key of the array corresponds to a header in the source
|
// The key of the array corresponds to a header in the source
|
||||||
// outlook file and the value of the array item will be used in
|
// import file and the value of the array item will be used in
|
||||||
// the creation of the output file.
|
// the creation of the output file.
|
||||||
//
|
//
|
||||||
// An exported Outlook file looks like this:
|
// An exported Outlook file looks like this:
|
||||||
@ -23,230 +23,232 @@
|
|||||||
// Also start with a '#' symbol and a comma separated list will be
|
// Also start with a '#' symbol and a comma separated list will be
|
||||||
// turned into a number of the same entries.
|
// turned into a number of the same entries.
|
||||||
|
|
||||||
class outlook_conv {
|
class import_conv
|
||||||
var $basedn;
|
{
|
||||||
var $contactsdn;
|
var $basedn;
|
||||||
|
var $contactsdn;
|
||||||
|
|
||||||
var $sn; //these two vars will be used in
|
var $sn; //these two vars will be used in
|
||||||
var $o; //building a dn field.
|
var $o; //building a dn field.
|
||||||
var $givenName; //this is used in building a cn field
|
var $givenName; //this is used in building a cn field
|
||||||
var $currentrecord; //used for buffering to allow uid lines to go first
|
var $currentrecord; //used for buffering to allow uid lines to go first
|
||||||
|
|
||||||
var $outlook = array(
|
var $import = array(
|
||||||
"Title" => "",
|
"Title" => "",
|
||||||
"First Name" => "givenName",
|
"First Name" => "givenName",
|
||||||
"Middle Name" => "",
|
"Middle Name" => "",
|
||||||
"Last Name" => "sn",
|
"Last Name" => "sn",
|
||||||
"Suffix" => "",
|
"Suffix" => "",
|
||||||
"Company" => "o", //objectclass: organization
|
"Company" => "o", //objectclass: organization
|
||||||
"Department" => "ou", //objectclass: organizationalPerson
|
"Department" => "ou", //objectclass: organizationalPerson
|
||||||
"Job Title" => "title", //objectclass: organizationalPerson
|
"Job Title" => "title", //objectclass: organizationalPerson
|
||||||
"Business Street" => "postalAddress",
|
"Business Street" => "postalAddress",
|
||||||
"Business Street 2" => "",
|
"Business Street 2" => "",
|
||||||
"Business Street 3" => "",
|
"Business Street 3" => "",
|
||||||
"Business City" => "l",
|
"Business City" => "l",
|
||||||
"Business State" => "st",
|
"Business State" => "st",
|
||||||
"Business Postal Code" => "postalCode",
|
"Business Postal Code" => "postalCode",
|
||||||
"Business Country" => "co",
|
"Business Country" => "co",
|
||||||
"Home Street" => "homePostalAddress",
|
"Home Street" => "homePostalAddress",
|
||||||
"Home City" => "+\n",
|
"Home City" => "+\n",
|
||||||
"Home State" => "+, ",
|
"Home State" => "+, ",
|
||||||
"Home Postal Code" => "+ ",
|
"Home Postal Code" => "+ ",
|
||||||
"Home Country" => "+\n",
|
"Home Country" => "+\n",
|
||||||
"Home Street 2" => "",
|
"Home Street 2" => "",
|
||||||
"Home Street 3" => "",
|
"Home Street 3" => "",
|
||||||
"Other Street" => "",
|
"Other Street" => "",
|
||||||
"Other City" => "+\n",
|
"Other City" => "+\n",
|
||||||
"Other State" => "+, ",
|
"Other State" => "+, ",
|
||||||
"Other Postal Code" => "+ ",
|
"Other Postal Code" => "+ ",
|
||||||
"Other Country" => "+\n",
|
"Other Country" => "+\n",
|
||||||
"Assistant's Phone" => "",
|
"Assistant's Phone" => "",
|
||||||
"Business Fax" => "facsimileTelephoneNumber",
|
"Business Fax" => "facsimileTelephoneNumber",
|
||||||
"Business Phone" => "telephoneNumber",
|
"Business Phone" => "telephoneNumber",
|
||||||
"Business Phone 2" => "",
|
"Business Phone 2" => "",
|
||||||
"Callback" => "",
|
"Callback" => "",
|
||||||
"Car Phone" => "",
|
"Car Phone" => "",
|
||||||
"Company Main Phone" => "",
|
"Company Main Phone" => "",
|
||||||
"Home Fax" => "",
|
"Home Fax" => "",
|
||||||
"Home Phone" => "homePhone",
|
"Home Phone" => "homePhone",
|
||||||
"Home Phone 2" => "homePhone", //This will make another homePhone entry
|
"Home Phone 2" => "homePhone", //This will make another homePhone entry
|
||||||
"ISDN" => "",
|
"ISDN" => "",
|
||||||
"Mobile Phone" => "mobile", //newPilotPerson
|
"Mobile Phone" => "mobile", //newPilotPerson
|
||||||
"Other Fax" => "",
|
"Other Fax" => "",
|
||||||
"Other Phone" => "",
|
"Other Phone" => "",
|
||||||
"Pager" => "pager",
|
"Pager" => "pager",
|
||||||
"Primary Phone" => "",
|
"Primary Phone" => "",
|
||||||
"Radio Phone" => "",
|
"Radio Phone" => "",
|
||||||
"TTY/TDD Phone" => "",
|
"TTY/TDD Phone" => "",
|
||||||
"Telex" => "telexNumber", //organization
|
"Telex" => "telexNumber", //organization
|
||||||
"Account" => "",
|
"Account" => "",
|
||||||
"Anniversary" => "",
|
"Anniversary" => "",
|
||||||
"Assistant's Name" => "secretary", //newPilotPerson
|
"Assistant's Name" => "secretary", //newPilotPerson
|
||||||
"Billing Information" => "",
|
"Billing Information" => "",
|
||||||
"Birthday" => "",
|
"Birthday" => "",
|
||||||
"Categories" => "#businessCategory",
|
"Categories" => "#businessCategory",
|
||||||
"Children" => "",
|
"Children" => "",
|
||||||
"Directory Server" => "",
|
"Directory Server" => "",
|
||||||
"E-mail Address" => "mail",
|
"E-mail Address" => "mail",
|
||||||
"E-mail Display Name" => "",
|
"E-mail Display Name" => "",
|
||||||
"E-mail 2 Address" => "otherMailbox",
|
"E-mail 2 Address" => "otherMailbox",
|
||||||
"E-mail 2 Display Name" => "",
|
"E-mail 2 Display Name" => "",
|
||||||
"E-mail 3 Address" => "otherMailbox", //add another...
|
"E-mail 3 Address" => "otherMailbox", //add another...
|
||||||
"E-mail 3 Display Name" => "",
|
"E-mail 3 Display Name" => "",
|
||||||
"Gender" => "",
|
"Gender" => "",
|
||||||
"Government ID Number" => "",
|
"Government ID Number" => "",
|
||||||
"Hobby" => "",
|
"Hobby" => "",
|
||||||
"Initials" => "",
|
"Initials" => "",
|
||||||
"Internet Free Busy" => "",
|
"Internet Free Busy" => "",
|
||||||
"Keywords" => "",
|
"Keywords" => "",
|
||||||
"Language" => "",
|
"Language" => "",
|
||||||
"Location" => "",
|
"Location" => "",
|
||||||
"Manager's Name" => "",
|
"Manager's Name" => "",
|
||||||
"Mileage" => "",
|
"Mileage" => "",
|
||||||
"Notes" => "comment",
|
"Notes" => "comment",
|
||||||
"Office Location" => "physicalDeliveryOfficeName",
|
"Office Location" => "physicalDeliveryOfficeName",
|
||||||
"Organizational ID Number" => "",
|
"Organizational ID Number" => "",
|
||||||
"PO Box" => "postOfficeBox",
|
"PO Box" => "postOfficeBox",
|
||||||
"Priority" => "",
|
"Priority" => "",
|
||||||
"Private Profession" => "",
|
"Private Profession" => "",
|
||||||
"Referred By" => "",
|
"Referred By" => "",
|
||||||
"Sensitivity" => "",
|
"Sensitivity" => "",
|
||||||
"Spouse" => "",
|
"Spouse" => "",
|
||||||
"User 1" => "",
|
"User 1" => "",
|
||||||
"User 2" => "",
|
"User 2" => "",
|
||||||
"User 3" => "",
|
"User 3" => "",
|
||||||
"User 4" => "",
|
"User 4" => "",
|
||||||
"Web Page" => "");
|
"Web Page" => ""
|
||||||
|
);
|
||||||
|
|
||||||
function outlook_start_file($buffer,$basedn="",$context="") {
|
function import_start_file($buffer,$basedn="",$context="") {
|
||||||
# Here are some tests for correct basedn and Contacts context.
|
# Here are some tests for correct basedn and Contacts context.
|
||||||
# If none of these are correct, ldap_add will fail, but at least
|
# If none of these are correct, ldap_add will fail, but at least
|
||||||
# we can give them a fighting chance.
|
# we can give them a fighting chance.
|
||||||
if (!empty($basedn) && empty($context)) {
|
if (!empty($basedn) && empty($context)) {
|
||||||
# Oops, no context, try a default
|
# Oops, no context, try a default
|
||||||
$context = "ou=Contacts,".$basedn;
|
$context = "ou=Contacts,".$basedn;
|
||||||
} elseif (empty($basedn) && !empty($context)) {
|
} elseif (empty($basedn) && !empty($context)) {
|
||||||
# Oops, no basedn, try this one
|
# Oops, no basedn, try this one
|
||||||
$work = split(",",$context);
|
$work = split(",",$context);
|
||||||
array_shift($work);
|
array_shift($work);
|
||||||
for ($i=0;$i<count($work);$i++) {
|
for ($i=0;$i<count($work);$i++) {
|
||||||
if($i==0) {
|
if($i==0) {
|
||||||
$basedn = $work[$i];
|
$basedn = $work[$i];
|
||||||
} else {
|
} else {
|
||||||
$basedn = $basedn.$work[$i];
|
$basedn = $basedn.$work[$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif(empty($basedn) && empty($context)) {
|
} elseif(empty($basedn) && empty($context)) {
|
||||||
# Wow, create both from known info
|
# Wow, create both from known info
|
||||||
$work = split(",",$phpgw_info["server"]["ldap_context"]);
|
$work = split(",",$phpgw_info["server"]["ldap_context"]);
|
||||||
array_shift($work);
|
array_shift($work);
|
||||||
for ($i=0;$i<count($work);$i++) {
|
for ($i=0;$i<count($work);$i++) {
|
||||||
if($i==0) {
|
if($i==0) {
|
||||||
$basedn = $work[$i];
|
$basedn = $work[$i];
|
||||||
} else {
|
} else {
|
||||||
$basedn = $basedn.",".$work[$i];
|
$basedn = $basedn.",".$work[$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$context = "ou=Contacts,".$basedn;
|
$context = "ou=Contacts,".$basedn;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->basedn= $basedn;
|
$this->basedn= $basedn;
|
||||||
$this->contactsdn= $context;
|
$this->contactsdn= $context;
|
||||||
|
$buffer="";
|
||||||
|
return $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
return $buffer;
|
function import_end_file($buffer) {
|
||||||
}
|
return $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
function outlook_end_file($buffer) {
|
function import_start_record($buffer) {
|
||||||
return $buffer;
|
global $phpgw_info;
|
||||||
}
|
|
||||||
|
|
||||||
function outlook_start_record($buffer) {
|
$top="\nobjectClass: person
|
||||||
global $phpgw_info;
|
|
||||||
|
|
||||||
$top="\nobjectClass: person
|
|
||||||
objectClass: organizationalPerson
|
objectClass: organizationalPerson
|
||||||
objectClass: inetOrgPerson
|
objectClass: inetOrgPerson
|
||||||
objectClass: outlookPerson";
|
objectClass: importPerson";
|
||||||
|
|
||||||
$this->o="";
|
$this->o="";
|
||||||
$this->sn="";
|
$this->sn="";
|
||||||
$this->givenName="";
|
$this->givenName="";
|
||||||
|
|
||||||
$this->currentrecord = $top;
|
$this->currentrecord = $top;
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function outlook_end_record($buffer,$private="") {
|
function import_end_record($buffer,$private="") {
|
||||||
if (trim($this->sn) != "") {
|
if (trim($this->sn) != "") {
|
||||||
$this->currentrecord = "cn: ".$this->givenName." ".$this->sn.$this->currentrecord;
|
$this->currentrecord = "cn: ".$this->givenName." ".$this->sn.$this->currentrecord;
|
||||||
} else if (trim($this->o) != "") {
|
} else if (trim($this->o) != "") {
|
||||||
$this->currentrecord = "cn: ".$this->o.$this->currentrecord;
|
$this->currentrecord = "cn: ".$this->o.$this->currentrecord;
|
||||||
} else if (trim($this->givenName)) {
|
} else if (trim($this->givenName)) {
|
||||||
$this->currentrecord = "cn: ".$this->givenName.$this->currentrecord;
|
$this->currentrecord = "cn: ".$this->givenName.$this->currentrecord;
|
||||||
} else {
|
} else {
|
||||||
$this->currentrecord = "cn: (unnamed)".$this->currentrecord;
|
$this->currentrecord = "cn: (unnamed)".$this->currentrecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
$time = gettimeofday();
|
$time = gettimeofday();
|
||||||
$uid = ($this->sn?$this->sn:$this->o);
|
$uid = ($this->sn?$this->sn:$this->o);
|
||||||
if (strpos($uid, ",")) {
|
if (strpos($uid, ",")) {
|
||||||
$uid = str_replace(",", "\,", $uid);
|
$uid = str_replace(",", "\,", $uid);
|
||||||
$uid = "\"".$uid."\"";
|
$uid = "\"".$uid."\"";
|
||||||
}
|
}
|
||||||
$uid = time().$time["usec"].":".$uid;
|
$uid = time().$time["usec"].":".$uid;
|
||||||
$this->currentrecord = "dn: uid=$uid,".$this->contactsdn."\nuid: $uid"."\n".$this->currentrecord;
|
$this->currentrecord = "dn: uid=$uid,".$this->contactsdn."\nuid: $uid"."\n".$this->currentrecord;
|
||||||
|
|
||||||
while ($pos = strpos($this->currentrecord, "|br x=y/|")) {
|
while ($pos = strpos($this->currentrecord, "|br x=y/|")) {
|
||||||
$startline = strrpos(substr($this->currentrecord,0,$pos), "\n");
|
$startline = strrpos(substr($this->currentrecord,0,$pos), "\n");
|
||||||
if ($startline == "") {$startline = 0;}
|
if ($startline == "") {$startline = 0;}
|
||||||
$startattrib = strpos($this->currentrecord, ":", $startline) + 1;
|
$startattrib = strpos($this->currentrecord, ":", $startline) + 1;
|
||||||
$endline = strpos($this->currentrecord, "\n", $startattrib);
|
$endline = strpos($this->currentrecord, "\n", $startattrib);
|
||||||
if ($endline == "") { $endline = strlen($this->currentrecord); }
|
if ($endline == "") { $endline = strlen($this->currentrecord); }
|
||||||
$attrib = str_replace("|br x=y/|", "\r\n", substr($this->currentrecord, $startattrib + 1, $endline - $startattrib - 1));
|
$attrib = str_replace("|br x=y/|", "\r\n", substr($this->currentrecord, $startattrib + 1, $endline - $startattrib - 1));
|
||||||
$this->currentrecord = substr($this->currentrecord, 0, $startattrib).": ".base64_encode($attrib).substr($this->currentrecord, $endline);
|
$this->currentrecord = substr($this->currentrecord, 0, $startattrib).": ".base64_encode($attrib).substr($this->currentrecord, $endline);
|
||||||
}
|
}
|
||||||
return $buffer.$this->currentrecord."\n\n";
|
return $buffer.$this->currentrecord."\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function outlook_new_attrib($buffer,$name,$value) {
|
function import_new_attrib($buffer,$name,$value) {
|
||||||
if ($name == "sn") {
|
if ($name == "sn") {
|
||||||
$this->sn = $value;
|
$this->sn = $value;
|
||||||
}
|
}
|
||||||
if ($name == "o") {
|
if ($name == "o") {
|
||||||
$this->o = $value;
|
$this->o = $value;
|
||||||
}
|
}
|
||||||
if ($name == "givenName") {
|
if ($name == "givenName") {
|
||||||
$this->givenName = $value;
|
$this->givenName = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = str_replace("\n","|br x=y/|",$value);
|
$value = str_replace("\n","|br x=y/|",$value);
|
||||||
$name = str_replace("\n","|br x=y/|",$name);
|
$name = str_replace("\n","|br x=y/|",$name);
|
||||||
$value = str_replace("\r","",$value);
|
$value = str_replace("\r","",$value);
|
||||||
$name = str_replace("\r","",$name);
|
$name = str_replace("\r","",$name);
|
||||||
|
|
||||||
switch (substr($name,0,1)) {
|
switch (substr($name,0,1)) {
|
||||||
case '+':
|
case '+':
|
||||||
$this->currentrecord .= substr($name,1).$value;
|
$this->currentrecord .= substr($name,1).$value;
|
||||||
return $buffer;
|
return $buffer;
|
||||||
break;
|
break;
|
||||||
case '#':
|
case '#':
|
||||||
$data = explode(";",$value);
|
$data = explode(";",$value);
|
||||||
$num = count($data);
|
$num = count($data);
|
||||||
$return = "";
|
$return = "";
|
||||||
for ( $i=0; $i<$num; $i++ ) {
|
for ( $i=0; $i<$num; $i++ ) {
|
||||||
$return .= "\n".substr($name,1).": $data[$i]";
|
$return .= "\n".substr($name,1).": $data[$i]";
|
||||||
}
|
}
|
||||||
$this->currentrecord .= $return;
|
$this->currentrecord .= $return;
|
||||||
return $buffer;
|
return $buffer;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ($name == "otherMailbox") {
|
if ($name == "otherMailbox") {
|
||||||
$this->currentrecord .= "\n$name: smtp\$$value";
|
$this->currentrecord .= "\n$name: smtp\$$value";
|
||||||
} else {
|
} else {
|
||||||
$this->currentrecord .= "\n$name: $value";
|
$this->currentrecord .= "\n$name: $value";
|
||||||
}
|
}
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
} // end switch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
// This file defines a set of functions and an associative array.
|
// This file defines a set of functions and an associative array.
|
||||||
// The key of the array corresponds to a header in the source
|
// The key of the array corresponds to a header in the source
|
||||||
// outlook file and the value of the array item will be used in
|
// import file and the value of the array item will be used in
|
||||||
// the creation of the output file.
|
// the creation of the output file.
|
||||||
//
|
//
|
||||||
// An exported Outlook file looks like this:
|
// An exported Outlook file looks like this:
|
||||||
@ -23,168 +23,171 @@
|
|||||||
// Also start with a '#' symbol and a comma separated list will be
|
// Also start with a '#' symbol and a comma separated list will be
|
||||||
// turned into a number of the same entries.
|
// turned into a number of the same entries.
|
||||||
|
|
||||||
class outlook_conv {
|
class import_conv
|
||||||
var $currentrecord; //used for buffering to allow uid lines to go first
|
{
|
||||||
|
var $currentrecord; //used for buffering to allow uid lines to go first
|
||||||
|
|
||||||
var $outlook = array(
|
var $import = array(
|
||||||
"Title" => "title",
|
"Title" => "title",
|
||||||
"First Name" => "n_given",
|
"First Name" => "n_given",
|
||||||
"Middle Name" => "n_middle",
|
"Middle Name" => "n_middle",
|
||||||
"Last Name" => "n_family",
|
"Last Name" => "n_family",
|
||||||
"Suffix" => "n_suffix",
|
"Suffix" => "n_suffix",
|
||||||
"Company" => "org_name", //objectclass: organization
|
"Company" => "org_name", //objectclass: organization
|
||||||
"Department" => "org_unit", //objectclass: organizationalPerson
|
"Department" => "org_unit", //objectclass: organizationalPerson
|
||||||
"Job Title" => "title", //objectclass: organizationalPerson
|
"Job Title" => "title", //objectclass: organizationalPerson
|
||||||
"Business Street" => "address2",
|
"Business Street" => "address2",
|
||||||
"Business Street 2" => "",
|
"Business Street 2" => "",
|
||||||
"Business Street 3" => "",
|
"Business Street 3" => "",
|
||||||
"Business City" => "",
|
"Business City" => "",
|
||||||
"Business State" => "",
|
"Business State" => "",
|
||||||
"Business Postal Code" => "",
|
"Business Postal Code" => "",
|
||||||
"Business Country" => "",
|
"Business Country" => "",
|
||||||
"Home Street" => "adr_street",
|
"Home Street" => "adr_street",
|
||||||
"Home City" => "adr_locality",
|
"Home City" => "adr_locality",
|
||||||
"Home State" => "adr_region",
|
"Home State" => "adr_region",
|
||||||
"Home Postal Code" => "adr_postalcode",
|
"Home Postal Code" => "adr_postalcode",
|
||||||
"Home Country" => "adr_countryname",
|
"Home Country" => "adr_countryname",
|
||||||
"Home Street 2" => "",
|
"Home Street 2" => "",
|
||||||
"Home Street 3" => "",
|
"Home Street 3" => "",
|
||||||
"Other Street" => "",
|
"Other Street" => "",
|
||||||
"Other City" => "",
|
"Other City" => "",
|
||||||
"Other State" => "",
|
"Other State" => "",
|
||||||
"Other Postal Code" => "",
|
"Other Postal Code" => "",
|
||||||
"Other Country" => "",
|
"Other Country" => "",
|
||||||
"Assistant's Phone" => "",
|
"Assistant's Phone" => "",
|
||||||
"Business Fax" => "c_tel",
|
"Business Fax" => "c_tel",
|
||||||
"Business Phone" => "b_tel",
|
"Business Phone" => "b_tel",
|
||||||
"Business Phone 2" => "ophone",
|
"Business Phone 2" => "ophone",
|
||||||
"Callback" => "",
|
"Callback" => "",
|
||||||
"Car Phone" => "",
|
"Car Phone" => "",
|
||||||
"Company Main Phone" => "",
|
"Company Main Phone" => "",
|
||||||
"Home Fax" => "",
|
"Home Fax" => "",
|
||||||
"Home Phone" => "a.tel",
|
"Home Phone" => "a.tel",
|
||||||
"Home Phone 2" => "", //This will make another homePhone entry
|
"Home Phone 2" => "", //This will make another homePhone entry
|
||||||
"ISDN" => "",
|
"ISDN" => "",
|
||||||
"Mobile Phone" => "mphone", //newPilotPerson
|
"Mobile Phone" => "mphone", //newPilotPerson
|
||||||
"Other Fax" => "",
|
"Other Fax" => "",
|
||||||
"Other Phone" => "",
|
"Other Phone" => "",
|
||||||
"Pager" => "pager",
|
"Pager" => "pager",
|
||||||
"Primary Phone" => "",
|
"Primary Phone" => "",
|
||||||
"Radio Phone" => "",
|
"Radio Phone" => "",
|
||||||
"TTY/TDD Phone" => "",
|
"TTY/TDD Phone" => "",
|
||||||
"Telex" => "", //organization
|
"Telex" => "", //organization
|
||||||
"Account" => "",
|
"Account" => "",
|
||||||
"Anniversary" => "",
|
"Anniversary" => "",
|
||||||
"Assistant's Name" => "", //newPilotPerson
|
"Assistant's Name" => "", //newPilotPerson
|
||||||
"Billing Information" => "",
|
"Billing Information" => "",
|
||||||
"Birthday" => "bday",
|
"Birthday" => "bday",
|
||||||
"Categories" => "",
|
"Categories" => "",
|
||||||
"Children" => "",
|
"Children" => "",
|
||||||
"Directory Server" => "",
|
"Directory Server" => "",
|
||||||
"E-mail Address" => "d_email",
|
"E-mail Address" => "d_email",
|
||||||
"E-mail Display Name" => "",
|
"E-mail Display Name" => "",
|
||||||
"E-mail 2 Address" => "",
|
"E-mail 2 Address" => "",
|
||||||
"E-mail 2 Display Name" => "",
|
"E-mail 2 Display Name" => "",
|
||||||
"E-mail 3 Address" => "", //add another...
|
"E-mail 3 Address" => "", //add another...
|
||||||
"E-mail 3 Display Name" => "",
|
"E-mail 3 Display Name" => "",
|
||||||
"Gender" => "",
|
"Gender" => "",
|
||||||
"Government ID Number" => "",
|
"Government ID Number" => "",
|
||||||
"Hobby" => "",
|
"Hobby" => "",
|
||||||
"Initials" => "",
|
"Initials" => "",
|
||||||
"Internet Free Busy" => "",
|
"Internet Free Busy" => "",
|
||||||
"Keywords" => "",
|
"Keywords" => "",
|
||||||
"Language" => "",
|
"Language" => "",
|
||||||
"Location" => "",
|
"Location" => "",
|
||||||
"Manager's Name" => "",
|
"Manager's Name" => "",
|
||||||
"Mileage" => "",
|
"Mileage" => "",
|
||||||
"Notes" => "ab_notes",
|
"Notes" => "note",
|
||||||
"Office Location" => "",
|
"Office Location" => "",
|
||||||
"Organizational ID Number" => "",
|
"Organizational ID Number" => "",
|
||||||
"PO Box" => "postOfficeBox",
|
"PO Box" => "postOfficeBox",
|
||||||
"Priority" => "",
|
"Priority" => "",
|
||||||
"Private Profession" => "",
|
"Private Profession" => "",
|
||||||
"Referred By" => "",
|
"Referred By" => "",
|
||||||
"Sensitivity" => "",
|
"Sensitivity" => "",
|
||||||
"Spouse" => "",
|
"Spouse" => "",
|
||||||
"User 1" => "",
|
"User 1" => "",
|
||||||
"User 2" => "",
|
"User 2" => "",
|
||||||
"User 3" => "",
|
"User 3" => "",
|
||||||
"User 4" => "",
|
"User 4" => "",
|
||||||
"Web Page" => "");
|
"Web Page" => ""
|
||||||
|
);
|
||||||
|
|
||||||
function outlook_start_file($buffer,$j="",$k="") {
|
function import_start_file($buffer,$j="",$k="") {
|
||||||
return $buffer;
|
$buffer="";
|
||||||
}
|
return $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
function outlook_end_file($buffer) {
|
function import_end_file($buffer) {
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function outlook_start_record($buffer) {
|
function import_start_record($buffer) {
|
||||||
$top="";
|
$top="";
|
||||||
|
|
||||||
$this->currentrecord = $top;
|
$this->currentrecord = $top;
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function outlook_end_record($buffer,$private="private") {
|
function import_end_record($buffer,$private="private") {
|
||||||
global $phpgw_info;
|
global $phpgw_info;
|
||||||
$row=0;
|
$row=0;
|
||||||
$i=0;
|
$i=0;
|
||||||
$lines = split("##",$this->currentrecord);
|
$lines = split("##",$this->currentrecord);
|
||||||
|
|
||||||
# Commence the ugly parsing of csv into sql
|
|
||||||
for ($i=0;$i<count($lines)-1;$i++) {
|
|
||||||
list($name, $value) = split("%%",$lines[$i]);
|
|
||||||
$row++;
|
|
||||||
if ($row==1) {
|
|
||||||
if (!empty($name) && !empty($value)) {
|
|
||||||
if (count($lines)>2) {
|
|
||||||
$thisname=$name.",";
|
|
||||||
$thisvalu="'".$value."',";
|
|
||||||
} else {
|
|
||||||
$thisname=$name.") ";
|
|
||||||
$thisvalu="'".$value."');";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$thisname="";
|
|
||||||
$thisvalu="";
|
|
||||||
}
|
|
||||||
$namelist = $namelist."\nINSERT INTO phpgw_addressbook (owner,".$thisname;
|
|
||||||
$valulist = $valulist."VALUES ('".$phpgw_info["user"]["account_id"]."',".$thisvalu;
|
|
||||||
} elseif ($row==count($lines)-1) {
|
|
||||||
if (!empty($name) && !empty($value)) {
|
|
||||||
$thisname=$name.") ";
|
|
||||||
$thisvalu="'".$value."');";
|
|
||||||
} else {
|
|
||||||
$thisname="";
|
|
||||||
$thisvalu="";
|
|
||||||
}
|
|
||||||
$namelist = $namelist.$thisname;
|
|
||||||
$valulist = $valulist.$thisvalu;
|
|
||||||
} else {
|
|
||||||
if (!empty($name) && !empty($value)) {
|
|
||||||
$thisname=$name.",";
|
|
||||||
$thisvalu="'".$value."',";
|
|
||||||
} else {
|
|
||||||
$thisname=",";
|
|
||||||
$thisvalu=",";
|
|
||||||
}
|
|
||||||
$namelist = $namelist.$thisname;
|
|
||||||
$valulist = $valulist.$thisvalu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $buffer.$namelist.$valulist;
|
|
||||||
}
|
|
||||||
|
|
||||||
function outlook_new_attrib($buffer,$name,$value) {
|
# Commence the ugly parsing of csv into sql
|
||||||
$value = str_replace("\n","<BR>",$value);
|
for ($i=0;$i<count($lines)-1;$i++) {
|
||||||
$value = str_replace("\r","",$value);
|
list($name, $value) = split("%%",$lines[$i]);
|
||||||
if ($value=="") { $value="NULL"; }
|
$row++;
|
||||||
$this->currentrecord .= $name."%%".$value."##";
|
if ($row==1) {
|
||||||
|
if (!empty($name) && !empty($value)) {
|
||||||
return $buffer;
|
if (count($lines)>2) {
|
||||||
}
|
$thisname=$name.",";
|
||||||
}
|
$thisvalu="'".$value."',";
|
||||||
|
} else {
|
||||||
|
$thisname=$name.") ";
|
||||||
|
$thisvalu="'".$value."');";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$thisname="";
|
||||||
|
$thisvalu="";
|
||||||
|
}
|
||||||
|
$namelist = $namelist."\nINSERT INTO phpgw_addressbook (owner,".$thisname;
|
||||||
|
$valulist = $valulist."VALUES ('".$phpgw_info["user"]["account_id"]."',".$thisvalu;
|
||||||
|
} elseif ($row==count($lines)-1) {
|
||||||
|
if (!empty($name) && !empty($value)) {
|
||||||
|
$thisname=$name.") ";
|
||||||
|
$thisvalu="'".$value."');";
|
||||||
|
} else {
|
||||||
|
$thisname="";
|
||||||
|
$thisvalu="";
|
||||||
|
}
|
||||||
|
$namelist = $namelist.$thisname;
|
||||||
|
$valulist = $valulist.$thisvalu;
|
||||||
|
} else {
|
||||||
|
if (!empty($name) && !empty($value)) {
|
||||||
|
$thisname=$name.",";
|
||||||
|
$thisvalu="'".$value."',";
|
||||||
|
} else {
|
||||||
|
$thisname=",";
|
||||||
|
$thisvalu=",";
|
||||||
|
}
|
||||||
|
$namelist = $namelist.$thisname;
|
||||||
|
$valulist = $valulist.$thisvalu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $buffer.$namelist.$valulist;
|
||||||
|
}
|
||||||
|
|
||||||
|
function import_new_attrib($buffer,$name,$value) {
|
||||||
|
$value = str_replace("\n","<BR>",$value);
|
||||||
|
$value = str_replace("\r","",$value);
|
||||||
|
if ($value=="") { $value="NULL"; }
|
||||||
|
$this->currentrecord .= $name."%%".$value."##";
|
||||||
|
|
||||||
|
return $buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
// This file defines a set of functions and an associative array.
|
// This file defines a set of functions and an associative array.
|
||||||
// The key of the array corresponds to a header in the source
|
// The key of the array corresponds to a header in the source
|
||||||
// outlook file and the value of the array item will be used in
|
// import file and the value of the array item will be used in
|
||||||
// the creation of the output file.
|
// the creation of the output file.
|
||||||
//
|
//
|
||||||
// An exported Outlook file looks like this:
|
// An exported Outlook file looks like this:
|
||||||
@ -23,143 +23,139 @@
|
|||||||
// Also start with a '#' symbol and a comma separated list will be
|
// Also start with a '#' symbol and a comma separated list will be
|
||||||
// turned into a number of the same entries.
|
// turned into a number of the same entries.
|
||||||
|
|
||||||
class outlook_conv {
|
class import_conv
|
||||||
var $currentrecord; //used for buffering to allow uid lines to go first
|
{
|
||||||
|
var $currentrecord = array(); //used for buffering to allow uid lines to go first
|
||||||
|
|
||||||
var $outlook = array(
|
var $import = array(
|
||||||
"Title" => "title",
|
"Title" => "title",
|
||||||
"First Name" => "n_given",
|
"First Name" => "n_given",
|
||||||
"Middle Name" => "n_middle",
|
"Middle Name" => "n_middle",
|
||||||
"Last Name" => "n_family",
|
"Last Name" => "n_family",
|
||||||
"Suffix" => "n_suffix",
|
"Suffix" => "n_suffix",
|
||||||
"Company" => "org_name", //objectclass: organization
|
"Company" => "org_name", //objectclass: organization
|
||||||
"Department" => "org_unit", //objectclass: organizationalPerson
|
"Department" => "org_unit", //objectclass: organizationalPerson
|
||||||
"Job Title" => "title", //objectclass: organizationalPerson
|
"Job Title" => "title", //objectclass: organizationalPerson
|
||||||
"Business Street" => "address2",
|
"Business Street" => "address2",
|
||||||
"Business Street 2" => "",
|
"Business Street 2" => "",
|
||||||
"Business Street 3" => "",
|
"Business Street 3" => "",
|
||||||
"Business City" => "",
|
"Business City" => "",
|
||||||
"Business State" => "",
|
"Business State" => "",
|
||||||
"Business Postal Code" => "",
|
"Business Postal Code" => "",
|
||||||
"Business Country" => "",
|
"Business Country" => "",
|
||||||
"Home Street" => "adr_street",
|
"Home Street" => "adr_street",
|
||||||
"Home City" => "adr_locality",
|
"Home City" => "adr_locality",
|
||||||
"Home State" => "adr_region",
|
"Home State" => "adr_region",
|
||||||
"Home Postal Code" => "adr_postalcode",
|
"Home Postal Code" => "adr_postalcode",
|
||||||
"Home Country" => "adr_countryname",
|
"Home Country" => "adr_countryname",
|
||||||
"Home Street 2" => "",
|
"Home Street 2" => "",
|
||||||
"Home Street 3" => "",
|
"Home Street 3" => "",
|
||||||
"Other Street" => "",
|
"Other Street" => "",
|
||||||
"Other City" => "",
|
"Other City" => "",
|
||||||
"Other State" => "",
|
"Other State" => "",
|
||||||
"Other Postal Code" => "",
|
"Other Postal Code" => "",
|
||||||
"Other Country" => "",
|
"Other Country" => "",
|
||||||
"Assistant's Phone" => "",
|
"Assistant's Phone" => "",
|
||||||
"Business Fax" => "c_tel",
|
"Business Fax" => "c_tel",
|
||||||
"Business Phone" => "b_tel",
|
"Business Phone" => "b_tel",
|
||||||
"Business Phone 2" => "ophone",
|
"Business Phone 2" => "ophone",
|
||||||
"Callback" => "",
|
"Callback" => "",
|
||||||
"Car Phone" => "",
|
"Car Phone" => "",
|
||||||
"Company Main Phone" => "",
|
"Company Main Phone" => "",
|
||||||
"Home Fax" => "",
|
"Home Fax" => "",
|
||||||
"Home Phone" => "a_tel",
|
"Home Phone" => "a_tel",
|
||||||
"Home Phone 2" => "", //This will make another homePhone entry
|
"Home Phone 2" => "", //This will make another homePhone entry
|
||||||
"ISDN" => "",
|
"ISDN" => "",
|
||||||
"Mobile Phone" => "mphone", //newPilotPerson
|
"Mobile Phone" => "mphone", //newPilotPerson
|
||||||
"Other Fax" => "",
|
"Other Fax" => "",
|
||||||
"Other Phone" => "",
|
"Other Phone" => "",
|
||||||
"Pager" => "pager",
|
"Pager" => "pager",
|
||||||
"Primary Phone" => "",
|
"Primary Phone" => "",
|
||||||
"Radio Phone" => "",
|
"Radio Phone" => "",
|
||||||
"TTY/TDD Phone" => "",
|
"TTY/TDD Phone" => "",
|
||||||
"Telex" => "", //organization
|
"Telex" => "", //organization
|
||||||
"Account" => "",
|
"Account" => "",
|
||||||
"Anniversary" => "",
|
"Anniversary" => "",
|
||||||
"Assistant's Name" => "", //newPilotPerson
|
"Assistant's Name" => "", //newPilotPerson
|
||||||
"Billing Information" => "",
|
"Billing Information" => "",
|
||||||
"Birthday" => "bday",
|
"Birthday" => "bday",
|
||||||
"Categories" => "",
|
"Categories" => "",
|
||||||
"Children" => "",
|
"Children" => "",
|
||||||
"Directory Server" => "",
|
"Directory Server" => "",
|
||||||
"E-mail Address" => "d_email",
|
"E-mail Address" => "d_email",
|
||||||
"E-mail Display Name" => "",
|
"E-mail Display Name" => "",
|
||||||
"E-mail 2 Address" => "",
|
"E-mail 2 Address" => "",
|
||||||
"E-mail 2 Display Name" => "",
|
"E-mail 2 Display Name" => "",
|
||||||
"E-mail 3 Address" => "", //add another...
|
"E-mail 3 Address" => "", //add another...
|
||||||
"E-mail 3 Display Name" => "",
|
"E-mail 3 Display Name" => "",
|
||||||
"Gender" => "",
|
"Gender" => "",
|
||||||
"Government ID Number" => "",
|
"Government ID Number" => "",
|
||||||
"Hobby" => "",
|
"Hobby" => "",
|
||||||
"Initials" => "",
|
"Initials" => "",
|
||||||
"Internet Free Busy" => "",
|
"Internet Free Busy" => "",
|
||||||
"Keywords" => "",
|
"Keywords" => "",
|
||||||
"Language" => "",
|
"Language" => "",
|
||||||
"Location" => "",
|
"Location" => "",
|
||||||
"Manager's Name" => "",
|
"Manager's Name" => "",
|
||||||
"Mileage" => "",
|
"Mileage" => "",
|
||||||
"Notes" => "note",
|
"Notes" => "note",
|
||||||
"Office Location" => "",
|
"Office Location" => "",
|
||||||
"Organizational ID Number" => "",
|
"Organizational ID Number" => "",
|
||||||
"PO Box" => "",
|
"PO Box" => "",
|
||||||
"Priority" => "",
|
"Priority" => "",
|
||||||
"Private Profession" => "",
|
"Private Profession" => "",
|
||||||
"Referred By" => "",
|
"Referred By" => "",
|
||||||
"Sensitivity" => "",
|
"Sensitivity" => "",
|
||||||
"Spouse" => "",
|
"Spouse" => "",
|
||||||
"User 1" => "",
|
"User 1" => "",
|
||||||
"User 2" => "",
|
"User 2" => "",
|
||||||
"User 3" => "",
|
"User 3" => "",
|
||||||
"User 4" => "",
|
"User 4" => "",
|
||||||
"Web Page" => "");
|
"Web Page" => ""
|
||||||
|
);
|
||||||
|
|
||||||
function outlook_start_file($buffer,$j="",$k="") {
|
function import_start_file($buffer,$j="",$k="") {
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function outlook_end_file($buffer) {
|
function import_end_file($buffer) {
|
||||||
global $phpgw,$phpgw_info;
|
global $phpgw,$phpgw_info;
|
||||||
|
|
||||||
$lines = split("\n",$buffer);
|
//$contacts = CreateObject("phpgwapi.contacts");
|
||||||
$contacts = CreateObject("phpgwapi.contacts");
|
echo '<br>';
|
||||||
|
while ( list($name,$value) = each($buffer) ) {
|
||||||
for ($i=0;$i<count($lines);$i++) {
|
echo '<br>'.$name.' => '.$value;
|
||||||
$entry=$lines[$i];
|
$i++;
|
||||||
$contacts->add($phpgw_info["user"]["account_id"],$entry);
|
//$contacts->add($phpgw_info["user"]["account_id"],$entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Successfully imported $i records into your addressbook.";
|
return "Successfully imported $i records into your addressbook.";
|
||||||
}
|
}
|
||||||
|
|
||||||
function outlook_start_record($buffer) {
|
function import_start_record($buffer) {
|
||||||
$top="";
|
$top=array();
|
||||||
|
$this->currentrecord = $top;
|
||||||
|
return $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
$this->currentrecord = $top;
|
function import_end_record($buffer,$private="private") {
|
||||||
return $buffer;
|
global $phpgw_info;
|
||||||
}
|
$namelist=array();
|
||||||
|
while ( list($name, $value) = each($this->currentrecord)) {
|
||||||
|
$namelist = $namelist + array($name => $value);
|
||||||
|
echo '<br>'.$name.' => '.$value;
|
||||||
|
}
|
||||||
|
echo '<br>';
|
||||||
|
$buffer = $buffer + $namelist;
|
||||||
|
return $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
function outlook_end_record($buffer,$private="private") {
|
function import_new_attrib($buffer,$name,$value) {
|
||||||
global $phpgw_info;
|
$value = str_replace("\n","<BR>",$value);
|
||||||
$row=0;
|
$value = str_replace("\r","",$value);
|
||||||
$i=0;
|
$this->currentrecord += array($name => $value);
|
||||||
$lines = split("##",$this->currentrecord);
|
|
||||||
|
|
||||||
for ($i=0;$i<count($lines)-1;$i++) {
|
|
||||||
list($name, $value) = split("%%",$lines[$i]);
|
|
||||||
$row++;
|
|
||||||
$namelist .= array($name => $value);
|
|
||||||
echo $name.' '.$value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $buffer.$namelist;
|
|
||||||
}
|
|
||||||
|
|
||||||
function outlook_new_attrib($buffer,$name,$value) {
|
return $buffer;
|
||||||
$value = str_replace("\n","<BR>",$value);
|
}
|
||||||
$value = str_replace("\r","",$value);
|
}
|
||||||
if ($value=="") { $value="NULL"; }
|
|
||||||
$this->currentrecord .= $name."%%".addslashes($value)."##";
|
|
||||||
|
|
||||||
return $buffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user