Several form changes and mods to vcardout.

This commit is contained in:
Miles Lott 2001-02-04 05:53:24 +00:00
parent 78bd44e89e
commit 21096481b9
10 changed files with 253 additions and 106 deletions

View File

@ -27,26 +27,26 @@ class outlook_conv {
var $currentrecord; //used for buffering to allow uid lines to go first
var $outlook = array(
"Title" => "",
"First Name" => "ab_firstname",
"Middle Name" => "",
"Last Name" => "ab_lastname",
"Suffix" => "",
"Company" => "ab_company", //objectclass: organization
"Department" => "", //objectclass: organizationalPerson
"Job Title" => "ab_title", //objectclass: organizationalPerson
"Business Street" => "ab_address2",
"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" => "address2",
"Business Street 2" => "",
"Business Street 3" => "",
"Business City" => "",
"Business State" => "",
"Business Postal Code" => "",
"Business Country" => "",
"Home Street" => "ab_street",
"Home City" => "ab_city",
"Home State" => "ab_state",
"Home Postal Code" => "ab_zip",
"Home Country" => "",
"Home Street" => "ADR.Street",
"Home City" => "ADR.Locality",
"Home State" => "ADR.Region",
"Home Postal Code" => "ADR.PostalCode",
"Home Country" => "ADR.Country",
"Home Street 2" => "",
"Home Street 3" => "",
"Other Street" => "",
@ -55,20 +55,20 @@ class outlook_conv {
"Other Postal Code" => "",
"Other Country" => "",
"Assistant's Phone" => "",
"Business Fax" => "ab_fax",
"Business Phone" => "ab_wphone",
"Business Phone 2" => "ab_ophone",
"Business Fax" => "C.TEL",
"Business Phone" => "B.TEL",
"Business Phone 2" => "ophone",
"Callback" => "",
"Car Phone" => "",
"Company Main Phone" => "",
"Home Fax" => "",
"Home Phone" => "ab_hphone",
"Home Phone" => "A.TEL",
"Home Phone 2" => "", //This will make another homePhone entry
"ISDN" => "",
"Mobile Phone" => "ab_mphone", //newPilotPerson
"Mobile Phone" => "mphone", //newPilotPerson
"Other Fax" => "",
"Other Phone" => "",
"Pager" => "ab_pager",
"Pager" => "pager",
"Primary Phone" => "",
"Radio Phone" => "",
"TTY/TDD Phone" => "",
@ -77,11 +77,11 @@ class outlook_conv {
"Anniversary" => "",
"Assistant's Name" => "", //newPilotPerson
"Billing Information" => "",
"Birthday" => "ab_bday",
"Birthday" => "bday",
"Categories" => "",
"Children" => "",
"Directory Server" => "",
"E-mail Address" => "ab_email",
"E-mail Address" => "D.EMAIL",
"E-mail Display Name" => "",
"E-mail 2 Address" => "",
"E-mail 2 Display Name" => "",
@ -117,14 +117,14 @@ function outlook_start_file($buffer,$j="",$k="") {
}
function outlook_end_file($buffer) {
global $phpgw;
global $phpgw_info;
global $phpgw,$phpgw_info;
$lines = split("\n",$buffer);
$contacts = CreateObject("phpgwapi.contacts");
for ($i=0;$i<count($lines);$i++) {
$sql=$lines[$i];
$phpgw->db->query($sql);
$entry=$lines[$i];
$contacts->add($phpgw_info["user"]["account_id"],$entry);
}
return "Successfully imported $i records into your addressbook.";
@ -143,49 +143,13 @@ function outlook_end_record($buffer,$private="private") {
$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 addressbook (ab_owner,ab_access,".$thisname;
$valulist = $valulist."VALUES ('".$phpgw_info["user"]["account_id"]."','".$private."',".$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;
}
$namelist = $namelist.array($name => $value);
}
return $buffer.$namelist.$valulist;
return $buffer.$namelist;
}
function outlook_new_attrib($buffer,$name,$value) {

View File

@ -56,27 +56,36 @@
$access = $phpgw->accounts->array_to_string($access,$n_groups);
}
$fields["ORG_Name"] = $company;
$fields["N_Given"] = $firstname;
$fields["N_Family"] = $lastname;
$fields["D_EMAIL"] = $email;
$fields["D_EMAILTYPE"] = $email_type;
$fields["TITLE"] = $title;
$fields["A_TEL"] = $wphone;
$fields["B_TEL"] = $hphone;
$fields["C_TEL"] = $fax;
$fields["pager"] = $pager;
$fields["mphone"] = $mphone;
$fields["ophone"] = $ophone;
$fields["ADR_Street"] = $street;
$fields["address2"] = $address2;
$fields["ADR_Locality"] = $city;
$fields["ADR_Region"] = $state;
$fields["ADR_PostalCode"] = $zip;
$fields["ADR_Country"] = $country;
$fields["bday"] = $bday;
$fields["url"] = $url;
$fields["notes"] = $notes;
$fields["ORG_Name"] = $company;
$fields["ORG_Unit"] = $department;
$fields["N_Given"] = $firstname;
$fields["N_Family"] = $lastname;
$fields["N_Middle"] = $middle;
$fields["N_Prefix"] = $prefix;
$fields["N_Suffix"] = $suffix;
if ($prefix) { $pspc = " "; }
if ($middle) { $mspc = " "; }
if ($suffix) { $sspc = " "; }
$fields["FN"] = $prefix . $pspc . $firstname . $mspc . $middle . $mspc . $lastname . $sspc . $suffix;
$fields["D_EMAIL"] = $email;
$fields["D_EMAILTYPE"] = $email_type;
$fields["TITLE"] = $title;
$fields["A_TEL"] = $wphone;
$fields["B_TEL"] = $hphone;
$fields["C_TEL"] = $fax;
$fields["pager"] = $pager;
$fields["mphone"] = $mphone;
$fields["ophone"] = $ophone;
$fields["ADR_Street"] = $street;
$fields["address2"] = $address2;
$fields["ADR_Locality"] = $city;
$fields["ADR_Region"] = $state;
$fields["ADR_PostalCode"] = $zip;
$fields["ADR_CountryName"] = $country;
$fields["TZ"] = $timezone;
$fields["bday"] = $bday;
$fields["url"] = $url;
$fields["notes"] = $notes;
$this->update($ab_id,$phpgw_info["user"]["account_id"],$fields);

View File

@ -18,17 +18,17 @@
$sep = $phpgw_info["server"]["dir_separator"];
# Construct a default basedn and context for Contacts if using LDAP
# Construct a default basedn for Contacts if using LDAP
$tmpbasedn = split(",",$phpgw_info["server"]["ldap_context"]);
array_shift($tmpbasedn);
for ($i=0;$i<count($tmpbasedn);$i++) {
if($i==0) {
$fakebasedn = $tmpbasedn[$i];
$basedn = $tmpbasedn[$i];
} else {
$fakebasedn = $fakebasedn.",".$tmpbasedn[$i];
$basedn = $basedn.",".$tmpbasedn[$i];
}
}
$fakecontext = "ou=Contacts,".$fakebasedn;
$context = $phpgw_info["server"]["ldap_contact_context"];
if (!$convert) {
$t = new Template($phpgw_info["server"]["app_tpl"]);
@ -58,8 +58,8 @@
$t->set_var("tsvfilename","");
$t->set_var("conv",$conv);
$t->set_var("debug",lang("Debug output in browser"));
$t->set_var("fakebasedn",$fakebasedn);
$t->set_var("fakecontext",$fakecontext);
$t->set_var("basedn",$basedn);
$t->set_var("context",$context);
$t->set_var("download",lang("Submit"));
#$t->parse("out","import");

View File

@ -17,7 +17,7 @@
$abc = array("FN" => "full name", //'firstname lastname'
"SOUND" => "",
"ORG_Name" => "company", //company
"ORG_Name" => "company name", //company
"ORG_Unit" => "department", //division
"TITLE" => "title",
"N_Given" => "first name", //firstname
@ -36,7 +36,7 @@
"ADR_Parcel" => "", //yn
"ADR_Postal" => "", //yn
"TZ" => "timezone",
"GEO" => "",
"GEO" => "geo",
"A_TEL" => "home phone",
"A_TEL_Work" => "", //yn
"A_TEL_Home" => "", //yn
@ -83,6 +83,9 @@
$email = $fields["D_EMAIL"];
$emailtype = $fields["D_EMAILTYPE"];
$firstname = $fields["N_Given"];
$middle = $fields["N_Middle"];
$prefix = $fields["N_Prefix"];
$suffix = $fields["N_Suffix"];
$lastname = $fields["N_Family"];
$title = $fields["TITLE"];
$hphone = $fields["A_TEL"];
@ -96,16 +99,21 @@
$city = $fields["ADR_Locality"];
$state = $fields["ADR_Region"];
$zip = $fields["ADR_PostalCode"];
$country = $fields["ADR_Country"];
$country = $fields["ADR_CountryName"];
$timezone = $fields["TZ"];
$bday = $fields["bday"];
$notes = $fields["notes"];
$company = $fields["ORG_Name"];
$department = $fields["ORG_Unit"];
$url = $fields["url"];
if ($format != "view") {
$email = "<input name=\"email\" value=\"$email\">";
$firstname = "<input name=\"firstname\" value=\"$firstname\">";
$lastname = "<input name=\"lastname\" value=\"$lastname\">";
$middle = "<input name=\"middle\" value=\"$middle\">";
$prefix = "<input name=\"prefix\" value=\"$prefix\" size=\"10\">";
$suffix = "<input name=\"suffix\" value=\"$suffix\" size=\"10\">";
$title = "<input name=\"title\" value=\"$title\">";
$hphone = "<input name=\"hphone\" value=\"$hphone\">";
$wphone = "<input name=\"wphone\" value=\"$wphone\">";
@ -140,6 +148,7 @@
$company .= "</select>";
} else { */
$company = "<input name=\"company\" value=\"$company\">";
$department = "<input name=\"department\" value=\"$department\">";
/* } */
if (strlen($bday) > 2) {
@ -182,6 +191,19 @@
$bday_day = '<input name="bday_day" size="2" maxlength="2">';
$bday_year = '<input name="bday_year" size="4" maxlength="4">';
}
$time_zone = "<select name=\"timezone\">\n";
for ($i = -23; $i<24; $i++) {
$time_zone .= "<option value=\"$i\"";
if ($i == $timezone)
$time_zone .= " selected";
if ($i < 1)
$time_zone .= ">$i</option>\n";
else
$time_zone .= ">+$i</option>\n";
}
$time_zone .= "</select>\n";
$this = CreateObject("phpgwapi.contacts");
$email_type = '<select name=email_type>';
while ($type = each($this->email_types)) {
@ -291,8 +313,16 @@
$t->set_var("lastname",$lastname);
$t->set_var("lang_firstname",lang("First Name"));
$t->set_var("firstname",$firstname);
$t->set_var("lang_middle",lang("Middle Name"));
$t->set_var("middle",$middle);
$t->set_var("lang_prefix",lang("Prefix"));
$t->set_var("prefix",$prefix);
$t->set_var("lang_suffix",lang("Suffix"));
$t->set_var("suffix",$suffix);
$t->set_var("lang_company",lang("Company Name"));
$t->set_var("company",$company);
$t->set_var("lang_department",lang("Department"));
$t->set_var("department",$department);
$t->set_var("lang_title",lang("Title"));
$t->set_var("title",$title);
$t->set_var("lang_email",lang("Email"));
@ -301,6 +331,8 @@
$t->set_var("email_type",$email_type);
$t->set_var("lang_url",lang("URL"));
$t->set_var("url",$url);
$t->set_var("lang_timezone",lang("time zone offset"));
$t->set_var("timezone",$time_zone);
$t->set_var("lang_hphone",lang("Home Phone"));
$t->set_var("hphone",$hphone);
$t->set_var("lang_fax",lang("fax"));

View File

@ -0,0 +1,99 @@
function read($start,$offset,$fields,$query="",$sort="",$order="")
$start = start of list, e.g. 1,16,31
$offset = numrows, e.g. 15,30,etc.
$fields = simple array of fields to return
$query = simple string to search for
$sort = ASC, DESC, or ""
$order = sort on this field, e.g. N_Given
returns an array of name/values, e.g.:
$fields[0]["D_EMAIL"] => "name@domain.com"
...
$fields[1]["D_EMAIL"] => "othername@otherdomain.com"
...
function read_single_entry($id,$fields)
$id = id of entry you want to return
$fields = simple array of fields to return
returns a single array of name/value, e.g.:
$fields[0]["D_EMAIL"] => "name@domain.com"
$fields[0]["N_Given"] => "Bob"
function add($owner,$fields)
$owner = lid of user adding this data
$fields = assoc array of fields to write into the new record
function update($id,$owner,$fields)
$id = id of entry you want to update
$owner = lid of user modifying this data
$fields = assoc array of fields to update in the record
function delete_($id)
$id = id of entry you want to delete
$this->stock_contact_fields = array("FN" => "FN", //'firstname lastname'
"SOUND" => "SOUND",
"ORG_Name" => "ORG_Name", //company
"ORG_Unit" => "ORG_Unit", //division
"TITLE" => "TITLE",
"N_Given" => "N_Given", //firstname
"N_Family" => "N_Family", //lastname
"N_Middle" => "N_Middle",
"N_Prefix" => "N_Prefix",
"N_Suffix" => "N_Suffix",
"LABEL" => "LABEL",
"ADR_Street" => "ADR_Street",
"ADR_Locality" => "ADR_Locality", //city
"ADR_Region" => "ADR_Region", //state
"ADR_PostalCode" => "ADR_PostalCode", //zip
"ADR_CountryName" => "ADR_CountryName",
"ADR_Work" => "ADR_Work", //yn
"ADR_Home" => "ADR_Home", //yn
"ADR_Parcel" => "ADR_Parcel", //yn
"ADR_Postal" => "ADR_Postal", //yn
"TZ" => "TZ",
"GEO" => "GEO",
"A_TEL" => "A_TEL",
"A_TEL_Work" => "A_TEL_Work", //yn
"A_TEL_Home" => "A_TEL_Home", //yn
"A_TEL_Voice" => "A_TEL_Voice", //yn
"A_TEL_Msg" => "A_TEL_Msg", //yn
"A_TEL_Fax" => "A_TEL_Fax", //yn
"A_TEL_Prefer" => "A_TEL_Prefer", //yn
"B_TEL" => "B_TEL",
"B_TEL_Work" => "B_TEL_Work", //yn
"B_TEL_Home" => "B_TEL_Home", //yn
"B_TEL_Voice" => "B_TEL_Voice", //yn
"B_TEL_Msg" => "B_TEL_Msg", //yn
"B_TEL_Fax" => "B_TEL_Fax", //yn
"B_TEL_Prefer" => "B_TEL_Prefer", //yn
"C_TEL" => "C_TEL",
"C_TEL_Work" => "C_TEL_Work", //yn
"C_TEL_Home" => "C_TEL_Home", //yn
"C_TEL_Voice" => "C_TEL_Voice", //yn
"C_TEL_Msg" => "C_TEL_Msg", //yn
"C_TEL_Fax" => "C_TEL_Fax", //yn
"C_TEL_Prefer" => "C_TEL_Prefer", //yn
"D_EMAIL" => "D_EMAIL",
"D_EMAILTYPE" => "D_EMAILTYPE", //'INTERNET','CompuServe',etc...
"D_EMAIL_Work" => "D_EMAIL_Work", //yn
"D_EMAIL_Home" => "D_EMAIL_Home", //yn
);
$this->email_types = array("INTERNET" => "INTERNET",
"CompuServe" => "CompuServe",
"AOL" => "AOL",
"Prodigy" => "Prodigy",
"eWorld" => "eWorld",
"AppleLink" => "AppleLink",
"AppleTalk" => "AppleTalk",
"PowerShare" => "PowerShare",
"IBMMail" => "IBMMail",
"ATTMail" => "ATTMail",
"MCIMail" => "MCIMail",
"X.400" => "X.400",
"TLX" => "TLX"
);

View File

@ -60,7 +60,9 @@ CREATE TABLE addressbook (
D_EMAIL_Work enum('y','n') DEFAULT 'n' NOT NULL,
D_EMAIL_Home enum('y','n') DEFAULT 'n' NOT NULL,
PRIMARY KEY (id),
UNIQUE id (id)
UNIQUE id (id),
KEY lid (lid),
KEY tid (tid)
);
CREATE TABLE addressbook_extra (

View File

@ -1,16 +1,37 @@
<!-- BEGIN addressbook entry form -->
<table width="75%" border="0" align="center">
<tr>
<td><font color="#000000" face="" size="-1">{lang_prefix}:</font></td>
<td>
<font size="-1">
{prefix}
</font></td>
</tr>
<tr>
<td><font color="#000000" face="" size="-1">{lang_firstname}:</font></td>
<td>
<font size="-1">
{firstname}
</font></td>
<td><font color="#000000" face="" size="-1">{lang_middle}:</font></td>
<td>
<font size="-1">
{middle}
</font></td>
</tr>
<tr>
<td><font color="#000000" face="" size="-1">{lang_lastname}:</font></td>
<td>
<font size="-1">
{lastname}
</font></td>
<td><font color="#000000" face="" size="-1">{lang_firstname}:</font></td>
</tr>
<tr>
<td><font color="#000000" face="" size="-1">{lang_suffix}:</font></td>
<td>
<font size="-1">
{firstname}
{suffix}
</font></td>
</tr>
<tr>
@ -52,7 +73,15 @@
</td>
<td><font size="-1"></font></td>
</tr>
<tr>
<td>
<font color="#000000" face="" size="-1">{lang_department}:</font>
</td>
<td>
<font size="-1">{department}</font>
</td>
<td><font size="-1"></font></td>
</tr>
<tr>
<td><font color="#000000" face="" size="-1">{lang_hphone}:</font></td>
<td>
@ -142,9 +171,15 @@
<font size="-1">
{country}
</font></td>
<td><font color="#000000" face="" size="-1">{lang_timezone}:</font></td>
<td>
<font size="-1">
{timezone}
</font></td>
<td><font size="-1"></font></td>
<td><font size="-1"></font></td>
</tr>
<tr>
<td colspan="4"><font size="-1"></font></td>
</tr>

View File

@ -24,8 +24,8 @@
</SELECT><P></LI>
<LI><INPUT NAME="download" TYPE="checkbox" VALUE="{debug}" CHECKED>Debug output in browser (Uncheck to download output.)</LI>
<LI><INPUT NAME="private" TYPE="checkbox" VALUE="private" CHECKED>Mark records as private (Addressbook)</LI>
<LI>Use this basedn (LDAP)<BR><INPUT NAME="basedn" TYPE="text" VALUE="{fakebasedn}" SIZE="48"></LI>
<LI>Use this context for storing Contacts (LDAP)<BR><INPUT NAME="context" TYPE="text" VALUE="{fakecontext}" SIZE="48"></LI>
<LI>Use this basedn (LDAP)<BR><INPUT NAME="basedn" TYPE="text" VALUE="{basedn}" SIZE="48"></LI>
<LI>Use this context for storing Contacts (LDAP)<BR><INPUT NAME="context" TYPE="text" VALUE="{context}" SIZE="48"></LI>
<LI><INPUT NAME="convert" TYPE="submit" VALUE="{download}"></LI>
</OL>
</FORM></TD>

View File

@ -35,8 +35,12 @@
$fields = $this->read_single_entry($ab_id,$this->stock_contact_fields);
$email = $fields[0]["D_EMAIL"];
$fullname = $fields[0]["FN"];
$prefix = $fields[0]["N_Prefix"];
$firstname = $fields[0]["N_Given"];
$middle = $fields[0]["N_Middle"];
$lastname = $fields[0]["N_Family"];
$suffix = $fields[0]["N_Suffix"];
$title = $fields[0]["TITLE"];
$hphone = $fields[0]["A_TEL"];
$wphone = $fields[0]["B_TEL"];
@ -49,8 +53,9 @@
$city = $fields[0]["ADR_Locality"];
$state = $fields[0]["ADR_Region"];
$zip = $fields[0]["ADR_PostalCode"];
$country = $fields[0]["ADR_Country"];
$country = $fields[0]["ADR_CountryName"];
$company = $fields[0]["ORG_Name"];
$dept = $fields[0]["ORG_Unit"];
$bday = $fields[0]["bday"];
$notes = $fields[0]["notes"];
$access = $fields[0]["access"];
@ -78,7 +83,8 @@
printf("BEGIN:VCARD\r\n");
printf("N:%s;%s\r\n", $lastname, $firstname);
printf("FN:%s %s\r\n", $firstname, $lastname);
if (!$fullname) { printf("FN:%s %s\r\n", $firstname, $lastname); }
else { printf("FN:%s\r\n", $fullname); }
/* This stuff is optional. */
if($title != "") /* Title */
@ -110,7 +116,7 @@
if($bday != "" && $bday != "//") /* Birthday */
printf("BDAY:%s\r\n", $bday); /* This is not the right format. */
if($company != "") /* Company Name (Really isn't company_name?) */
printf("ORG:%s\r\n", $company);
printf("ORG:%s %s\r\n", $company, $dept);
if($notes != "") /* Notes */
$NOTES .= $notes;

View File

@ -56,7 +56,7 @@
$view_header .= '<table border="0" cellspacing="2" cellpadding="2" width="80%" align="center">';
while ($column = each($columns_to_display)) { // each entry column
$columns_html .= "<tr><td><b>" . lang($colname[$column[0]]) . "</b>:</td>";
$columns_html .= "<tr><td><b>" . lang(display_name($colname[$column[0]])) . "</b>:</td>";
$ref=$data="";
$coldata = $fields[0][$column[0]];
// Some fields require special formatting.