Contacts class upgrade

This commit is contained in:
Miles Lott 2001-03-16 01:33:15 +00:00
parent 0eedd1ffc3
commit 21d4d7319d
5 changed files with 291 additions and 126 deletions

View File

@ -104,73 +104,74 @@
$phpgw_setup->db->query($sql);
$sql = "CREATE TABLE phpgw_addressbook (
id int(8) NOT NULL auto_increment,
lid varchar(32),
tid char(1),
owner int(8),
fn varchar(64),
n_family varchar(64),
n_given varchar(64),
n_middle varchar(64),
n_prefix varchar(64),
n_suffix varchar(64),
sound varchar(64),
bday varchar(32),
note text,
tz varchar(8),
geo varchar(32),
url varchar(128),
pubkey text,
org_name varchar(64),
org_unit varchar(64),
title varchar(64),
adr_one_street varchar(64),
adr_one_locality varchar(32),
adr_one_region varchar(32),
adr_one_postalcode varchar(32),
adr_one_countryname varchar(32),
adr_one_type varchar(64),
label text,
adr_two_street varchar(64),
adr_two_locality varchar(32),
adr_two_region varchar(32),
adr_two_postalcode varchar(32),
adr_two_countryname varchar(32),
adr_two_type varchar(64),
tel_work varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_home varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_voice varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_fax varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_msg varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_cell varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_pager varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_bbs varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_modem varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_car varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_isdn varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_video varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_prefer varchar(32),
email varchar(64),
email_type varchar(32) DEFAULT 'INTERNET' NOT NULL,
email_home varchar(64),
email_home_type varchar(32) DEFAULT 'INTERNET' NOT NULL,
PRIMARY KEY (id),
UNIQUE id (id)
)";
id int(8) PRIMARY KEY DEFAULT '0' NOT NULL auto_increment,
lid varchar(32),
tid char(1),
owner int(8),
fn varchar(64),
sound varchar(64),
org_name varchar(64),
org_unit varchar(64),
title varchar(64),
n_family varchar(64),
n_given varchar(64),
n_middle varchar(64),
n_prefix varchar(64),
n_suffix varchar(64),
label text,
adr_poaddr varchar(64),
adr_extaddr varchar(64),
adr_street varchar(64),
adr_locality varchar(32),
adr_region varchar(32),
adr_postalcode varchar(32),
adr_countryname varchar(32),
adr_work char(1) DEFAULT 'n' NOT NULL,
adr_home char(1) DEFAULT 'n' NOT NULL,
adr_parcel char(1) DEFAULT 'n' NOT NULL,
adr_postal char(1) DEFAULT 'n' NOT NULL,
tz varchar(8),
geo varchar(32),
url varchar(128),
bday varchar(32),
note text,
a_tel varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
a_tel_work char(1) DEFAULT 'n' NOT NULL,
a_tel_home char(1) DEFAULT 'n' NOT NULL,
a_tel_voice char(1) DEFAULT 'n' NOT NULL,
a_tel_msg char(1) DEFAULT 'n' NOT NULL,
a_tel_fax char(1) DEFAULT 'n' NOT NULL,
a_tel_prefer char(1) DEFAULT 'n' NOT NULL,
b_tel varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
b_tel_work char(1) DEFAULT 'n' NOT NULL,
b_tel_home char(1) DEFAULT 'n' NOT NULL,
b_tel_voice char(1) DEFAULT 'n' NOT NULL,
b_tel_msg char(1) DEFAULT 'n' NOT NULL,
b_tel_fax char(1) DEFAULT 'n' NOT NULL,
b_tel_prefer char(1) DEFAULT 'n' NOT NULL,
c_tel varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
c_tel_work char(1) DEFAULT 'n' NOT NULL,
c_tel_home char(1) DEFAULT 'n' NOT NULL,
c_tel_voice char(1) DEFAULT 'n' NOT NULL,
c_tel_msg char(1) DEFAULT 'n' NOT NULL,
c_tel_fax char(1) DEFAULT 'n' NOT NULL,
c_tel_prefer char(1) DEFAULT 'n' NOT NULL,
d_emailtype enum('INTERNET','CompuServe','AOL','Prodigy','eWorld','AppleLink','AppleTalk','PowerShare','IBMMail','ATTMail','MCIMail','X.400','TLX') NOT NULL,
d_email varchar(64),
d_email_work char(1) DEFAULT 'n' NOT NULL,
d_email_home char(1) DEFAULT 'n' NOT NULL,
UNIQUE (id)
)";
$phpgw_setup->db->query($sql);
$sql = "CREATE TABLE phpgw_addressbook_extra (
contact_id int(11),
contact_owner int(11),
contact_name varchar(255),
contact_value text
)";
$sql = "CREATE TABLE phpgw_addressbook_extra (
contact_id int(11),
contact_owner int(11),
contact_name varchar(255),
contact_value text
)";
$phpgw_setup->db->query($sql);
@ -335,7 +336,7 @@
);";
$phpgw_setup->db->query($sql);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre16';
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre17';
$phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi'];
update_version_table();
// $phpgw_setup->update_version_table();

