mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 09:05:16 +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,7 +23,8 @@
|
|||||||
// 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 $basedn;
|
||||||
var $contactsdn;
|
var $contactsdn;
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ class outlook_conv {
|
|||||||
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" => "",
|
||||||
@ -116,9 +117,10 @@ class outlook_conv {
|
|||||||
"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.
|
||||||
@ -152,21 +154,21 @@ function outlook_start_file($buffer,$basedn="",$context="") {
|
|||||||
|
|
||||||
$this->basedn= $basedn;
|
$this->basedn= $basedn;
|
||||||
$this->contactsdn= $context;
|
$this->contactsdn= $context;
|
||||||
|
$buffer="";
|
||||||
return $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) {
|
||||||
global $phpgw_info;
|
global $phpgw_info;
|
||||||
|
|
||||||
$top="\nobjectClass: person
|
$top="\nobjectClass: person
|
||||||
objectClass: organizationalPerson
|
objectClass: organizationalPerson
|
||||||
objectClass: inetOrgPerson
|
objectClass: inetOrgPerson
|
||||||
objectClass: outlookPerson";
|
objectClass: importPerson";
|
||||||
|
|
||||||
$this->o="";
|
$this->o="";
|
||||||
$this->sn="";
|
$this->sn="";
|
||||||
@ -174,9 +176,9 @@ objectClass: outlookPerson";
|
|||||||
|
|
||||||
$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) != "") {
|
||||||
@ -206,9 +208,9 @@ function outlook_end_record($buffer,$private="") {
|
|||||||
$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;
|
||||||
}
|
}
|
||||||
@ -246,7 +248,7 @@ function outlook_new_attrib($buffer,$name,$value) {
|
|||||||
$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,10 +23,11 @@
|
|||||||
// 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",
|
||||||
@ -97,7 +98,7 @@ class outlook_conv {
|
|||||||
"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",
|
||||||
@ -110,24 +111,26 @@ class outlook_conv {
|
|||||||
"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="") {
|
||||||
|
$buffer="";
|
||||||
return $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;
|
||||||
@ -176,15 +179,15 @@ function outlook_end_record($buffer,$private="private") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $buffer.$namelist.$valulist;
|
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("\n","<BR>",$value);
|
||||||
$value = str_replace("\r","",$value);
|
$value = str_replace("\r","",$value);
|
||||||
if ($value=="") { $value="NULL"; }
|
if ($value=="") { $value="NULL"; }
|
||||||
$this->currentrecord .= $name."%%".$value."##";
|
$this->currentrecord .= $name."%%".$value."##";
|
||||||
|
|
||||||
return $buffer;
|
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,10 +23,11 @@
|
|||||||
// 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",
|
||||||
@ -110,56 +111,51 @@ class outlook_conv {
|
|||||||
"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) {
|
|
||||||
$top="";
|
|
||||||
|
|
||||||
$this->currentrecord = $top;
|
|
||||||
return $buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
function outlook_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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $buffer.$namelist;
|
function import_start_record($buffer) {
|
||||||
}
|
$top=array();
|
||||||
|
$this->currentrecord = $top;
|
||||||
|
return $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
function outlook_new_attrib($buffer,$name,$value) {
|
function import_end_record($buffer,$private="private") {
|
||||||
|
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 import_new_attrib($buffer,$name,$value) {
|
||||||
$value = str_replace("\n","<BR>",$value);
|
$value = str_replace("\n","<BR>",$value);
|
||||||
$value = str_replace("\r","",$value);
|
$value = str_replace("\r","",$value);
|
||||||
if ($value=="") { $value="NULL"; }
|
$this->currentrecord += array($name => $value);
|
||||||
$this->currentrecord .= $name."%%".addslashes($value)."##";
|
|
||||||
|
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user