mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 07:09:20 +01:00
Move import files to new import subdir
This commit is contained in:
parent
a7ef1f4775
commit
b04931911d
@ -35,11 +35,11 @@
|
||||
$t = new Template($phpgw_info["server"]["app_tpl"]);
|
||||
$t->set_file(array("import" => "import.tpl"));
|
||||
|
||||
$dir_handle=opendir($phpgw_info["server"]["app_root"].$sep."conv");
|
||||
$dir_handle=opendir($phpgw_info["server"]["app_root"].$sep."import");
|
||||
$i=0; $myfilearray="";
|
||||
while ($file = readdir($dir_handle)) {
|
||||
//echo "<!-- ".is_file($phpgw_info["server"]["app_root"].$sep."conv".$sep.$file)." -->";
|
||||
if ((substr($file, 0, 1) != ".") && is_file($phpgw_info["server"]["app_root"].$sep."conv".$sep.$file) ) {
|
||||
//echo "<!-- ".is_file($phpgw_info["server"]["app_root"].$sep."import".$sep.$file)." -->";
|
||||
if ((substr($file, 0, 1) != ".") && is_file($phpgw_info["server"]["app_root"].$sep."import".$sep.$file) ) {
|
||||
$myfilearray[$i] = $file;
|
||||
$i++;
|
||||
}
|
||||
@ -68,7 +68,7 @@
|
||||
$t->pparse("out","import");
|
||||
$phpgw->common->phpgw_footer();
|
||||
} else {
|
||||
include ($phpgw_info["server"]["app_root"].$sep."conv".$sep.$conv_type);
|
||||
include ($phpgw_info["server"]["app_root"].$sep."import".$sep.$conv_type);
|
||||
|
||||
if ($private=="") { $private="public"; }
|
||||
$row=0;
|
||||
@ -76,7 +76,7 @@
|
||||
$o = new import_conv;
|
||||
$buffer = $o->import_start_file($buffer,$basedn,$context);
|
||||
$fp=fopen($tsvfile,"r");
|
||||
if ($o->type != 'ldif') {
|
||||
if ($o->type == 'csv') {
|
||||
while ($data = fgetcsv($fp,8000,",")) {
|
||||
$num = count($data);
|
||||
$row++;
|
||||
|
197
addressbook/import/Debug_Netscape_to_LDAP
Normal file
197
addressbook/import/Debug_Netscape_to_LDAP
Normal file
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
// This file defines a set of functions and an associative array.
|
||||
// The key of the array corresponds to a header in the source
|
||||
// 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:
|
||||
//
|
||||
// Title<tab>First Name<tab>Middle Name<tab>Last Name<tab>...
|
||||
// <tab>Patrick<tab><tab>Walsh<tab>...
|
||||
//
|
||||
// Where the first line explains each optional field. This is what
|
||||
// will be looked up in the key.
|
||||
//
|
||||
// The array need not be in any order and any fields not defined will
|
||||
// not be transferred. If the val='+', the value will be appended to
|
||||
// the previous field and any text after the '+' will be appended
|
||||
// before the value. For example, the following would add a comma and
|
||||
// a space between LastName and FirstName and store it in FullName:
|
||||
//
|
||||
// array("LastName" => "FullName","FirstName" => "+, ");
|
||||
//
|
||||
// Also start with a '#' symbol and a comma separated list will be
|
||||
// turned into a number of the same entries.
|
||||
|
||||
class import_conv
|
||||
{
|
||||
var $basedn;
|
||||
var $contactsdn;
|
||||
|
||||
var $sn; //these two vars will be used in
|
||||
var $o; //building a dn field.
|
||||
var $givenName; //this is used in building a cn field
|
||||
var $currentrecord; //used for buffering to allow uid lines to go first
|
||||
var $type = 'ldif';
|
||||
|
||||
var $import = array(
|
||||
"title" => "title",
|
||||
"givenname" => "givenname",
|
||||
"sn" => "sn",
|
||||
"cn" => "cn",
|
||||
"o" => "o",
|
||||
"ou" => "ou",
|
||||
"streetaddress" => "streetaddress",
|
||||
"locality" => "locality",
|
||||
"st" => "st",
|
||||
"postalcode" => "postalcode",
|
||||
"countryname" => "countryname",
|
||||
"telephonenumber" => "telephonenumber",
|
||||
"homephone" => "homephone",
|
||||
"facsimiletelephonenumber" => "facsimiletelephonenumber",
|
||||
"xmozillaanyphone" => "xmozillaanyphone",
|
||||
"cellphone" => "cellphone",
|
||||
"description" => "description",
|
||||
"pagerphone" => "pagerphone",
|
||||
"mail" => "mail",
|
||||
"homeurl" => "homeurl",
|
||||
"xmozillauseconferenceserver" => "xmozillauseconferenceserver",
|
||||
"xmozillanickname" => "xmozillanickname",
|
||||
"xmozillausehtmlmail" => "xmozillausehtmlmail",
|
||||
"modifytimestamp" => "modifytimestamp",
|
||||
"objectclass" => "objectclass"
|
||||
);
|
||||
|
||||
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.
|
||||
if (!empty($basedn) && empty($context)) {
|
||||
# Oops, no context, try a default
|
||||
$context = "ou=Contacts,".$basedn;
|
||||
} elseif (empty($basedn) && !empty($context)) {
|
||||
# Oops, no basedn, try this one
|
||||
$work = split(",",$context);
|
||||
array_shift($work);
|
||||
for ($i=0;$i<count($work);$i++) {
|
||||
if($i==0) {
|
||||
$basedn = $work[$i];
|
||||
} else {
|
||||
$basedn = $basedn.$work[$i];
|
||||
}
|
||||
}
|
||||
} elseif(empty($basedn) && empty($context)) {
|
||||
# Wow, create both from known info
|
||||
$work = split(",",$phpgw_info["server"]["ldap_context"]);
|
||||
array_shift($work);
|
||||
for ($i=0;$i<count($work);$i++) {
|
||||
if($i==0) {
|
||||
$basedn = $work[$i];
|
||||
} else {
|
||||
$basedn = $basedn.",".$work[$i];
|
||||
}
|
||||
}
|
||||
$context = "ou=Contacts,".$basedn;
|
||||
}
|
||||
|
||||
$this->basedn= $basedn;
|
||||
$this->contactsdn= $context;
|
||||
$buffer="";
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_file($buffer) {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_start_record($buffer) {
|
||||
global $phpgw_info;
|
||||
|
||||
$top="\nobjectClass: person
|
||||
objectClass: organizationalPerson
|
||||
objectClass: inetOrgPerson
|
||||
objectClass: importPerson";
|
||||
|
||||
$this->o="";
|
||||
$this->sn="";
|
||||
$this->givenName="";
|
||||
|
||||
$this->currentrecord = $top;
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_record($buffer,$private="") {
|
||||
if (trim($this->sn) != "") {
|
||||
$this->currentrecord = "cn: ".$this->givenName." ".$this->sn.$this->currentrecord;
|
||||
} else if (trim($this->o) != "") {
|
||||
$this->currentrecord = "cn: ".$this->o.$this->currentrecord;
|
||||
} else if (trim($this->givenName)) {
|
||||
$this->currentrecord = "cn: ".$this->givenName.$this->currentrecord;
|
||||
} else {
|
||||
$this->currentrecord = "cn: (unnamed)".$this->currentrecord;
|
||||
}
|
||||
|
||||
$time = gettimeofday();
|
||||
$uid = ($this->sn?$this->sn:$this->o);
|
||||
if (strpos($uid, ",")) {
|
||||
$uid = str_replace(",", "\,", $uid);
|
||||
$uid = "\"".$uid."\"";
|
||||
}
|
||||
$uid = time().$time["usec"].":".$uid;
|
||||
$this->currentrecord = "dn: uid=$uid,".$this->contactsdn."\nuid: $uid"."\n".$this->currentrecord;
|
||||
|
||||
while ($pos = strpos($this->currentrecord, "|br x=y/|")) {
|
||||
$startline = strrpos(substr($this->currentrecord,0,$pos), "\n");
|
||||
if ($startline == "") {$startline = 0;}
|
||||
$startattrib = strpos($this->currentrecord, ":", $startline) + 1;
|
||||
$endline = strpos($this->currentrecord, "\n", $startattrib);
|
||||
if ($endline == "") { $endline = strlen($this->currentrecord); }
|
||||
$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);
|
||||
}
|
||||
return $buffer.$this->currentrecord."\n\n";
|
||||
}
|
||||
|
||||
function import_new_attrib($buffer,$name,$value) {
|
||||
if ($name == "sn") {
|
||||
$this->sn = $value;
|
||||
}
|
||||
if ($name == "o") {
|
||||
$this->o = $value;
|
||||
}
|
||||
if ($name == "givenName") {
|
||||
$this->givenName = $value;
|
||||
}
|
||||
|
||||
$value = trim($value);
|
||||
$value = str_replace("\n","",$value);
|
||||
$name = str_replace("\n","",$name);
|
||||
$value = str_replace("\r","",$value);
|
||||
$name = str_replace("\r","",$name);
|
||||
|
||||
switch (substr($name,0,1)) {
|
||||
case '+':
|
||||
$this->currentrecord .= substr($name,1).$value;
|
||||
return $buffer;
|
||||
break;
|
||||
case '#':
|
||||
$data = explode(";",$value);
|
||||
$num = count($data);
|
||||
$return = "";
|
||||
for ( $i=0; $i<$num; $i++ ) {
|
||||
$return .= "\n".substr($name,1).": $data[$i]";
|
||||
}
|
||||
$this->currentrecord .= $return;
|
||||
return $buffer;
|
||||
break;
|
||||
default:
|
||||
if ($name == "otherMailbox") {
|
||||
$this->currentrecord .= "\n$name: smtp\$$value";
|
||||
} else {
|
||||
$this->currentrecord .= "\n$name: $value";
|
||||
}
|
||||
return $buffer;
|
||||
} // end switch
|
||||
}
|
||||
}
|
||||
?>
|
136
addressbook/import/Debug_Netscape_to_SQL
Normal file
136
addressbook/import/Debug_Netscape_to_SQL
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
// This file defines a set of functions and an associative array.
|
||||
// The key of the array corresponds to a header in the source
|
||||
// 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:
|
||||
//
|
||||
// Title<tab>First Name<tab>Middle Name<tab>Last Name<tab>...
|
||||
// <tab>Patrick<tab><tab>Walsh<tab>...
|
||||
//
|
||||
// Where the first line explains each optional field. This is what
|
||||
// will be looked up in the key.
|
||||
//
|
||||
// The array need not be in any order and any fields not defined will
|
||||
// not be transferred. If the val='+', the value will be appended to
|
||||
// the previous field and any text after the '+' will be appended
|
||||
// before the value. For example, the following would add a comma and
|
||||
// a space between LastName and FirstName and store it in FullName:
|
||||
//
|
||||
// array("LastName" => "FullName","FirstName" => "+, ");
|
||||
//
|
||||
// Also start with a '#' symbol and a comma separated list will be
|
||||
// turned into a number of the same entries.
|
||||
|
||||
class import_conv
|
||||
{
|
||||
var $currentrecord; //used for buffering to allow uid lines to go first
|
||||
var $type = 'ldif';
|
||||
|
||||
var $import = array(
|
||||
"title" => "title",
|
||||
"givenname" => "n_given",
|
||||
"sn" => "n_family",
|
||||
"cn" => "fn",
|
||||
"o" => "org_name",
|
||||
"ou" => "org_unit",
|
||||
"streetaddress" => "adr_one_street",
|
||||
"locality" => "adr_one_locality",
|
||||
"st" => "adr_one_region",
|
||||
"postalcode" => "adr_one_postalcode",
|
||||
"countryname" => "adr_one_countryname",
|
||||
"telephonenumber" => "tel_work",
|
||||
"homephone" => "tel_home",
|
||||
"facsimiletelephonenumber" => "tel_fax",
|
||||
"xmozillaanyphone" => "tel_msg",
|
||||
"cellphone" => "tel_cell",
|
||||
"description" => "note",
|
||||
"pagerphone" => "tel_pager",
|
||||
"mail" => "email",
|
||||
"homeurl" => "url",
|
||||
"xmozillauseconferenceserver" => "",
|
||||
"xmozillanickname" => "",
|
||||
"xmozillausehtmlmail" => "",
|
||||
"modifytimestamp" => "",
|
||||
"objectclass" => ""
|
||||
);
|
||||
|
||||
function import_start_file($buffer,$j="",$k="") {
|
||||
$buffer="";
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_file($buffer) {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_start_record($buffer) {
|
||||
$top="";
|
||||
|
||||
$this->currentrecord = $top;
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_record($buffer,$private="private") {
|
||||
global $phpgw_info;
|
||||
$row=0;
|
||||
$i=0;
|
||||
$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 import_new_attrib($buffer,$name,$value) {
|
||||
$value = trim($value);
|
||||
$value = str_replace("\n","",$value);
|
||||
$value = str_replace("\r","",$value);
|
||||
if ($value=="") { $value="NULL"; }
|
||||
$this->currentrecord .= $name."%%".$value."##";
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
?>
|
255
addressbook/import/Debug_Outlook_to_LDAP
Normal file
255
addressbook/import/Debug_Outlook_to_LDAP
Normal file
@ -0,0 +1,255 @@
|
||||
<?php
|
||||
// This file defines a set of functions and an associative array.
|
||||
// The key of the array corresponds to a header in the source
|
||||
// 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:
|
||||
//
|
||||
// Title<tab>First Name<tab>Middle Name<tab>Last Name<tab>...
|
||||
// <tab>Patrick<tab><tab>Walsh<tab>...
|
||||
//
|
||||
// Where the first line explains each optional field. This is what
|
||||
// will be looked up in the key.
|
||||
//
|
||||
// The array need not be in any order and any fields not defined will
|
||||
// not be transferred. If the val='+', the value will be appended to
|
||||
// the previous field and any text after the '+' will be appended
|
||||
// before the value. For example, the following would add a comma and
|
||||
// a space between LastName and FirstName and store it in FullName:
|
||||
//
|
||||
// array("LastName" => "FullName","FirstName" => "+, ");
|
||||
//
|
||||
// Also start with a '#' symbol and a comma separated list will be
|
||||
// turned into a number of the same entries.
|
||||
|
||||
class import_conv
|
||||
{
|
||||
var $type = '';
|
||||
var $basedn;
|
||||
var $contactsdn;
|
||||
|
||||
var $sn; //these two vars will be used in
|
||||
var $o; //building a dn field.
|
||||
var $givenName; //this is used in building a cn field
|
||||
var $currentrecord; //used for buffering to allow uid lines to go first
|
||||
|
||||
var $import = array(
|
||||
"Title" => "",
|
||||
"First Name" => "givenName",
|
||||
"Middle Name" => "",
|
||||
"Last Name" => "sn",
|
||||
"Suffix" => "",
|
||||
"Company" => "o", //objectclass: organization
|
||||
"Department" => "ou", //objectclass: organizationalPerson
|
||||
"Job Title" => "title", //objectclass: organizationalPerson
|
||||
"Business Street" => "postalAddress",
|
||||
"Business Street 2" => "",
|
||||
"Business Street 3" => "",
|
||||
"Business City" => "l",
|
||||
"Business State" => "st",
|
||||
"Business Postal Code" => "postalCode",
|
||||
"Business Country" => "co",
|
||||
"Home Street" => "homePostalAddress",
|
||||
"Home City" => "+\n",
|
||||
"Home State" => "+, ",
|
||||
"Home Postal Code" => "+ ",
|
||||
"Home Country" => "+\n",
|
||||
"Home Street 2" => "",
|
||||
"Home Street 3" => "",
|
||||
"Other Street" => "",
|
||||
"Other City" => "+\n",
|
||||
"Other State" => "+, ",
|
||||
"Other Postal Code" => "+ ",
|
||||
"Other Country" => "+\n",
|
||||
"Assistant's Phone" => "",
|
||||
"Business Fax" => "facsimileTelephoneNumber",
|
||||
"Business Phone" => "telephoneNumber",
|
||||
"Business Phone 2" => "",
|
||||
"Callback" => "",
|
||||
"Car Phone" => "",
|
||||
"Company Main Phone" => "",
|
||||
"Home Fax" => "",
|
||||
"Home Phone" => "homePhone",
|
||||
"Home Phone 2" => "homePhone", //This will make another homePhone entry
|
||||
"ISDN" => "",
|
||||
"Mobile Phone" => "mobile", //newPilotPerson
|
||||
"Other Fax" => "",
|
||||
"Other Phone" => "",
|
||||
"Pager" => "pager",
|
||||
"Primary Phone" => "",
|
||||
"Radio Phone" => "",
|
||||
"TTY/TDD Phone" => "",
|
||||
"Telex" => "telexNumber", //organization
|
||||
"Account" => "",
|
||||
"Anniversary" => "",
|
||||
"Assistant's Name" => "secretary", //newPilotPerson
|
||||
"Billing Information" => "",
|
||||
"Birthday" => "",
|
||||
"Categories" => "#businessCategory",
|
||||
"Children" => "",
|
||||
"Directory Server" => "",
|
||||
"E-mail Address" => "mail",
|
||||
"E-mail Display Name" => "",
|
||||
"E-mail 2 Address" => "otherMailbox",
|
||||
"E-mail 2 Display Name" => "",
|
||||
"E-mail 3 Address" => "otherMailbox", //add another...
|
||||
"E-mail 3 Display Name" => "",
|
||||
"Gender" => "",
|
||||
"Government ID Number" => "",
|
||||
"Hobby" => "",
|
||||
"Initials" => "",
|
||||
"Internet Free Busy" => "",
|
||||
"Keywords" => "",
|
||||
"Language" => "",
|
||||
"Location" => "",
|
||||
"Manager's Name" => "",
|
||||
"Mileage" => "",
|
||||
"Notes" => "comment",
|
||||
"Office Location" => "physicalDeliveryOfficeName",
|
||||
"Organizational ID Number" => "",
|
||||
"PO Box" => "postOfficeBox",
|
||||
"Priority" => "",
|
||||
"Private Profession" => "",
|
||||
"Referred By" => "",
|
||||
"Sensitivity" => "",
|
||||
"Spouse" => "",
|
||||
"User 1" => "",
|
||||
"User 2" => "",
|
||||
"User 3" => "",
|
||||
"User 4" => "",
|
||||
"Web Page" => ""
|
||||
);
|
||||
|
||||
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.
|
||||
if (!empty($basedn) && empty($context)) {
|
||||
# Oops, no context, try a default
|
||||
$context = "ou=Contacts,".$basedn;
|
||||
} elseif (empty($basedn) && !empty($context)) {
|
||||
# Oops, no basedn, try this one
|
||||
$work = split(",",$context);
|
||||
array_shift($work);
|
||||
for ($i=0;$i<count($work);$i++) {
|
||||
if($i==0) {
|
||||
$basedn = $work[$i];
|
||||
} else {
|
||||
$basedn = $basedn.$work[$i];
|
||||
}
|
||||
}
|
||||
} elseif(empty($basedn) && empty($context)) {
|
||||
# Wow, create both from known info
|
||||
$work = split(",",$phpgw_info["server"]["ldap_context"]);
|
||||
array_shift($work);
|
||||
for ($i=0;$i<count($work);$i++) {
|
||||
if($i==0) {
|
||||
$basedn = $work[$i];
|
||||
} else {
|
||||
$basedn = $basedn.",".$work[$i];
|
||||
}
|
||||
}
|
||||
$context = "ou=Contacts,".$basedn;
|
||||
}
|
||||
|
||||
$this->basedn= $basedn;
|
||||
$this->contactsdn= $context;
|
||||
$buffer="";
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_file($buffer) {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_start_record($buffer) {
|
||||
global $phpgw_info;
|
||||
|
||||
$top="\nobjectClass: person
|
||||
objectClass: organizationalPerson
|
||||
objectClass: inetOrgPerson
|
||||
objectClass: importPerson";
|
||||
|
||||
$this->o="";
|
||||
$this->sn="";
|
||||
$this->givenName="";
|
||||
|
||||
$this->currentrecord = $top;
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_record($buffer,$private="") {
|
||||
if (trim($this->sn) != "") {
|
||||
$this->currentrecord = "cn: ".$this->givenName." ".$this->sn.$this->currentrecord;
|
||||
} else if (trim($this->o) != "") {
|
||||
$this->currentrecord = "cn: ".$this->o.$this->currentrecord;
|
||||
} else if (trim($this->givenName)) {
|
||||
$this->currentrecord = "cn: ".$this->givenName.$this->currentrecord;
|
||||
} else {
|
||||
$this->currentrecord = "cn: (unnamed)".$this->currentrecord;
|
||||
}
|
||||
|
||||
$time = gettimeofday();
|
||||
$uid = ($this->sn?$this->sn:$this->o);
|
||||
if (strpos($uid, ",")) {
|
||||
$uid = str_replace(",", "\,", $uid);
|
||||
$uid = "\"".$uid."\"";
|
||||
}
|
||||
$uid = time().$time["usec"].":".$uid;
|
||||
$this->currentrecord = "dn: uid=$uid,".$this->contactsdn."\nuid: $uid"."\n".$this->currentrecord;
|
||||
|
||||
while ($pos = strpos($this->currentrecord, "|br x=y/|")) {
|
||||
$startline = strrpos(substr($this->currentrecord,0,$pos), "\n");
|
||||
if ($startline == "") {$startline = 0;}
|
||||
$startattrib = strpos($this->currentrecord, ":", $startline) + 1;
|
||||
$endline = strpos($this->currentrecord, "\n", $startattrib);
|
||||
if ($endline == "") { $endline = strlen($this->currentrecord); }
|
||||
$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);
|
||||
}
|
||||
return $buffer.$this->currentrecord."\n\n";
|
||||
}
|
||||
|
||||
function import_new_attrib($buffer,$name,$value) {
|
||||
if ($name == "sn") {
|
||||
$this->sn = $value;
|
||||
}
|
||||
if ($name == "o") {
|
||||
$this->o = $value;
|
||||
}
|
||||
if ($name == "givenName") {
|
||||
$this->givenName = $value;
|
||||
}
|
||||
|
||||
$value = str_replace("\n","|br x=y/|",$value);
|
||||
$name = str_replace("\n","|br x=y/|",$name);
|
||||
$value = str_replace("\r","",$value);
|
||||
$name = str_replace("\r","",$name);
|
||||
|
||||
switch (substr($name,0,1)) {
|
||||
case '+':
|
||||
$this->currentrecord .= substr($name,1).$value;
|
||||
return $buffer;
|
||||
break;
|
||||
case '#':
|
||||
$data = explode(";",$value);
|
||||
$num = count($data);
|
||||
$return = "";
|
||||
for ( $i=0; $i<$num; $i++ ) {
|
||||
$return .= "\n".substr($name,1).": $data[$i]";
|
||||
}
|
||||
$this->currentrecord .= $return;
|
||||
return $buffer;
|
||||
break;
|
||||
default:
|
||||
if ($name == "otherMailbox") {
|
||||
$this->currentrecord .= "\n$name: smtp\$$value";
|
||||
} else {
|
||||
$this->currentrecord .= "\n$name: $value";
|
||||
}
|
||||
return $buffer;
|
||||
} // end switch
|
||||
}
|
||||
}
|
||||
?>
|
194
addressbook/import/Debug_Outlook_to_SQL
Normal file
194
addressbook/import/Debug_Outlook_to_SQL
Normal file
@ -0,0 +1,194 @@
|
||||
<?php
|
||||
// This file defines a set of functions and an associative array.
|
||||
// The key of the array corresponds to a header in the source
|
||||
// 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:
|
||||
//
|
||||
// Title<tab>First Name<tab>Middle Name<tab>Last Name<tab>...
|
||||
// <tab>Patrick<tab><tab>Walsh<tab>...
|
||||
//
|
||||
// Where the first line explains each optional field. This is what
|
||||
// will be looked up in the key.
|
||||
//
|
||||
// The array need not be in any order and any fields not defined will
|
||||
// not be transferred. If the val='+', the value will be appended to
|
||||
// the previous field and any text after the '+' will be appended
|
||||
// before the value. For example, the following would add a comma and
|
||||
// a space between LastName and FirstName and store it in FullName:
|
||||
//
|
||||
// array("LastName" => "FullName","FirstName" => "+, ");
|
||||
//
|
||||
// Also start with a '#' symbol and a comma separated list will be
|
||||
// turned into a number of the same entries.
|
||||
|
||||
class import_conv
|
||||
{
|
||||
var $type = '';
|
||||
var $currentrecord; //used for buffering to allow uid lines to go first
|
||||
|
||||
var $import = array(
|
||||
"Title" => "title",
|
||||
"First Name" => "n_given",
|
||||
"Middle Name" => "n_middle",
|
||||
"Last Name" => "n_family",
|
||||
"Suffix" => "n_suffix",
|
||||
"Company" => "org_name", //objectclass: organization
|
||||
"Department" => "org_unit", //objectclass: organizationalPerson
|
||||
"Job Title" => "title", //objectclass: organizationalPerson
|
||||
"Business Street" => "adr_one_street",
|
||||
"Business Street 2" => "address2",
|
||||
"Business Street 3" => "address3",
|
||||
"Business City" => "adr_one_locality",
|
||||
"Business State" => "adr_one_region",
|
||||
"Business Postal Code" => "adr_one_postalcode",
|
||||
"Business Country" => "adr_one_countryname",
|
||||
"Home Street" => "adr_two_street",
|
||||
"Home City" => "adr_two_locality",
|
||||
"Home State" => "adr_two_region",
|
||||
"Home Postal Code" => "adr_two_postalcode",
|
||||
"Home Country" => "adr_two_countryname",
|
||||
"Home Street 2" => "",
|
||||
"Home Street 3" => "",
|
||||
"Other Street" => "",
|
||||
"Other City" => "",
|
||||
"Other State" => "",
|
||||
"Other Postal Code" => "",
|
||||
"Other Country" => "",
|
||||
"Assistant's Phone" => "tel_msg",
|
||||
"Business Fax" => "tel_fax",
|
||||
"Business Phone" => "tel_work",
|
||||
"Business Phone 2" => "ophone",
|
||||
"Callback" => "",
|
||||
"Car Phone" => "tel_car",
|
||||
"Company Main Phone" => "",
|
||||
"Home Fax" => "",
|
||||
"Home Phone" => "tel_home",
|
||||
"Home Phone 2" => "", //This will make another homePhone entry
|
||||
"ISDN" => "tel_isdn",
|
||||
"Mobile Phone" => "tel_cell", //newPilotPerson
|
||||
"Other Fax" => "",
|
||||
"Other Phone" => "",
|
||||
"Pager" => "pager",
|
||||
"Primary Phone" => "",
|
||||
"Radio Phone" => "",
|
||||
"TTY/TDD Phone" => "",
|
||||
"Telex" => "", //organization
|
||||
"Account" => "",
|
||||
"Anniversary" => "",
|
||||
"Assistant's Name" => "", //newPilotPerson
|
||||
"Billing Information" => "",
|
||||
"Birthday" => "bday",
|
||||
"Categories" => "",
|
||||
"Children" => "",
|
||||
"Directory Server" => "",
|
||||
"E-mail Address" => "email",
|
||||
"E-mail Display Name" => "",
|
||||
"E-mail 2 Address" => "email_home",
|
||||
"E-mail 2 Display Name" => "",
|
||||
"E-mail 3 Address" => "", //add another...
|
||||
"E-mail 3 Display Name" => "",
|
||||
"Gender" => "",
|
||||
"Government ID Number" => "",
|
||||
"Hobby" => "",
|
||||
"Initials" => "",
|
||||
"Internet Free Busy" => "",
|
||||
"Keywords" => "",
|
||||
"Language" => "",
|
||||
"Location" => "",
|
||||
"Manager's Name" => "",
|
||||
"Mileage" => "",
|
||||
"Notes" => "note",
|
||||
"Office Location" => "",
|
||||
"Organizational ID Number" => "",
|
||||
"PO Box" => "",
|
||||
"Priority" => "",
|
||||
"Private Profession" => "",
|
||||
"Referred By" => "",
|
||||
"Sensitivity" => "",
|
||||
"Spouse" => "",
|
||||
"User 1" => "",
|
||||
"User 2" => "",
|
||||
"User 3" => "",
|
||||
"User 4" => "",
|
||||
"Web Page" => ""
|
||||
);
|
||||
|
||||
function import_start_file($buffer,$j="",$k="") {
|
||||
$buffer="";
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_file($buffer) {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_start_record($buffer) {
|
||||
$top="";
|
||||
|
||||
$this->currentrecord = $top;
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_record($buffer,$private="private") {
|
||||
global $phpgw_info;
|
||||
$row=0;
|
||||
$i=0;
|
||||
$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 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;
|
||||
}
|
||||
}
|
||||
?>
|
104
addressbook/import/Import_from_Netscape
Normal file
104
addressbook/import/Import_from_Netscape
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
// This file defines a set of functions and an associative array.
|
||||
// The key of the array corresponds to a header in the source
|
||||
// import file and the value of the array item will be used in
|
||||
// the creation of the output file.
|
||||
//
|
||||
// The array need not be in any order and any fields not defined will
|
||||
// not be transferred. If the val='+', the value will be appended to
|
||||
// the previous field and any text after the '+' will be appended
|
||||
// before the value. For example, the following would add a comma and
|
||||
// a space between LastName and FirstName and store it in FullName:
|
||||
//
|
||||
// array("LastName" => "FullName","FirstName" => "+, ");
|
||||
//
|
||||
// Also start with a '#' symbol and a comma separated list will be
|
||||
// turned into a number of the same entries.
|
||||
|
||||
class import_conv
|
||||
{
|
||||
var $currentrecord = array(); //used for buffering to allow uid lines to go first
|
||||
var $id;
|
||||
var $type = 'ldif';
|
||||
|
||||
var $import = array(
|
||||
"title" => "title",
|
||||
"givenname" => "n_given",
|
||||
"sn" => "n_family",
|
||||
"cn" => "fn",
|
||||
"o" => "org_name",
|
||||
"ou" => "org_unit",
|
||||
"streetaddress" => "adr_one_street",
|
||||
"locality" => "adr_one_locality",
|
||||
"st" => "adr_one_region",
|
||||
"postalcode" => "adr_one_postalcode",
|
||||
"countryname" => "adr_one_countryname",
|
||||
"telephonenumber" => "tel_work",
|
||||
"homephone" => "tel_home",
|
||||
"facsimiletelephonenumber" => "tel_fax",
|
||||
"xmozillaanyphone" => "ophone",
|
||||
"cellphone" => "tel_cell",
|
||||
"description" => "note",
|
||||
"pagerphone" => "tel_pager",
|
||||
"mail" => "email",
|
||||
"homeurl" => "url",
|
||||
"xmozillauseconferenceserver" => "",
|
||||
"xmozillanickname" => "",
|
||||
"xmozillausehtmlmail" => "",
|
||||
"modifytimestamp" => "",
|
||||
"objectclass" => ""
|
||||
);
|
||||
|
||||
function import_start_file($buffer,$j="",$k="") {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_file($buffer) {
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
$contacts = CreateObject("phpgwapi.contacts");
|
||||
//echo '<br>';
|
||||
for ($i=1;$i<=count($buffer);$i++) {
|
||||
while ( list($name,$value) = @each($buffer[$i]) ) {
|
||||
//echo '<br>'.$i.': '.$name.' => '.$value;
|
||||
$entry[$i][$name] = $value;
|
||||
}
|
||||
$entry[$i]['email_type'] = 'INTERNET';
|
||||
$entry[$i]['email_home_type'] = 'INTERNET';
|
||||
$entry[$i]['adr_one_type'] = 'intl';
|
||||
$entry[$i]['adr_two_type'] = 'intl';
|
||||
//echo '<br>';
|
||||
$contacts->add($phpgw_info["user"]["account_id"],$entry[$i]);
|
||||
}
|
||||
$num = $i - 1;
|
||||
return "Successfully imported $num records into your addressbook.";
|
||||
}
|
||||
|
||||
function import_start_record($buffer) {
|
||||
$top=array();
|
||||
++$this->id;
|
||||
$this->currentrecord = $top;
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_record($buffer,$private="private") {
|
||||
global $phpgw_info;
|
||||
$buffer[$this->id]="";
|
||||
while ( list($name, $value) = each($this->currentrecord)) {
|
||||
$buffer[$this->id][$name] = $value;
|
||||
//echo '<br>'.$this->id.': '.$name.' => '.$value;
|
||||
}
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_new_attrib($buffer,$name,$value) {
|
||||
// chop leading space from value
|
||||
$value = trim($value);
|
||||
$value = str_replace("\r","",$value);
|
||||
//echo '<br>'.$name.' => '.$value;
|
||||
$this->currentrecord += array($name => $value);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
?>
|
170
addressbook/import/Import_from_Outlook
Normal file
170
addressbook/import/Import_from_Outlook
Normal file
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
// This file defines a set of functions and an associative array.
|
||||
// The key of the array corresponds to a header in the source
|
||||
// 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:
|
||||
//
|
||||
// Title<tab>First Name<tab>Middle Name<tab>Last Name<tab>...
|
||||
// <tab>Patrick<tab><tab>Walsh<tab>...
|
||||
//
|
||||
// Where the first line explains each optional field. This is what
|
||||
// will be looked up in the key.
|
||||
//
|
||||
// The array need not be in any order and any fields not defined will
|
||||
// not be transferred. If the val='+', the value will be appended to
|
||||
// the previous field and any text after the '+' will be appended
|
||||
// before the value. For example, the following would add a comma and
|
||||
// a space between LastName and FirstName and store it in FullName:
|
||||
//
|
||||
// array("LastName" => "FullName","FirstName" => "+, ");
|
||||
//
|
||||
// Also start with a '#' symbol and a comma separated list will be
|
||||
// turned into a number of the same entries.
|
||||
|
||||
class import_conv
|
||||
{
|
||||
var $currentrecord = array(); //used for buffering to allow uid lines to go first
|
||||
var $id;
|
||||
var $type = 'csv';
|
||||
|
||||
var $import = array(
|
||||
"Title" => "title",
|
||||
"First Name" => "n_given",
|
||||
"Middle Name" => "n_middle",
|
||||
"Last Name" => "n_family",
|
||||
"Suffix" => "n_suffix",
|
||||
"Company" => "org_name", //objectclass: organization
|
||||
"Department" => "org_unit", //objectclass: organizationalPerson
|
||||
"Job Title" => "title", //objectclass: organizationalPerson
|
||||
"Business Street" => "adr_one_street",
|
||||
"Business Street 2" => "address2",
|
||||
"Business Street 3" => "address3",
|
||||
"Business City" => "adr_one_locality",
|
||||
"Business State" => "adr_one_region",
|
||||
"Business Postal Code" => "adr_one_postalcode",
|
||||
"Business Country" => "adr_one_countryname",
|
||||
"Home Street" => "adr_two_street",
|
||||
"Home City" => "adr_two_locality",
|
||||
"Home State" => "adr_two_region",
|
||||
"Home Postal Code" => "adr_two_postalcode",
|
||||
"Home Country" => "adr_two_countryname",
|
||||
"Home Street 2" => "",
|
||||
"Home Street 3" => "",
|
||||
"Other Street" => "",
|
||||
"Other City" => "",
|
||||
"Other State" => "",
|
||||
"Other Postal Code" => "",
|
||||
"Other Country" => "",
|
||||
"Assistant's Phone" => "tel_msg",
|
||||
"Business Fax" => "tel_fax",
|
||||
"Business Phone" => "tel_work",
|
||||
"Business Phone 2" => "ophone",
|
||||
"Callback" => "",
|
||||
"Car Phone" => "tel_car",
|
||||
"Company Main Phone" => "",
|
||||
"Home Fax" => "",
|
||||
"Home Phone" => "tel_home",
|
||||
"Home Phone 2" => "", //This will make another homePhone entry
|
||||
"ISDN" => "tel_isdn",
|
||||
"Mobile Phone" => "tel_cell", //newPilotPerson
|
||||
"Other Fax" => "",
|
||||
"Other Phone" => "",
|
||||
"Pager" => "tel_pager",
|
||||
"Primary Phone" => "",
|
||||
"Radio Phone" => "",
|
||||
"TTY/TDD Phone" => "",
|
||||
"Telex" => "", //organization
|
||||
"Account" => "",
|
||||
"Anniversary" => "",
|
||||
"Assistant's Name" => "", //newPilotPerson
|
||||
"Billing Information" => "",
|
||||
"Birthday" => "bday",
|
||||
"Categories" => "",
|
||||
"Children" => "",
|
||||
"Directory Server" => "",
|
||||
"E-mail Address" => "email",
|
||||
"E-mail Display Name" => "",
|
||||
"E-mail 2 Address" => "email_home",
|
||||
"E-mail 2 Display Name" => "",
|
||||
"E-mail 3 Address" => "", //add another...
|
||||
"E-mail 3 Display Name" => "",
|
||||
"Gender" => "",
|
||||
"Government ID Number" => "",
|
||||
"Hobby" => "",
|
||||
"Initials" => "",
|
||||
"Internet Free Busy" => "",
|
||||
"Keywords" => "",
|
||||
"Language" => "",
|
||||
"Location" => "",
|
||||
"Manager's Name" => "",
|
||||
"Mileage" => "",
|
||||
"Notes" => "note",
|
||||
"Office Location" => "",
|
||||
"Organizational ID Number" => "",
|
||||
"PO Box" => "",
|
||||
"Priority" => "",
|
||||
"Private Profession" => "",
|
||||
"Referred By" => "",
|
||||
"Sensitivity" => "",
|
||||
"Spouse" => "",
|
||||
"User 1" => "",
|
||||
"User 2" => "",
|
||||
"User 3" => "",
|
||||
"User 4" => "",
|
||||
"Web Page" => "url"
|
||||
);
|
||||
|
||||
function import_start_file($buffer,$j="",$k="") {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_file($buffer) {
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
$contacts = CreateObject("phpgwapi.contacts");
|
||||
//echo '<br>';
|
||||
for ($i=1;$i<=count($buffer);$i++) {
|
||||
while ( list($name,$value) = @each($buffer[$i]) ) {
|
||||
//echo '<br>'.$i.': '.$name.' => '.$value;
|
||||
$entry[$i][$name] = $value;
|
||||
}
|
||||
$entry[$i]['email_type'] = 'INTERNET';
|
||||
$entry[$i]['email_home_type'] = 'INTERNET';
|
||||
$entry[$i]['adr_one_type'] = 'intl';
|
||||
$entry[$i]['adr_two_type'] = 'intl';
|
||||
//echo '<br>';
|
||||
$contacts->add($phpgw_info["user"]["account_id"],$entry[$i]);
|
||||
}
|
||||
$num = $i - 1;
|
||||
return "Successfully imported $num records into your addressbook.";
|
||||
}
|
||||
|
||||
function import_start_record($buffer) {
|
||||
$top=array();
|
||||
++$this->id;
|
||||
$this->currentrecord = $top;
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_record($buffer,$private="private") {
|
||||
global $phpgw_info;
|
||||
$buffer[$this->id]="";
|
||||
while ( list($name, $value) = each($this->currentrecord)) {
|
||||
$buffer[$this->id][$name] = $value;
|
||||
//echo '<br>'.$name.' => '.$value;
|
||||
}
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_new_attrib($buffer,$name,$value) {
|
||||
$value = trim($value);
|
||||
$value = str_replace("\n","<BR>",$value);
|
||||
$value = str_replace("\r","",$value);
|
||||
$this->currentrecord += array($name => $value);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
?>
|
108
addressbook/import/Import_from_VCard
Normal file
108
addressbook/import/Import_from_VCard
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
// This file defines a set of functions and an associative array.
|
||||
// The key of the array corresponds to a header in the source
|
||||
// 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:
|
||||
//
|
||||
// Title<tab>First Name<tab>Middle Name<tab>Last Name<tab>...
|
||||
// <tab>Patrick<tab><tab>Walsh<tab>...
|
||||
//
|
||||
// Where the first line explains each optional field. This is what
|
||||
// will be looked up in the key.
|
||||
//
|
||||
// The array need not be in any order and any fields not defined will
|
||||
// not be transferred. If the val='+', the value will be appended to
|
||||
// the previous field and any text after the '+' will be appended
|
||||
// before the value. For example, the following would add a comma and
|
||||
// a space between LastName and FirstName and store it in FullName:
|
||||
//
|
||||
// array("LastName" => "FullName","FirstName" => "+, ");
|
||||
//
|
||||
// Also start with a '#' symbol and a comma separated list will be
|
||||
// turned into a number of the same entries.
|
||||
|
||||
class import_conv
|
||||
{
|
||||
var $currentrecord = array(); //used for buffering to allow uid lines to go first
|
||||
var $id;
|
||||
var $type = 'vcard';
|
||||
|
||||
var $import = 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" => "adr",
|
||||
"label" => "label",
|
||||
"tel" => "tel",
|
||||
"email" => "email",
|
||||
);
|
||||
|
||||
var $grouping = array("a.","b.","c.","d.");
|
||||
|
||||
function import_start_file($buffer,$j="",$k="") {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_file($buffer) {
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
$contacts = CreateObject("phpgwapi.contacts");
|
||||
echo '<br>';
|
||||
for ($i=1;$i<=count($buffer);$i++) {
|
||||
while ( list($name,$value) = @each($buffer[$i]) ) {
|
||||
echo '<br>'.$i.': '.$name.' => '.$value;
|
||||
$entry[$i][$name] = $value;
|
||||
}
|
||||
$entry[$i]['email_type'] = 'INTERNET';
|
||||
$entry[$i]['email_home_type'] = 'INTERNET';
|
||||
$entry[$i]['adr_one_type'] = 'intl';
|
||||
$entry[$i]['adr_two_type'] = 'intl';
|
||||
echo '<br>';
|
||||
//$contacts->add($phpgw_info["user"]["account_id"],$entry[$i]);
|
||||
}
|
||||
$num = $i - 1;
|
||||
return "Successfully imported $num records into your addressbook.";
|
||||
}
|
||||
|
||||
function import_start_record($buffer) {
|
||||
$top=array();
|
||||
++$this->id;
|
||||
$this->currentrecord = $top;
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_record($buffer,$private="private") {
|
||||
global $phpgw_info;
|
||||
$buffer[$this->id]="";
|
||||
while ( list($name, $value) = each($this->currentrecord)) {
|
||||
$buffer[$this->id][$name] = $value;
|
||||
//echo '<br>'.$name.' => '.$value;
|
||||
}
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_new_attrib($buffer,$name,$value) {
|
||||
$value = trim($value);
|
||||
$value = str_replace("\n","<BR>",$value);
|
||||
$value = str_replace("\r","",$value);
|
||||
$this->currentrecord += array($name => $value);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user