Translation for privatemsg.module, version 4.7.0
[project/privatemsg.git] / privatemsg.install
CommitLineData
738b232d
AH
1<?php
2// $Id$
3
4function privatemsg_install() {
5 switch ($GLOBALS['db_type']) {
6 case 'mysql':
7 case 'mysqli':
8 db_query("CREATE TABLE {privatemsg} (
9 id int(10) unsigned NOT NULL auto_increment primary key,
10 author int(10) unsigned NOT NULL,
11 recipient int(10) unsigned NOT NULL,
12 subject varchar(64) NOT NULL,
13 message text NOT NULL,
14 timestamp int(11) unsigned NOT NULL,
15 newmsg tinyint unsigned NOT NULL,
16 hostname varchar(255) NOT NULL,
3f493a4c 17 folder int(10) unsigned NOT NULL DEFAULT '0',
738b232d
AH
18 author_del tinyint unsigned NOT NULL,
19 recipient_del tinyint unsigned NOT NULL,
ed597204 20 format int(4) NOT NULL DEFAULT '0',
738b232d
AH
21 key (recipient),
22 key (folder)
23 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
24 db_query("CREATE TABLE {privatemsg_folder} (
25 fid int(10) unsigned NOT NULL auto_increment primary key,
26 uid int(10) unsigned NOT NULL,
27 name varchar(255) NOT NULL
28 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
29 // Sent messages
30 db_query("INSERT INTO {privatemsg_folder} VALUES (1, 0, 'Sent')");
31 db_query("CREATE TABLE {privatemsg_archive} (
32 id int(10) unsigned NOT NULL auto_increment primary key,
33 author int(10) unsigned NOT NULL,
34 recipient int(10) unsigned NOT NULL,
35 subject VARCHAR(64) NOT NULL,
36 message text NOT NULL,
37 timestamp int(11) unsigned NOT NULL,
38 hostname varchar(255) NOT NULL,
39 folder int(10) unsigned NOT NULL,
ed597204 40 format int(4) NOT NULL DEFAULT '0',
738b232d
AH
41 key (recipient)
42 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
43 break;
44 case 'pgsql':
45 db_query("CREATE TABLE {privatemsg} (
46 id SERIAL,
47 author integer NOT NULL,
48 recipient integer NOT NULL,
49 subject varchar(64) NOT NULL,
50 message text NOT NULL,
51 timestamp integer NOT NULL,
52 newmsg smallint NOT NULL,
53 hostname varchar(255) NOT NULL,
54 format smallint NOT NULL DEFAULT '0',
55 folder integer NOT NULL DEFAULT '0',
56 author_del smallint NOT NULL DEFAULT '0',
57 recipient_del smallint NOT NULL DEFAULT '0',
58 PRIMARY KEY (id)
59 )");
60 db_query("CREATE INDEX {privatemsg_folder_index} ON {privatemsg}(folder)");
61 db_query("CREATE TABLE {privatemsg_folder} (
62 fid SERIAL,
63 uid integer NOT NULL,
64 name varchar(255) not null,
65 PRIMARY KEY (fid)
66 )");
67 db_query("INSERT INTO {privatemsg_folder} (uid, name) VALUES (0, 'Sent')");
68 db_query("CREATE TABLE {privatemsg_archive} (
69 id SERIAL,
70 author integer NOT NULL,
71 recipient integer NOT NULL,
72 subject varchar(64) NOT NULL,
73 message text NOT NULL,
74 timestamp integer NOT NULL,
75 hostname varchar(255) NOT NULL,
76 format smallint NOT NULL DEFAULT '0',
77 folder integer NOT NULL,
78 PRIMARY KEY (id)
79 )");
80 db_query("CREATE INDEX {privatemsg_archive_recipient} ON {privatemsg_archive}(recipient)");
81 db_query("create or replace function unix_timestamp(timestamp with time zone)
82 returns int as '
83 declare
84 date alias for " .'$1'. ";
85 timezero timestamp;
86 offset interval;
87 begin
88 timezero := timestamp ''1970-1-1 00:00'' at time zone ''utc'';
89 offset := date-timezero;
90
91 return (extract(''days'' from offset)*86400+
92 extract(''hours'' from offset)*3600+
93 extract(''minutes'' from offset)*60+
94 extract(''seconds'' from offset))::int;
95 end;
96 ' language 'plpgsql'");
97 db_query("create or replace function unix_timestamp(timestamp without time zone)
98 returns int as '
99 declare
100 date alias for " .'$1'. ";
101 timezero timestamp;
102 offset interval;
103 begin
104 timezero := timestamp ''1970-1-1 00:00'' at time zone ''utc'';
105 offset := date-timezero;
106
107 return (extract(''days'' from offset)*86400+
108 extract(''hours'' from offset)*3600+
109 extract(''minutes'' from offset)*60+
110 extract(''seconds'' from offset))::int;
111 end;
112 ' language 'plpgsql'");
113 break;
114 }
115}
116
117/* Upgrade on mysql from versions before 22-May-2003:
118 Create privatemsg_archive/privatemsg_folder tables and insert one row, shown above^
119 ALTER TABLE privatemsg ADD folder int(10) unsigned NOT NULL;
120 ALTER TABLE privatemsg ADD author_del tinyint unsigned NOT NULL;
121 ALTER TABLE privatemsg ADD recipient_del tinyint unsigned NOT NULL;
122 ALTER TABLE privatemsg ADD INDEX(folder);
123 ALTER TABLE privatemsg CHANGE hostname hostname varchar(255) NOT NULL;
124 Continue with steps below, but skip ALTER line for privatemsg_archive..
125 *
126 * Upgrade on mysql from versions before 29-Apr-2005:
127 ALTER TABLE privatemsg CHANGE new newmsg tinyint UNSIGNED NOT NULL;
128 ALTER TABLE privatemsg ADD format int(4) NOT NULL DEFAULT '0';
129 ALTER TABLE privatemsg_archive ADD format int(4) NOT NULL DEFAULT '0';
130 UPDATE privatemsg SET format=1;
131 UPDATE privatemsg_archive SET format=1;
132 */
133
134function privatemsg_update_1() {
135 return _system_update_utf8(array('privatemsg', 'privatemsg_archive', 'privatemsg_folder'));
136}
137?>