From 21096481b93c1e7191d727880df240bd2f70fc32 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Sun, 4 Feb 2001 05:53:24 +0000 Subject: [PATCH] Several form changes and mods to vcardout. --- .../conv/Import to Addressbook (MySQL) | 96 ++++++------------ addressbook/edit.php | 51 ++++++---- addressbook/import.php | 12 +-- addressbook/inc/functions.inc.php | 38 ++++++- addressbook/inc/readme.txt | 99 +++++++++++++++++++ addressbook/sql/addressbook.sql | 4 +- addressbook/templates/default/form.tpl | 41 +++++++- addressbook/templates/default/import.tpl | 4 +- addressbook/vcardout.php | 12 ++- addressbook/view.php | 2 +- 10 files changed, 253 insertions(+), 106 deletions(-) create mode 100644 addressbook/inc/readme.txt diff --git a/addressbook/conv/Import to Addressbook (MySQL) b/addressbook/conv/Import to Addressbook (MySQL) index 70a45971c9..4179a091d7 100644 --- a/addressbook/conv/Import to Addressbook (MySQL) +++ b/addressbook/conv/Import to Addressbook (MySQL) @@ -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; - - $lines = split("\n",$buffer); + global $phpgw,$phpgw_info; + $lines = split("\n",$buffer); + $contacts = CreateObject("phpgwapi.contacts"); + for ($i=0;$idb->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;$i2) { - $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) { diff --git a/addressbook/edit.php b/addressbook/edit.php index 2fb4b9fd75..c9fec6a59f 100755 --- a/addressbook/edit.php +++ b/addressbook/edit.php @@ -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); diff --git a/addressbook/import.php b/addressbook/import.php index 7f3c4da36e..4d2dc94c3a 100644 --- a/addressbook/import.php +++ b/addressbook/import.php @@ -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;$iset_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"); diff --git a/addressbook/inc/functions.inc.php b/addressbook/inc/functions.inc.php index 94720e8092..4d67971781 100755 --- a/addressbook/inc/functions.inc.php +++ b/addressbook/inc/functions.inc.php @@ -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 = ""; $firstname = ""; $lastname = ""; + $middle = ""; + $prefix = ""; + $suffix = ""; $title = ""; $hphone = ""; $wphone = ""; @@ -140,6 +148,7 @@ $company .= ""; } else { */ $company = ""; + $department = ""; /* } */ if (strlen($bday) > 2) { @@ -182,6 +191,19 @@ $bday_day = ''; $bday_year = ''; } + + $time_zone = "

  • Debug output in browser (Uncheck to download output.)
  • Mark records as private (Addressbook)
  • -
  • Use this basedn (LDAP)
  • -
  • Use this context for storing Contacts (LDAP)
  • +
  • Use this basedn (LDAP)
  • +
  • Use this context for storing Contacts (LDAP)
  • diff --git a/addressbook/vcardout.php b/addressbook/vcardout.php index 187046dbc6..7e581091f7 100644 --- a/addressbook/vcardout.php +++ b/addressbook/vcardout.php @@ -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; diff --git a/addressbook/view.php b/addressbook/view.php index 478f0a5e4e..5f2cbf8204 100755 --- a/addressbook/view.php +++ b/addressbook/view.php @@ -56,7 +56,7 @@ $view_header .= ''; while ($column = each($columns_to_display)) { // each entry column - $columns_html .= ""; + $columns_html .= ""; $ref=$data=""; $coldata = $fields[0][$column[0]]; // Some fields require special formatting.
    " . lang($colname[$column[0]]) . ":
    " . lang(display_name($colname[$column[0]])) . ":