1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Implementation of hook_schema(). |
---|
5 | */ |
---|
6 | function user_schema() { |
---|
7 | $schema['access'] = array( |
---|
8 | 'description' => 'Stores site access rules.', |
---|
9 | 'fields' => array( |
---|
10 | 'aid' => array( |
---|
11 | 'type' => 'serial', |
---|
12 | 'not null' => TRUE, |
---|
13 | 'description' => 'Primary Key: Unique access ID.', |
---|
14 | ), |
---|
15 | 'mask' => array( |
---|
16 | 'type' => 'varchar', |
---|
17 | 'length' => 255, |
---|
18 | 'not null' => TRUE, |
---|
19 | 'default' => '', |
---|
20 | 'description' => 'Text mask used for filtering access.', |
---|
21 | ), |
---|
22 | 'type' => array( |
---|
23 | 'type' => 'varchar', |
---|
24 | 'length' => 255, |
---|
25 | 'not null' => TRUE, |
---|
26 | 'default' => '', |
---|
27 | 'description' => 'Type of access rule: name, mail or host.', |
---|
28 | ), |
---|
29 | 'status' => array( |
---|
30 | 'type' => 'int', |
---|
31 | 'not null' => TRUE, |
---|
32 | 'default' => 0, |
---|
33 | 'size' => 'tiny', |
---|
34 | 'description' => 'Whether rule is to allow(1) or deny(0) access.', |
---|
35 | ), |
---|
36 | ), |
---|
37 | 'primary key' => array('aid'), |
---|
38 | ); |
---|
39 | |
---|
40 | $schema['authmap'] = array( |
---|
41 | 'description' => 'Stores distributed authentication mapping.', |
---|
42 | 'fields' => array( |
---|
43 | 'aid' => array( |
---|
44 | 'description' => 'Primary Key: Unique authmap ID.', |
---|
45 | 'type' => 'serial', |
---|
46 | 'unsigned' => TRUE, |
---|
47 | 'not null' => TRUE, |
---|
48 | ), |
---|
49 | 'uid' => array( |
---|
50 | 'type' => 'int', |
---|
51 | 'not null' => TRUE, |
---|
52 | 'default' => 0, |
---|
53 | 'description' => "User's {users}.uid.", |
---|
54 | ), |
---|
55 | 'authname' => array( |
---|
56 | 'type' => 'varchar', |
---|
57 | 'length' => 128, |
---|
58 | 'not null' => TRUE, |
---|
59 | 'default' => '', |
---|
60 | 'description' => 'Unique authentication name.', |
---|
61 | ), |
---|
62 | 'module' => array( |
---|
63 | 'type' => 'varchar', |
---|
64 | 'length' => 128, |
---|
65 | 'not null' => TRUE, |
---|
66 | 'default' => '', |
---|
67 | 'description' => 'Module which is controlling the authentication.', |
---|
68 | ), |
---|
69 | ), |
---|
70 | 'unique keys' => array('authname' => array('authname')), |
---|
71 | 'primary key' => array('aid'), |
---|
72 | ); |
---|
73 | |
---|
74 | $schema['permission'] = array( |
---|
75 | 'description' => 'Stores permissions for users.', |
---|
76 | 'fields' => array( |
---|
77 | 'pid' => array( |
---|
78 | 'type' => 'serial', |
---|
79 | 'not null' => TRUE, |
---|
80 | 'description' => 'Primary Key: Unique permission ID.', |
---|
81 | ), |
---|
82 | 'rid' => array( |
---|
83 | 'type' => 'int', |
---|
84 | 'unsigned' => TRUE, |
---|
85 | 'not null' => TRUE, |
---|
86 | 'default' => 0, |
---|
87 | 'description' => 'The {role}.rid to which the permissions are assigned.', |
---|
88 | ), |
---|
89 | 'perm' => array( |
---|
90 | 'type' => 'text', |
---|
91 | 'not null' => FALSE, |
---|
92 | 'size' => 'big', |
---|
93 | 'description' => 'List of permissions being assigned.', |
---|
94 | ), |
---|
95 | 'tid' => array( |
---|
96 | 'type' => 'int', |
---|
97 | 'unsigned' => TRUE, |
---|
98 | 'not null' => TRUE, |
---|
99 | 'default' => 0, |
---|
100 | 'description' => 'Originally intended for taxonomy-based permissions, but never used.', |
---|
101 | ), |
---|
102 | ), |
---|
103 | 'primary key' => array('pid'), |
---|
104 | 'indexes' => array('rid' => array('rid')), |
---|
105 | ); |
---|
106 | |
---|
107 | $schema['role'] = array( |
---|
108 | 'description' => 'Stores user roles.', |
---|
109 | 'fields' => array( |
---|
110 | 'rid' => array( |
---|
111 | 'type' => 'serial', |
---|
112 | 'unsigned' => TRUE, |
---|
113 | 'not null' => TRUE, |
---|
114 | 'description' => 'Primary Key: Unique role id.', |
---|
115 | ), |
---|
116 | 'name' => array( |
---|
117 | 'type' => 'varchar', |
---|
118 | 'length' => 64, |
---|
119 | 'not null' => TRUE, |
---|
120 | 'default' => '', |
---|
121 | 'description' => 'Unique role name.', |
---|
122 | ), |
---|
123 | ), |
---|
124 | 'unique keys' => array('name' => array('name')), |
---|
125 | 'primary key' => array('rid'), |
---|
126 | ); |
---|
127 | |
---|
128 | $schema['users'] = array( |
---|
129 | 'description' => 'Stores user data.', |
---|
130 | 'fields' => array( |
---|
131 | 'uid' => array( |
---|
132 | 'type' => 'serial', |
---|
133 | 'unsigned' => TRUE, |
---|
134 | 'not null' => TRUE, |
---|
135 | 'description' => 'Primary Key: Unique user ID.', |
---|
136 | ), |
---|
137 | 'name' => array( |
---|
138 | 'type' => 'varchar', |
---|
139 | 'length' => 60, |
---|
140 | 'not null' => TRUE, |
---|
141 | 'default' => '', |
---|
142 | 'description' => 'Unique user name.', |
---|
143 | ), |
---|
144 | 'pass' => array( |
---|
145 | 'type' => 'varchar', |
---|
146 | 'length' => 32, |
---|
147 | 'not null' => TRUE, |
---|
148 | 'default' => '', |
---|
149 | 'description' => "User's password (md5 hash).", |
---|
150 | ), |
---|
151 | 'mail' => array( |
---|
152 | 'type' => 'varchar', |
---|
153 | 'length' => 64, |
---|
154 | 'not null' => FALSE, |
---|
155 | 'default' => '', |
---|
156 | 'description' => "User's email address.", |
---|
157 | ), |
---|
158 | 'mode' => array( |
---|
159 | 'type' => 'int', |
---|
160 | 'not null' => TRUE, |
---|
161 | 'default' => 0, |
---|
162 | 'size' => 'tiny', |
---|
163 | 'description' => 'Per-user comment display mode (threaded vs. flat), used by the {comment} module.', |
---|
164 | ), |
---|
165 | 'sort' => array( |
---|
166 | 'type' => 'int', |
---|
167 | 'not null' => FALSE, |
---|
168 | 'default' => 0, |
---|
169 | 'size' => 'tiny', |
---|
170 | 'description' => 'Per-user comment sort order (newest vs. oldest first), used by the {comment} module.', |
---|
171 | ), |
---|
172 | 'threshold' => array( |
---|
173 | 'type' => 'int', |
---|
174 | 'not null' => FALSE, |
---|
175 | 'default' => 0, |
---|
176 | 'size' => 'tiny', |
---|
177 | 'description' => 'Previously used by the {comment} module for per-user preferences; no longer used.', |
---|
178 | ), |
---|
179 | 'theme' => array( |
---|
180 | 'type' => 'varchar', |
---|
181 | 'length' => 255, |
---|
182 | 'not null' => TRUE, |
---|
183 | 'default' => '', |
---|
184 | 'description' => "User's default theme.", |
---|
185 | ), |
---|
186 | 'signature' => array( |
---|
187 | 'type' => 'varchar', |
---|
188 | 'length' => 255, |
---|
189 | 'not null' => TRUE, |
---|
190 | 'default' => '', |
---|
191 | 'description' => "User's signature.", |
---|
192 | ), |
---|
193 | 'signature_format' => array( |
---|
194 | 'type' => 'int', |
---|
195 | 'size' => 'small', |
---|
196 | 'not null' => TRUE, |
---|
197 | 'default' => 0, |
---|
198 | 'description' => 'The {filter_formats}.format of the signature.', |
---|
199 | ), |
---|
200 | 'created' => array( |
---|
201 | 'type' => 'int', |
---|
202 | 'not null' => TRUE, |
---|
203 | 'default' => 0, |
---|
204 | 'description' => 'Timestamp for when user was created.', |
---|
205 | ), |
---|
206 | 'access' => array( |
---|
207 | 'type' => 'int', |
---|
208 | 'not null' => TRUE, |
---|
209 | 'default' => 0, |
---|
210 | 'description' => 'Timestamp for previous time user accessed the site.', |
---|
211 | ), |
---|
212 | 'login' => array( |
---|
213 | 'type' => 'int', |
---|
214 | 'not null' => TRUE, |
---|
215 | 'default' => 0, |
---|
216 | 'description' => "Timestamp for user's last login.", |
---|
217 | ), |
---|
218 | 'status' => array( |
---|
219 | 'type' => 'int', |
---|
220 | 'not null' => TRUE, |
---|
221 | 'default' => 0, |
---|
222 | 'size' => 'tiny', |
---|
223 | 'description' => 'Whether the user is active(1) or blocked(0).', |
---|
224 | ), |
---|
225 | 'timezone' => array( |
---|
226 | 'type' => 'varchar', |
---|
227 | 'length' => 8, |
---|
228 | 'not null' => FALSE, |
---|
229 | 'description' => "User's timezone.", |
---|
230 | ), |
---|
231 | 'language' => array( |
---|
232 | 'type' => 'varchar', |
---|
233 | 'length' => 12, |
---|
234 | 'not null' => TRUE, |
---|
235 | 'default' => '', |
---|
236 | 'description' => "User's default language.", |
---|
237 | ), |
---|
238 | 'picture' => array( |
---|
239 | 'type' => 'varchar', |
---|
240 | 'length' => 255, |
---|
241 | 'not null' => TRUE, |
---|
242 | 'default' => '', |
---|
243 | 'description' => "Path to the user's uploaded picture.", |
---|
244 | ), |
---|
245 | 'init' => array( |
---|
246 | 'type' => 'varchar', |
---|
247 | 'length' => 64, |
---|
248 | 'not null' => FALSE, |
---|
249 | 'default' => '', |
---|
250 | 'description' => 'Email address used for initial account creation.', |
---|
251 | ), |
---|
252 | 'data' => array( |
---|
253 | 'type' => 'text', |
---|
254 | 'not null' => FALSE, |
---|
255 | 'size' => 'big', |
---|
256 | 'description' => 'A serialized array of name value pairs that are related to the user. Any form values posted during user edit are stored and are loaded into the $user object during user_load(). Use of this field is discouraged and it will likely disappear in a future version of Drupal.', |
---|
257 | ), |
---|
258 | ), |
---|
259 | 'indexes' => array( |
---|
260 | 'access' => array('access'), |
---|
261 | 'created' => array('created'), |
---|
262 | 'mail' => array('mail'), |
---|
263 | ), |
---|
264 | 'unique keys' => array( |
---|
265 | 'name' => array('name'), |
---|
266 | ), |
---|
267 | 'primary key' => array('uid'), |
---|
268 | ); |
---|
269 | |
---|
270 | $schema['users_roles'] = array( |
---|
271 | 'description' => 'Maps users to roles.', |
---|
272 | 'fields' => array( |
---|
273 | 'uid' => array( |
---|
274 | 'type' => 'int', |
---|
275 | 'unsigned' => TRUE, |
---|
276 | 'not null' => TRUE, |
---|
277 | 'default' => 0, |
---|
278 | 'description' => 'Primary Key: {users}.uid for user.', |
---|
279 | ), |
---|
280 | 'rid' => array( |
---|
281 | 'type' => 'int', |
---|
282 | 'unsigned' => TRUE, |
---|
283 | 'not null' => TRUE, |
---|
284 | 'default' => 0, |
---|
285 | 'description' => 'Primary Key: {role}.rid for role.', |
---|
286 | ), |
---|
287 | ), |
---|
288 | 'primary key' => array('uid', 'rid'), |
---|
289 | 'indexes' => array( |
---|
290 | 'rid' => array('rid'), |
---|
291 | ), |
---|
292 | ); |
---|
293 | |
---|
294 | return $schema; |
---|
295 | } |
---|
296 | |
---|