View File

@ -1254,6 +1254,54 @@
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre16';
}
$test[] = '0.9.10pre16';
function upgrade0_9_10pre16() {
global $phpgw_info, $phpgw_setup;
$db1 = $phpgw_setup->db;
$phpgw_setup->db->query("alter table phpgw_addressbook add pubkey text");
$phpgw_setup->db->query("alter table phpgw_addressbook change a_tel tel_work varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change b_tel tel_home varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change c_tel tel_fax varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change a_tel_work tel_msg varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change a_tel_home tel_cell varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change a_tel_voice tel_voice varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change a_tel_msg tel_pager varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change a_tel_fax tel_bbs varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change b_tel_work tel_modem varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change b_tel_home tel_car varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change b_tel_voice tel_isdn varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change b_tel_msg tel_video varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change a_tel_prefer tel_prefer varchar(32)");
$phpgw_setup->db->query("alter table phpgw_addressbook change d_email email varchar(64)");
$phpgw_setup->db->query("alter table phpgw_addressbook change d_email_tyoe email_type varchar(32) DEFAULT 'INTERNET' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook change d_email_work email_home varchar(64)");
$phpgw_setup->db->query("alter table phpgw_addressbook change d_email_home email_home_type varchar(32) DEFAULT 'INTERNET' NOT NULL");
$phpgw_setup->db->query("alter table phpgw_addressbook drop b_tel_prefer");
$phpgw_setup->db->query("alter table phpgw_addressbook drop c_tel_prefer");
$phpgw_setup->db->query("alter table phpgw_addressbook drop b_tel_fax");
$phpgw_setup->db->query("alter table phpgw_addressbook drop c_tel_work");
$phpgw_setup->db->query("alter table phpgw_addressbook drop c_tel_home");
$phpgw_setup->db->query("alter table phpgw_addressbook drop c_tel_voice");
$phpgw_setup->db->query("alter table phpgw_addressbook drop c_tel_msg");
$phpgw_setup->db->query("alter table phpgw_addressbook drop c_tel_fax");
$sql = "SELECT * FROM phpgw_addressbook_extra WHERE contact_name='mphone'";
$phpgw_setup->db->query($sql,__LINE__,__FILE__);
while($phpgw_setup->db->next_record()) {
$cid = $phpgw_setup->db->f("contact_id");
$cvalu = $phpgw_setup->db->f("contact_value");
if ($cvalu) {
$update = "UPDATE phpgw_addressbook set tel_cell=" . $cvalu . " WHERE id=" . $cid;
$db1->query($update);
$delete = "DELETE FROM phpgw_addressbook_extra WHERE contact_id=" . $cid . " AND contact_name='url'";
$db1->query($delete);
}
}
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre17';
}
reset ($test);
while (list ($key, $value) = each ($test)){
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {

View File

@ -101,66 +101,66 @@
)";
$phpgw_setup->db->query($sql);
$sql = "create table phpgw_addressbook (
$sql = "CREATE TABLE phpgw_addressbook (
id int(8) NOT NULL auto_increment,
lid varchar(32),
tid char(1),
owner int(8),
id serial,
lid varchar(32),
tid char(1),
owner int,
fn varchar(64),
sound varchar(64),
org_name varchar(64),
org_unit varchar(64),
title varchar(64),
n_family varchar(64),
n_given varchar(64),
n_middle varchar(64),
n_prefix varchar(64),
n_suffix varchar(64),
label text,
adr_poaddr varchar(64),
adr_extaddr varchar(64),
adr_street varchar(64),
adr_locality varchar(32),
adr_region varchar(32),
adr_postalcode varchar(32),
adr_countryname varchar(32),
adr_work char(1) DEFAULT 'n' NOT NULL,
adr_home char(1) DEFAULT 'n' NOT NULL,
adr_parcel char(1) DEFAULT 'n' NOT NULL,
adr_postal char(1) DEFAULT 'n' NOT NULL,
tz varchar(8),
geo varchar(32),
url varchar(128),
bday varchar(32),
note text,
a_tel varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
a_tel_work char(1) DEFAULT 'n' NOT NULL,
a_tel_home char(1) DEFAULT 'n' NOT NULL,
a_tel_voice char(1) DEFAULT 'n' NOT NULL,
a_tel_msg char(1) DEFAULT 'n' NOT NULL,
a_tel_fax char(1) DEFAULT 'n' NOT NULL,
a_tel_prefer char(1) DEFAULT 'n' NOT NULL,
b_tel varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
b_tel_work char(1) DEFAULT 'n' NOT NULL,
b_tel_home char(1) DEFAULT 'n' NOT NULL,
b_tel_voice char(1) DEFAULT 'n' NOT NULL,
b_tel_msg char(1) DEFAULT 'n' NOT NULL,
b_tel_fax char(1) DEFAULT 'n' NOT NULL,
b_tel_prefer char(1) DEFAULT 'n' NOT NULL,
c_tel varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
c_tel_work char(1) DEFAULT 'n' NOT NULL,
c_tel_home char(1) DEFAULT 'n' NOT NULL,
c_tel_voice char(1) DEFAULT 'n' NOT NULL,
c_tel_msg char(1) DEFAULT 'n' NOT NULL,
c_tel_fax char(1) DEFAULT 'n' NOT NULL,
c_tel_prefer char(1) DEFAULT 'n' NOT NULL,
d_emailtype text check(d_emailtype in('INTERNET','CompuServe','AOL','Prodigy','eWorld','AppleLink','AppleTalk','PowerShare','IBMMail','ATTMail','MCIMail','X.400','TLX')) DEFAULT 'INTERNET' NOT NULL,
d_email varchar(64),
d_email_work char(1) DEFAULT 'n' NOT NULL,
d_email_home char(1) DEFAULT 'n' NOT NULL,
UNIQUE (id)
)";
fn varchar(64),
n_family varchar(64),
n_given varchar(64),
n_middle varchar(64),
n_prefix varchar(64),
n_suffix varchar(64),
sound varchar(64),
bday varchar(32),
note text,
tz varchar(8),
geo varchar(32),
url varchar(128),
pubkey text,
org_name varchar(64),
org_unit varchar(64),
title varchar(64),
adr_one_street varchar(64),
adr_one_locality varchar(32),
adr_one_region varchar(32),
adr_one_postalcode varchar(32),
adr_one_countryname varchar(32),
adr_one_type varchar(64),
label text,
adr_two_street varchar(64),
adr_two_locality varchar(32),
adr_two_region varchar(32),
adr_two_postalcode varchar(32),
adr_two_countryname varchar(32),
adr_two_type varchar(64),
tel_work varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_home varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_voice varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_fax varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_msg varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_cell varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_pager varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_bbs varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_modem varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_car varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_isdn varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_video varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_prefer varchar(32),
email varchar(64),
email_type varchar(32) DEFAULT 'INTERNET',
email_home varchar(64),
email_home_type varchar(32) DEFAULT 'INTERNET',
PRIMARY KEY (id),
UNIQUE id (id)
)";
$phpgw_setup->db->query($sql);
@ -311,7 +311,7 @@
);";
$phpgw_setup->db->query($sql);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre16';
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre17';
$phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi'];
update_version_table();
?>

