diff --git a/setup/createtables_mysql.inc.php b/setup/createtables_mysql.inc.php index 0de4ca6901..14459b96e2 100644 --- a/setup/createtables_mysql.inc.php +++ b/setup/createtables_mysql.inc.php @@ -11,199 +11,200 @@ /* $Id$ */ - $sql = "CREATE TABLE config (" - ."config_name varchar(25) NOT NULL," - ."config_value varchar(100)," - ."UNIQUE config_name (config_name)" - .")"; + $sql = "CREATE TABLE config ( + config_name varchar(25) NOT NULL, + config_value varchar(100), + UNIQUE config_name (config_name) + )"; $db->query($sql); - $sql = "CREATE TABLE applications (" - ."app_name varchar(25) NOT NULL," - ."app_title varchar(50)," - ."app_enabled int," - ."app_order int," - ."app_tables varchar(255)," - ."UNIQUE app_name (app_name)" - .")"; + $sql = "CREATE TABLE applications ( + app_name varchar(25) NOT NULL, + app_title varchar(50), + app_enabled int, + app_order int, + app_tables varchar(255), + app_version varchar(20) NOT NULL default '0.0', + UNIQUE app_name (app_name) + )"; $db->query($sql); - $sql = "CREATE TABLE accounts (" - ."account_id int(11) DEFAULT '0' NOT NULL auto_increment," - ."account_lid varchar(25) NOT NULL," - ."account_pwd varchar(32) NOT NULL," - ."account_firstname varchar(50)," - ."account_lastname varchar(50)," - ."account_permissions text," - ."account_groups varchar(30)," - ."account_lastlogin int(11)," - ."account_lastloginfrom varchar(255)," - ."account_lastpwd_change int(11)," - ."account_status enum('A','L') DEFAULT 'A' NOT NULL," - ."PRIMARY KEY (account_id)," - ."UNIQUE account_lid (account_lid)" - .")"; + $sql = "CREATE TABLE accounts ( + account_id int(11) DEFAULT '0' NOT NULL auto_increment, + account_lid varchar(25) NOT NULL, + account_pwd varchar(32) NOT NULL, + account_firstname varchar(50), + account_lastname varchar(50), + account_permissions text, + account_groups varchar(30), + account_lastlogin int(11), + account_lastloginfrom varchar(255), + account_lastpwd_change int(11), + account_status enum('A','L') DEFAULT 'A' NOT NULL, + PRIMARY KEY (account_id), + UNIQUE account_lid (account_lid) + )"; $db->query($sql); - $sql = "create table groups (" - ."group_id int NOT NULL auto_increment," - ."group_name varchar(255)," - ."group_apps varchar(255)," - ."primary key(group_id)" - .")"; + $sql = "create table groups ( + group_id int NOT NULL auto_increment, + group_name varchar(255), + group_apps varchar(255), + primary key(group_id) + )"; $db->query($sql); - $sql = "CREATE TABLE preferences (" - ."preference_owner varchar(20)," - ."preference_name varchar(50)," - ."preference_value varchar(50)," - ."preference_appname varchar(50)" - .")"; + $sql = "CREATE TABLE preferences ( + preference_owner varchar(20), + preference_name varchar(50), + preference_value varchar(50), + preference_appname varchar(50) + )"; $db->query($sql); - $sql = "CREATE TABLE sessions (" - ."session_id varchar(255) NOT NULL," - ."session_lid varchar(20)," - ."session_pwd varchar(255)," - ."session_ip varchar(255)," - ."session_logintime int(11)," - ."session_dla int(11)," - ."UNIQUE sessionid (session_id)" - .")"; + $sql = "CREATE TABLE sessions ( + session_id varchar(255) NOT NULL, + session_lid varchar(20), + session_pwd varchar(255), + session_ip varchar(255), + session_logintime int(11), + session_dla int(11), + UNIQUE sessionid (session_id) + )"; $db->query($sql); - $sql = "CREATE TABLE app_sessions (" - ."sessionid varchar(255) NOT NULL," - ."loginid varchar(20)," - ."app varchar(20)," - ."content text" - .")"; + $sql = "CREATE TABLE app_sessions ( + sessionid varchar(255) NOT NULL, + loginid varchar(20), + app varchar(20), + content text + )"; $db->query($sql); - $sql = "create table access_log (" - ."sessionid varchar(30)," - ."loginid varchar(30)," - ."ip varchar(30)," - ."li int," - ."lo int" - .")"; + $sql = "create table access_log ( + sessionid varchar(30), + loginid varchar(30), + ip varchar(30), + li int, + lo int + )"; $db->query($sql); - $sql = "CREATE TABLE profiles (" - ."con int(11) DEFAULT '0' NOT NULL auto_increment," - ."owner varchar(20)," - ."title varchar(255)," - ."phone_number varchar(255)," - ."comments text," - ."picture_format varchar(255)," - ."picture blob," - ."PRIMARY KEY (con)" - .")"; + $sql = "CREATE TABLE profiles ( + con int(11) DEFAULT '0' NOT NULL auto_increment, + owner varchar(20), + title varchar(255), + phone_number varchar(255), + comments text, + picture_format varchar(255), + picture blob, + PRIMARY KEY (con) + )"; $db->query($sql); - $sql = "CREATE TABLE addressbook (" - ."ab_id int(11) DEFAULT '0' NOT NULL auto_increment," - ."ab_owner varchar(25)," - ."ab_access varchar(10)," - ."ab_firstname varchar(255)," - ."ab_lastname varchar(255)," - ."ab_email varchar(255)," - ."ab_hphone varchar(255)," - ."ab_wphone varchar(255)," - ."ab_fax varchar(255)," - ."ab_pager varchar(255)," - ."ab_mphone varchar(255)," - ."ab_ophone varchar(255)," - ."ab_street varchar(255)," - ."ab_city varchar(255)," - ."ab_state varchar(255)," - ."ab_zip varchar(255)," - ."ab_bday varchar(255)," - ."ab_notes text," - ."ab_company varchar(255)," - ."PRIMARY KEY (ab_id)" - .")"; + $sql = "CREATE TABLE addressbook ( + ab_id int(11) DEFAULT '0' NOT NULL auto_increment, + ab_owner varchar(25), + ab_access varchar(10), + ab_firstname varchar(255), + ab_lastname varchar(255), + ab_email varchar(255), + ab_hphone varchar(255), + ab_wphone varchar(255), + ab_fax varchar(255), + ab_pager varchar(255), + ab_mphone varchar(255), + ab_ophone varchar(255), + ab_street varchar(255), + ab_city varchar(255), + ab_state varchar(255), + ab_zip varchar(255), + ab_bday varchar(255), + ab_notes text, + ab_company varchar(255), + PRIMARY KEY (ab_id) + )"; $db->query($sql); - $sql = "CREATE TABLE todo (" - ."todo_id int(11) DEFAULT '0' NOT NULL auto_increment," - ."todo_owner varchar(25)," - ."todo_access varchar(10)," - ."todo_des text," - ."todo_pri int(11)," - ."todo_status int(11)," - ."todo_datecreated int(11)," - ."todo_datedue int(11)," - ."PRIMARY KEY (todo_id)" - .")"; + $sql = "CREATE TABLE todo ( + todo_id int(11) DEFAULT '0' NOT NULL auto_increment, + todo_owner varchar(25), + todo_access varchar(10), + todo_des text, + todo_pri int(11), + todo_status int(11), + todo_datecreated int(11), + todo_datedue int(11), + PRIMARY KEY (todo_id) + )"; $db->query($sql); - $sql = "CREATE TABLE webcal_entry (" - ."cal_id int(11) DEFAULT '0' NOT NULL auto_increment," - ."cal_group_id int(11)," - ."cal_create_by varchar(25) NOT NULL," - ."cal_date int(11) DEFAULT '0' NOT NULL," - ."cal_time int(11)," - ."cal_mod_date int(11)," - ."cal_mod_time int(11)," - ."cal_duration int(11) DEFAULT '0' NOT NULL," - ."cal_priority int(11) DEFAULT '2'," - ."cal_type varchar(10)," - ."cal_access char(10)," - ."cal_name varchar(80) NOT NULL," - ."cal_description text," - ."PRIMARY KEY (cal_id)" - .")"; + $sql = "CREATE TABLE webcal_entry ( + cal_id int(11) DEFAULT '0' NOT NULL auto_increment, + cal_group_id int(11), + cal_create_by varchar(25) NOT NULL, + cal_date int(11) DEFAULT '0' NOT NULL, + cal_time int(11), + cal_mod_date int(11), + cal_mod_time int(11), + cal_duration int(11) DEFAULT '0' NOT NULL, + cal_priority int(11) DEFAULT '2', + cal_type varchar(10), + cal_access char(10), + cal_name varchar(80) NOT NULL, + cal_description text, + PRIMARY KEY (cal_id) + )"; $db->query($sql); - $sql = "CREATE TABLE webcal_entry_repeats (" - ."cal_id int(11) DEFAULT '0' NOT NULL," - ."cal_type enum('daily','weekly','monthlyByDay','monthlyByDate','yearly') DEFAULT 'daily' NOT NULL," - ."cal_end int(11)," - ."cal_frequency int(11) DEFAULT '1'," - ."cal_days char(7)" - .")"; + $sql = "CREATE TABLE webcal_entry_repeats ( + cal_id int(11) DEFAULT '0' NOT NULL, + cal_type enum('daily','weekly','monthlyByDay','monthlyByDate','yearly') DEFAULT 'daily' NOT NULL, + cal_end int(11), + cal_frequency int(11) DEFAULT '1', + cal_days char(7) + )"; $db->query($sql); - $sql = "CREATE TABLE webcal_entry_user (" - ."cal_id int(11) DEFAULT '0' NOT NULL," - ."cal_login varchar(25) NOT NULL," - ."cal_status char(1) DEFAULT 'A'," - ."PRIMARY KEY (cal_id, cal_login)" - .")"; + $sql = "CREATE TABLE webcal_entry_user ( + cal_id int(11) DEFAULT '0' NOT NULL, + cal_login varchar(25) NOT NULL, + cal_status char(1) DEFAULT 'A', + PRIMARY KEY (cal_id, cal_login) + )"; $db->query($sql); - $sql = "create table webcal_entry_groups (" - ."cal_id int," - ."groups varchar(255)" - .")"; + $sql = "create table webcal_entry_groups ( + cal_id int, + groups varchar(255) + )"; $db->query($sql); - $sql = "CREATE TABLE newsgroups (" - ."con int(11) NOT NULL auto_increment," - ."name varchar(255) NOT NULL," - ."messagecount int(11) NOT NULL," - ."lastmessage int(11) NOT NULL," - ."active char DEFAULT 'N' NOT NULL," - ."lastread int(11)," - ."PRIMARY KEY (con)," - ."UNIQUE name (name)" - .")"; + $sql = "CREATE TABLE newsgroups ( + con int(11) NOT NULL auto_increment, + name varchar(255) NOT NULL, + messagecount int(11) NOT NULL, + lastmessage int(11) NOT NULL, + active char DEFAULT 'N' NOT NULL, + lastread int(11), + PRIMARY KEY (con), + UNIQUE name (name) + )"; $db->query($sql); - $sql = "CREATE TABLE users_newsgroups (" - ."owner int(11) NOT NULL," - ."newsgroup int(11) NOT NULL" - .")"; + $sql = "CREATE TABLE users_newsgroups ( + owner int(11) NOT NULL, + newsgroup int(11) NOT NULL + )"; $db->query($sql); - $sql = "CREATE TABLE lang (" - ."message_id varchar(150) DEFAULT '' NOT NULL," - ."app_name varchar(100) DEFAULT 'common' NOT NULL," - ."lang varchar(5) DEFAULT '' NOT NULL," - ."content text NOT NULL," - ."PRIMARY KEY (message_id,app_name,lang)" - .")"; + $sql = "CREATE TABLE lang ( + message_id varchar(150) DEFAULT '' NOT NULL, + app_name varchar(100) DEFAULT 'common' NOT NULL, + lang varchar(5) DEFAULT '' NOT NULL, + content text NOT NULL, + PRIMARY KEY (message_id,app_name,lang) + )"; $db->query($sql); ?> \ No newline at end of file diff --git a/setup/createtables_pgsql.inc.php b/setup/createtables_pgsql.inc.php index 6f4575309d..37931a8cf9 100644 --- a/setup/createtables_pgsql.inc.php +++ b/setup/createtables_pgsql.inc.php @@ -25,6 +25,7 @@ app_enabled int, app_order int, app_tables varchar(255), + app_version varchar(20) NOT NULL default '0.0', unique(app_name) )"; $db->query($sql); diff --git a/setup/default_records.inc.php b/setup/default_records.inc.php index d9ee3ef1cf..b0a9d4e833 100644 --- a/setup/default_records.inc.php +++ b/setup/default_records.inc.php @@ -12,7 +12,7 @@ /* $Id$ */ function add_default_server_config(){ - global $db; + global $db, $newversion; $db->query("insert into config (config_name, config_value) values ('default_tplset', 'default')"); $db->query("insert into config (config_name, config_value) values ('temp_dir', '/path/to/tmp')"); $db->query("insert into config (config_name, config_value) values ('files_dir', '/path/to/dir/phpgroupware/files')"); @@ -94,18 +94,18 @@ }else{ add_default_server_config(); } - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('admin', 'Administration', 1, 1, NULL)"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('tts', 'Trouble Ticket System', 0, 2, NULL)"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('inv', 'Inventory', 0, 3, NULL)"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('chat', 'Chat', 0, 4, NULL)"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('headlines', 'Headlines', 0, 5, 'news_sites,news_headlines,users_headlines')"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('filemanager', 'File manager', 1, 6, NULL)"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('addressbook', 'Address Book', 1, 7, 'addressbook')"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('todo', 'ToDo List', 1, 8, 'todo')"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('calendar', 'Calendar', 1, 9, 'webcal_entry,webcal_entry_users,webcal_entry_groups,webcal_repeats')"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('email', 'Email', 1, 10,NULL)"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('nntp', 'NNTP', 1, 11, 'newsgroups,users_newsgroups')"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables) values ('cron_apps', 'cron_apps', 0, 0, NULL)"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('admin', 'Administration', 1, 1, NULL, '$newversion')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('tts', 'Trouble Ticket System', 0, 2, NULL, '0.0.0')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('inv', 'Inventory', 0, 3, NULL, '0.0.0')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('chat', 'Chat', 0, 4, NULL, '0.0.0')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('headlines', 'Headlines', 0, 5, 'news_sites,news_headlines,users_headlines', '0.0.0')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('filemanager', 'File manager', 1, 6, NULL, '$newversion')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('addressbook', 'Address Book', 1, 7, 'addressbook', '$newversion')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('todo', 'ToDo List', 1, 8, 'todo', '$newversion')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('calendar', 'Calendar', 1, 9, 'webcal_entry,webcal_entry_users,webcal_entry_groups,webcal_repeats', '$newversion')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('email', 'Email', 1, 10,NULL, '$newversion')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('nntp', 'NNTP', 1, 11, 'newsgroups,users_newsgroups', '$newversion')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('cron_apps', 'cron_apps', 0, 0, NULL, '$newversion')"); $db->query("insert into accounts (account_lid,account_pwd,account_firstname,account_lastname,account_permissions,account_groups,account_status) values ('demo','81dc9bdb52d04dc20036dbd8313ed055','Demo','Account',':admin:email:todo:addressbook:calendar:',',1,','A')"); diff --git a/setup/index.php b/setup/index.php index 7060d77943..da011fa6d8 100644 --- a/setup/index.php +++ b/setup/index.php @@ -11,6 +11,9 @@ /* $Id$ */ + /* !!! This needs to be changed each time we do an update !!! */ + $newversion = "0.9.1"; + $phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True, "currentapp" => "home", "noapi" => True); include("../header.inc.php"); @@ -109,10 +112,12 @@ echo " \n"; echo " At your request, this script is going to take the evil action of dropping your existing tables and re-creating them in the new format.\n"; echo " \n"; + $db->Halt_On_Error = "report"; include ("droptables_".$phpgw_info["server"]["db_type"].".inc.php"); include ("createtables_".$phpgw_info["server"]["db_type"].".inc.php"); include ("default_records.inc.php"); include ("lang_records.inc.php"); + $db->Halt_On_Error = "no"; echo " \n"; echo "  Status\n"; echo " \n"; @@ -134,9 +139,11 @@ echo " \n"; echo "\n"; $currentver = $oldversion; + $db->Halt_On_Error = "report"; include ("upgradetables_".$phpgw_info["server"]["db_type"].".inc.php"); // include ("default_records.inc.php"); include ("lang_records.inc.php"); + $db->Halt_On_Error = "no"; echo "\n"; echo " \n"; echo " \n"; @@ -161,9 +168,11 @@ echo " \n"; echo " \n"; echo " \n"; + $db->Halt_On_Error = "report"; include ("createtables_".$phpgw_info["server"]["db_type"].".inc.php"); include ("default_records.inc.php"); include ("lang_records.inc.php"); + $db->Halt_On_Error = "no"; echo " \n"; echo " \n"; echo " \n"; @@ -192,4 +201,4 @@ echo ""; //db->disconnect(); -?> +?> \ No newline at end of file diff --git a/setup/upgradetables_mysql.inc.php b/setup/upgradetables_mysql.inc.php index 959feacff1..30a33a3070 100644 --- a/setup/upgradetables_mysql.inc.php +++ b/setup/upgradetables_mysql.inc.php @@ -94,7 +94,7 @@ } } function v9072000to0_9_1(){ - global $currentver, $db; + global $currentver, $newversion, $db; if ($currentver == "9072000"){ $db->query("alter table accounts change con account_id int(11) DEFAULT '0' NOT NULL auto_increment"); @@ -108,8 +108,9 @@ $db->query("alter table accounts change lastloginfrom account_lastloginfrom varchar(255)"); $db->query("alter table accounts change lastpasswd_change account_lastpwd_change int(11)"); $db->query("alter table accounts change status account_status enum('A','L') DEFAULT 'A' NOT NULL"); - $db->query("alter table applications add app_order int"); - $db->query("alter table applications add app_tables varchar(255)"); + $db->query("alter table applications add app_order int"); + $db->query("alter table applications add app_tables varchar(255)"); + $db->query("alter table applications add app_version varchar(20) not null default '0.0'"); $db->query("alter table preferences change owner preference_owner varchar(20)"); $db->query("alter table preferences change name preference_name varchar(50)"); $db->query("alter table preferences change value preference_value varchar(50)"); @@ -133,7 +134,6 @@ $db->query("update applications set app_order=10,app_tables=NULL where app_name='email'"); $db->query("update applications set app_order=11,app_tables='newsgroups,users_newsgroups' where app_name='nntp'"); $db->query("update applications set app_order=0,app_tables=NULL where app_name='cron_apps'"); - $sql = "CREATE TABLE config (" ."config_name varchar(25) NOT NULL," ."config_value varchar(100)," @@ -190,5 +190,7 @@ v8212000to9052000(); v9052000to9072000(); v9072000to0_9_1(); + $db->query("update applications set app_version='$newversion' where (app_name='admin' or app_name='filemanager' or app_name='addressbook' or app_name='todo' or app_name='calendar' or app_name='email' or app_name='nntp' or app_name='cron_apps')"); + echo "
 Status
You appear to be running a new install of phpGroupWare, so the tables will be created for you.
 Status
\n"; ?> \ No newline at end of file