Formatting and some adjustment to start making actual imports work again

This commit is contained in:
Miles Lott 2001-03-11 06:58:57 +00:00
parent ed3da58048
commit 3d06057c20
3 changed files with 501 additions and 500 deletions

View File

@ -1,7 +1,7 @@
<?php
// This file defines a set of functions and an associative array.
// 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.
//
// An exported Outlook file looks like this:
@ -23,7 +23,8 @@
// Also start with a '#' symbol and a comma separated list will be
// turned into a number of the same entries.
class outlook_conv {
class import_conv
{
var $basedn;
var $contactsdn;
@ -32,7 +33,7 @@ class outlook_conv {
var $givenName; //this is used in building a cn field
var $currentrecord; //used for buffering to allow uid lines to go first
var $outlook = array(
var $import = array(
"Title" => "",
"First Name" => "givenName",
"Middle Name" => "",
@ -116,9 +117,10 @@ class outlook_conv {
"User 2" => "",
"User 3" => "",
"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.
# If none of these are correct, ldap_add will fail, but at least
# we can give them a fighting chance.
@ -152,21 +154,21 @@ function outlook_start_file($buffer,$basedn="",$context="") {
$this->basedn= $basedn;
$this->contactsdn= $context;
$buffer="";
return $buffer;
}
function outlook_end_file($buffer) {
function import_end_file($buffer) {
return $buffer;
}
function outlook_start_record($buffer) {
function import_start_record($buffer) {
global $phpgw_info;
$top="\nobjectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: outlookPerson";
objectClass: importPerson";
$this->o="";
$this->sn="";
@ -176,7 +178,7 @@ objectClass: outlookPerson";
return $buffer;
}
function outlook_end_record($buffer,$private="") {
function import_end_record($buffer,$private="") {
if (trim($this->sn) != "") {
$this->currentrecord = "cn: ".$this->givenName." ".$this->sn.$this->currentrecord;
} else if (trim($this->o) != "") {
@ -208,7 +210,7 @@ function outlook_end_record($buffer,$private="") {
return $buffer.$this->currentrecord."\n\n";
}
function outlook_new_attrib($buffer,$name,$value) {
function import_new_attrib($buffer,$name,$value) {
if ($name == "sn") {
$this->sn = $value;
}
@ -246,7 +248,7 @@ function outlook_new_attrib($buffer,$name,$value) {
$this->currentrecord .= "\n$name: $value";
}
return $buffer;
}
} // end switch
}
}
?>

View File

@ -1,7 +1,7 @@
<?php
// This file defines a set of functions and an associative array.
// 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.
//
// An exported Outlook file looks like this:
@ -23,10 +23,11 @@
// Also start with a '#' symbol and a comma separated list will be
// 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 $outlook = array(
var $import = array(
"Title" => "title",
"First Name" => "n_given",
"Middle Name" => "n_middle",
@ -97,7 +98,7 @@ class outlook_conv {
"Location" => "",
"Manager's Name" => "",
"Mileage" => "",
"Notes" => "ab_notes",
"Notes" => "note",
"Office Location" => "",
"Organizational ID Number" => "",
"PO Box" => "postOfficeBox",
@ -110,24 +111,26 @@ class outlook_conv {
"User 2" => "",
"User 3" => "",
"User 4" => "",
"Web Page" => "");
"Web Page" => ""
);
function outlook_start_file($buffer,$j="",$k="") {
function import_start_file($buffer,$j="",$k="") {
$buffer="";
return $buffer;
}
function outlook_end_file($buffer) {
function import_end_file($buffer) {
return $buffer;
}
function outlook_start_record($buffer) {
function import_start_record($buffer) {
$top="";
$this->currentrecord = $top;
return $buffer;
}
function outlook_end_record($buffer,$private="private") {
function import_end_record($buffer,$private="private") {
global $phpgw_info;
$row=0;
$i=0;
@ -178,7 +181,7 @@ function outlook_end_record($buffer,$private="private") {
return $buffer.$namelist.$valulist;
}
function outlook_new_attrib($buffer,$name,$value) {
function import_new_attrib($buffer,$name,$value) {
$value = str_replace("\n","<BR>",$value);
$value = str_replace("\r","",$value);
if ($value=="") { $value="NULL"; }

View File

@ -1,7 +1,7 @@
<?php
// This file defines a set of functions and an associative array.
// 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.
//
// An exported Outlook file looks like this:
@ -23,10 +23,11 @@
// Also start with a '#' symbol and a comma separated list will be
// turned into a number of the same entries.
class outlook_conv {
var $currentrecord; //used for buffering to allow uid lines to go first
class import_conv
{
var $currentrecord = array(); //used for buffering to allow uid lines to go first
var $outlook = array(
var $import = array(
"Title" => "title",
"First Name" => "n_given",
"Middle Name" => "n_middle",
@ -110,54 +111,49 @@ class outlook_conv {
"User 2" => "",
"User 3" => "",
"User 4" => "",
"Web Page" => "");
"Web Page" => ""
);
function outlook_start_file($buffer,$j="",$k="") {
function import_start_file($buffer,$j="",$k="") {
return $buffer;
}
function outlook_end_file($buffer) {
function import_end_file($buffer) {
global $phpgw,$phpgw_info;
$lines = split("\n",$buffer);
$contacts = CreateObject("phpgwapi.contacts");
for ($i=0;$i<count($lines);$i++) {
$entry=$lines[$i];
$contacts->add($phpgw_info["user"]["account_id"],$entry);
//$contacts = CreateObject("phpgwapi.contacts");
echo '<br>';
while ( list($name,$value) = each($buffer) ) {
echo '<br>'.$name.' => '.$value;
$i++;
//$contacts->add($phpgw_info["user"]["account_id"],$entry);
}
return "Successfully imported $i records into your addressbook.";
}
function outlook_start_record($buffer) {
$top="";
function import_start_record($buffer) {
$top=array();
$this->currentrecord = $top;
return $buffer;
}
function outlook_end_record($buffer,$private="private") {
function import_end_record($buffer,$private="private") {
global $phpgw_info;
$row=0;
$i=0;
$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;
$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;
}
return $buffer.$namelist;
}
function outlook_new_attrib($buffer,$name,$value) {
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."%%".addslashes($value)."##";
$this->currentrecord += array($name => $value);
return $buffer;
}