View File

@ -1447,6 +1447,122 @@
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre16';
}
$test[] = '0.9.10pre16';
function upgrade0_9_10pre16() {
global $phpgw_info, $phpgw_setup;
$db1 = $phpgw_setup->db;
$sql="CREATE TABLE phpgw_addressbook_temp (
id int(8) NOT NULL auto_increment,
lid varchar(32),
tid char(1),
owner int(8),
fn varchar(64),
n_family varchar(64),
n_given varchar(64),
n_middle varchar(64),
n_prefix varchar(64),
n_suffix varchar(64),
sound varchar(64),
bday varchar(32),
note text,
tz varchar(8),
geo varchar(32),
url varchar(128),
pubkey text,
org_name varchar(64),
org_unit varchar(64),
title varchar(64),
adr_one_street varchar(64),
adr_one_locality varchar(32),
adr_one_region varchar(32),
adr_one_postalcode varchar(32),
adr_one_countryname varchar(32),
adr_one_type varchar(64),
label text,
adr_two_street varchar(64),
adr_two_locality varchar(32),
adr_two_region varchar(32),
adr_two_postalcode varchar(32),
adr_two_countryname varchar(32),
adr_two_type varchar(64),
tel_work varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_home varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_voice varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_fax varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_msg varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_cell varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_pager varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_bbs varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_modem varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_car varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_isdn varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_video varchar(40) DEFAULT '+1 (000) 000-0000' NOT NULL,
tel_prefer varchar(32),
email varchar(64),
email_type varchar(32) DEFAULT 'INTERNET',
email_home varchar(64),
email_home_type varchar(32) DEFAULT 'INTERNET',
PRIMARY KEY (id),
UNIQUE id (id)
)";
$phpgw_setup->db->query($sql);
$phpgw_setup->db->query("SELECT * FROM phpgw_addressbook");
while ($phpgw_setup->db->next_record()) {
$fields['id'] = $phpgw_setup->db->f("id");
$fields['owner'] = $phpgw_setup->db->f("owner");
$fields['n_given'] = $phpgw_setup->db->f("firstname");
$fields['n_family'] = $phpgw_setup->db->f("lastname");
$fields['email'] = $phpgw_setup->db->f("d_email");
$fields['email_type'] = $phpgw_setup->db->f("d_email_type");
$fields['tel_home'] = $phpgw_setup->db->f("hphone");
$fields['tel_work'] = $phpgw_setup->db->f("wphone");
$fields['tel_fax'] = $phpgw_setup->db->f("fax");
$fields['fn'] = $phpgw_setup->db->f("fn");
$fields['org_name'] = $phpgw_setup->db->f("org_name");
$fields['title'] = $phpgw_setup->db->f("title");
$fields['adr_one_street'] = $phpgw_setup->db->f("adr_street");
$fields['adr_one_locality'] = $phpgw_setup->db->f("adr_locality");
$fields['adr_one_region'] = $phpgw_setup->db->f("adr_region");
$fields['adr_one_postalcode'] = $phpgw_setup->db->f("adr_postalcode");
$fields['adr_one_countryname'] = $phpgw_setup->db->f("adr_countryname");
$fields['bday'] = $phpgw_setup->db->f("bday");
$fields['note'] = $phpgw_setup->db->f("note");
$fields['url'] = $phpgw_setup->db->f("url");
$sql="INSERT INTO phpgw_addressbook_temp (org_name,n_given,n_family,fn,email,email_type,title,tel_work,"
. "tel_home,tel_fax,adr_one_street,adr_one_locality,adr_one_region,adr_one_postalcode,adr_one_countryname,"
. "owner,bday,url,note)"
. " VALUES ('".$fields["org_name"]."','".$fields["n_given"]."','".$fields["n_family"]."','"
. $fields["fn"]."','".$fields["email"]."','".$fields["email_type"]."','".$fields["title"]."','".$fields["tel_work"]."','"
. $fields["tel_home"]."','".$fields["tel_fax"] ."','".$fields["adr_one_street"]."','"
. $fields["adr_one_locality"]."','".$fields["adr_one_region"]."','".$fields["adr_one_postalcode"]."','"
. $fields["adr_one_countryname"]."','".$fields["owner"] ."','".$fields["bday"]."','".$fields["url"]."','".$fields["note"]."')";
$db1->query($sql,__LINE__,__FILE__);
}
$phpgw_setup->db->query("DROP TABLE phpgw_addressbook");
$phpgw_setup->db->query("ALTER TABLE phpgw_addressbook_temp RENAME TO phpgw_addressbook",__LINE__,__FILE__);
$sql = "SELECT * FROM phpgw_addressbook_extra WHERE contact_name='mphone'";
$phpgw_setup->db->query($sql,__LINE__,__FILE__);
while($phpgw_setup->db->next_record()) {
$cid = $phpgw_setup->db->f("contact_id");
$cvalu = $phpgw_setup->db->f("contact_value");
if ($cvalu) {
$update = "UPDATE phpgw_addressbook set tel_cell=" . $cvalu . " WHERE id=" . $cid;
$db1->query($update);
$delete = "DELETE FROM phpgw_addressbook_extra WHERE contact_id=" . $cid . " AND contact_name='url'";
$db1->query($delete);
}
}
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre17';
}
reset ($test);
while (list ($key, $value) = each ($test)){
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {

View File

@ -11,5 +11,5 @@
/* $Id$ */
$phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.10pre16";
$phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.10pre17";
$phpgw_info["server"]["versions"]["current_header"] = "1.11";