Correct field mapping

This commit is contained in:
Miles Lott 2001-02-02 06:28:56 +00:00
parent f6c10d906a
commit 404f0c79da
2 changed files with 56 additions and 56 deletions

View File

@ -37,7 +37,7 @@
{ {
var $db; var $db;
var $account_id; var $account_id;
var $stock_addressbook_fields; // This is an array of all the fields in the addressbook var $stock_contact_fields; // This is an array of all the fields in the addressbook
var $total_records; var $total_records;
function split_ab_and_extras($fields) function split_ab_and_extras($fields)
@ -48,7 +48,7 @@
if (gettype($field) == "integer") { if (gettype($field) == "integer") {
$field = $value; $field = $value;
} }
if ($this->stock_addressbook_fields[$field]) { if ($this->stock_contact_fields[$field]) {
$ab_fields[$field] = $value; $ab_fields[$field] = $value;
$ab_fieldnames[$field] = $field; $ab_fieldnames[$field] = $field;
} else { } else {
@ -60,7 +60,7 @@
function loop_addslashes($fields) function loop_addslashes($fields)
{ {
$absf = $this->stock_addressbook_fields; $absf = $this->stock_contact_fields;
while ($t = each($absf)) { while ($t = each($absf)) {
$ta[] = addslashes($fields[$t[0]]); $ta[] = addslashes($fields[$t[0]]);
} }

View File

@ -52,50 +52,50 @@
$this->stock_contact_fields = array("FN" => "FN", //'firstname lastname' $this->stock_contact_fields = array("FN" => "FN", //'firstname lastname'
"SOUND" => "SOUND", "SOUND" => "SOUND",
"ORG.Name" => "ORG.Name", //company "ORG.Name" => "ORG.Name", //company
"ORG.Unit" => "ORG.Unit", //division "ORG_Unit" => "ORG.Unit", //division
"TITLE" => "TITLE", "TITLE" => "TITLE",
"N.Given" => "N_Given", //firstname "N_Given" => "N.Given", //firstname
"N.Family" => "N_Family", //lastname "N_Family" => "N.Family", //lastname
"N.Middle" => "N_Middle", "N_Middle" => "N.Middle",
"N.Prefix" => "N_Prefix", "N_Prefix" => "N.Prefix",
"N.Suffix" => "N_Suffix", "N_Suffix" => "N.Suffix",
"LABEL" => "LABEL", "LABEL" => "LABEL",
"ADR_Street" => "ADR_Street", "ADR_Street" => "ADR.Street",
"ADR.Locality" => "ADR_Locality", //city "ADR_Locality" => "ADR.Locality", //city
"ADR.Region" => "ADR_Region", //state "ADR_Region" => "ADR.Region", //state
"ADR.PostalCode" => "ADR_PostalCode", //zip "ADR_PostalCode" => "ADR.PostalCode", //zip
"ADR.CountryName" => "ADR_CountryName", "ADR_CountryName" => "ADR.CountryName",
"ADR_Work" => "ADR_Work", "ADR_Work" => "ADR.Work", //yn
"ADR_Home" => "ADR_Home", "ADR_Home" => "ADR.Home", //yn
"ADR_Parcel" => "ADR_Parcel", "ADR_Parcel" => "ADR.Parcel", //yn
"ADR_Postal" => "ADR_Postal", "ADR_Postal" => "ADR.Postal", //yn
"TZ" => "TZ", "TZ" => "TZ",
"GEO" => "GEO", "GEO" => "GEO",
"A.TEL" => "A_TEL", "A_TEL" => "A.TEL",
"A.TEL.Work" => "A_TEL_Work", "A_TEL_Work" => "A.TEL.Work", //yn
"A.TEL.Home" => "A_TEL_Home", "A_TEL_Home" => "A.TEL.Home", //yn
"A.TEL.Voice" => "A_TEL_Voice", "A_TEL_Voice" => "A.TEL.Voice", //yn
"A.TEL.Msg" => "A_TEL_Msg", "A_TEL_Msg" => "A.TEL.Msg", //yn
"A.TEL.Fax" => "A_TEL_Fax", "A_TEL_Fax" => "A.TEL.Fax", //yn
"A.TEL.Prefer" => "A_TEL_Prefer", "A_TEL_Prefer" => "A.TEL.Prefer", //yn
"B.TEL" => "B_TEL", "B_TEL" => "B.TEL",
"B.TEL.Work" => "B_TEL_Work", "B_TEL_Work" => "B.TEL.Work", //yn
"B.TEL.Home" => "B_TEL_Home", "B_TEL_Home" => "B.TEL.Home", //yn
"B.TEL.Voice" => "B_TEL_Voice", "B_TEL_Voice" => "B.TEL.Voice", //yn
"B.TEL.Msg" => "B_TEL_Msg", "B_TEL_Msg" => "B.TEL.Msg", //yn
"B.TEL.Fax" => "B_TEL_Fax", "B_TEL_Fax" => "B.TEL.Fax", //yn
"B.TEL.Prefer" => "B_TEL_Prefer", "B_TEL_Prefer" => "B.TEL.Prefer", //yn
"C.TEL" => "C_TEL", "C_TEL" => "C.TEL",
"C.TEL.Work" => "C_TEL_Work", "C_TEL_Work" => "C.TEL.Work", //yn
"C.TEL.Home" => "C_TEL_Home", "C_TEL_Home" => "C.TEL.Home", //yn
"C.TEL.Voice" => "C_TEL_Voice", "C_TEL_Voice" => "C.TEL.Voice", //yn
"C.TEL.Msg" => "C_TEL_Msg", "C_TEL_Msg" => "C.TEL.Msg", //yn
"C.TEL.Fax" => "C_TEL_Fax", "C_TEL_Fax" => "C.TEL.Fax", //yn
"C.TEL.Prefer" => "C_TEL_Prefer", "C_TEL_Prefer" => "C.TEL.Prefer", //yn
"D.EMAIL" => "D_EMAIL", "D_EMAIL" => "D.EMAIL",
"D.EMAILTYPE" => "D_EMAILTYPE", //'INTERNET','CompuServe',etc... "D_EMAILTYPE" => "D.EMAILTYPE", //'INTERNET','CompuServe',etc...
"D.EMAIL.Work" => "D_EMAIL_Work", //yn "D_EMAIL_Work" => "D.EMAIL.Work", //yn
"D.EMAIL.Home" => "D_EMAIL_Home", //yn "D_EMAIL_Home" => "D.EMAIL.Home", //yn
); );
} }
@ -111,7 +111,7 @@
$this->db2 = $this->db; $this->db2 = $this->db;
$this->db->query("select id,lid,owner $t_fields from contacts WHERE id='$id'"); $this->db->query("select id,lid,owner $t_fields from addressbook WHERE id='$id'");
$this->db->next_record(); $this->db->next_record();
$return_fields[0]["id"] = $this->db->f("id"); $return_fields[0]["id"] = $this->db->f("id");
@ -122,7 +122,7 @@
$return_fields[0][$f_name] = $this->db->f($f_name); $return_fields[0][$f_name] = $this->db->f($f_name);
} }
} }
$this->db2->query("select contact_name,contact_value from contacts_extra where contact_id='" $this->db2->query("select contact_name,contact_value from addressbook_extra where contact_id='"
. $this->db->f("id") . "'",__LINE__,__FILE__); . $this->db->f("id") . "'",__LINE__,__FILE__);
while ($this->db2->next_record()) { while ($this->db2->next_record()) {
// If its not in the list to be returned, don't return it. // If its not in the list to be returned, don't return it.
@ -158,25 +158,25 @@
$this->db3 = $this->db2 = $this->db; // Create new result objects before our queries $this->db3 = $this->db2 = $this->db; // Create new result objects before our queries
if ($query) { if ($query) {
$this->db3->query("SELECT * from contacts WHERE (N_Family like '" $this->db3->query("SELECT * from addressbook WHERE (N_Family like '"
. "%$query%' OR N_Given like '%$query%' OR D_EMAIL like '%$query%' OR " . "%$query%' OR N_Given like '%$query%' OR D_EMAIL like '%$query%' OR "
. "ADR_Street like '%$query%' OR ADR_Locality like '%$query%' OR ADR_Region " . "ADR_Street like '%$query%' OR ADR_Locality like '%$query%' OR ADR_Region "
. "like '%$query%' OR ADR_PostalCode like '%$query%' OR ORG_Unit like " . "like '%$query%' OR ADR_PostalCode like '%$query%' OR ORG_Unit like "
. "'%$query%' OR ORG_Name like '%$query%') " . $ordermethod,__LINE__,__FILE__); . "'%$query%' OR ORG_Name like '%$query%') " . $ordermethod,__LINE__,__FILE__);
$this->total_records = $this->db3->num_rows(); $this->total_records = $this->db3->num_rows();
$this->db->query("SELECT * from contacts WHERE (N_Family like '" $this->db->query("SELECT * from addressbook WHERE (N_Family like '"
. "%$query%' OR N_Given like '%$query%' OR D_EMAIL like '%$query%' OR " . "%$query%' OR N_Given like '%$query%' OR D_EMAIL like '%$query%' OR "
. "ADR_Street like '%$query%' OR ADR_Locality like '%$query%' OR ADR_Region " . "ADR_Street like '%$query%' OR ADR_Locality like '%$query%' OR ADR_Region "
. "like '%$query%' OR ADR_PostalCode like '%$query%' OR ORG_Unit like " . "like '%$query%' OR ADR_PostalCode like '%$query%' OR ORG_Unit like "
. "'%$query%' OR ORG_Name like '%$query%') " . $ordermethod . " " . "'%$query%' OR ORG_Name like '%$query%') " . $ordermethod . " "
. $this->db->limit($start,$offset),__LINE__,__FILE__); . $this->db->limit($start,$offset),__LINE__,__FILE__);
} else { } else {
$this->db3->query("select id,lid,owner $t_fields from contacts " $this->db3->query("select id,lid,owner $t_fields from addressbook "
. $filtermethod,__LINE__,__FILE__); . $filtermethod,__LINE__,__FILE__);
$this->total_records = $this->db3->num_rows(); $this->total_records = $this->db3->num_rows();
$this->db->query("select id,lid,owner $t_fields from contacts " $this->db->query("select id,lid,owner $t_fields from addressbook "
. $filtermethod . " " . $ordermethod . " " . $this->db->limit($start,$offset),__LINE__,__FILE__); . $filtermethod . " " . $ordermethod . " " . $this->db->limit($start,$offset),__LINE__,__FILE__);
} }
@ -192,7 +192,7 @@
reset($ab_fieldnames); reset($ab_fieldnames);
} }
$this->db2->query("select contact_name,contact_value from contacts_extra where contact_id='" $this->db2->query("select contact_name,contact_value from addressbook_extra where contact_id='"
. $this->db->f("id") . "'",__LINE__,__FILE__); . $this->db->f("id") . "'",__LINE__,__FILE__);
while ($this->db2->next_record()) { while ($this->db2->next_record()) {
// If its not in the list to be returned, don't return it. // If its not in the list to be returned, don't return it.
@ -217,7 +217,7 @@
. ") values ('$owner','" . ") values ('$owner','"
. implode("','",$this->loop_addslashes($ab_fields)) . "')",__LINE__,__FILE__); . implode("','",$this->loop_addslashes($ab_fields)) . "')",__LINE__,__FILE__);
$this->db->query("select max(id) from contacts",__LINE__,__FILE__); $this->db->query("select max(id) from addressbook",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
$id = $this->db->f(0); $id = $this->db->f(0);
//$this->db->unlock(); //$this->db->unlock();
@ -232,7 +232,7 @@
function field_exists($id,$field_name) function field_exists($id,$field_name)
{ {
$this->db->query("select count(*) from contacts_extra where contact_id='$id' and contact_name='" $this->db->query("select count(*) from addressbook_extra where contact_id='$id' and contact_name='"
. addslashes($field_name) . "'",__LINE__,__FILE__); . addslashes($field_name) . "'",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
return $this->db->f(0); return $this->db->f(0);
@ -246,14 +246,14 @@
function delete_single_extra_field($id,$field_name) function delete_single_extra_field($id,$field_name)
{ {
$this->db->query("delete from contacts_extra where contact_id='$id' and contact_name='" $this->db->query("delete from addressbook_extra where contact_id='$id' and contact_name='"
. addslashes($field_name) . "'",__LINE__,__FILE__); . addslashes($field_name) . "'",__LINE__,__FILE__);
} }
function update($id,$owner,$fields) function update($id,$owner,$fields)
{ {
// First make sure that id number exists // First make sure that id number exists
$this->db->query("select count(*) from contacts where id='$id'",__LINE__,__FILE__); $this->db->query("select count(*) from addressbook where id='$id'",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
if (! $this->db->f(0)) { if (! $this->db->f(0)) {
return False; return False;
@ -290,9 +290,9 @@
// This is where the real work of delete() is done // This is where the real work of delete() is done
function delete_($id) function delete_($id)
{ {
$this->db->query("delete from contacts where owner='" . $this->account_id . "' and " $this->db->query("delete from addressbook where owner='" . $this->account_id . "' and "
. "id='$id'",__LINE__,__FILE__); . "id='$id'",__LINE__,__FILE__);
$this->db->query("delete from contacts_extra where contact_id='$id' and contact_owner='" $this->db->query("delete from addressbook_extra where contact_id='$id' and contact_owner='"
. $this->account_id . "'",__LINE__,__FILE__); . $this->account_id . "'",__LINE__,__FILE__);
} }