/[drupal]/contributions/modules/user_types/user_types.install
ViewVC logotype

Contents of /contributions/modules/user_types/user_types.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Tue Sep 23 16:29:36 2008 UTC (14 months ago) by swentel
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.1: +73 -1 lines
File MIME type: text/x-php
#196938 by domidc: documentation and help. #218132 by thePanz: uninstall hook. Adding README and CHANGELOG file
1 <?php
2 // $Id: user_types.install,v 1.1.2.2 2007/12/06 23:25:54 drumm Exp $
3
4 /**
5 * @file
6 * Install file.
7 */
8
9 /**
10 * Implementation of hook_install().
11 */
12 function user_types_install() {
13 switch ($GLOBALS['db_type']) {
14 case 'mysql':
15 case 'mysqli':
16 db_query('CREATE TABLE {user_types_type} (
17 user_type_id int NOT NULL,
18 name varchar(255) NOT NULL,
19 enable_registration tinyint NOT NULL,
20 PRIMARY KEY (user_type_id)
21 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ');
22 db_query('CREATE TABLE {user_types_profile_fields} (
23 user_type_id int NOT NULL,
24 fid int NOT NULL,
25 enabled tinyint NOT NULL,
26 PRIMARY KEY (user_type_id, fid),
27 INDEX (enabled)
28 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ');
29 db_query('CREATE TABLE {user_types_user} (
30 uid int NOT NULL,
31 user_type_id int NOT NULL,
32 PRIMARY KEY (uid),
33 INDEX (user_type_id)
34 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ');
35 db_query('CREATE TABLE {user_types_quick_view} (
36 fid int NOT NULL,
37 enabled tinyint NOT NULL,
38 PRIMARY KEY (fid)
39 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ');
40 break;
41 }
42 }
43
44 function user_types_update_1() {
45 $return = array();
46
47 switch ($GLOBALS['db_type']) {
48 case 'mysql':
49 case 'mysqli':
50 $return[] = update_sql('CREATE TABLE {user_types_quick_view} (
51 fid int NOT NULL,
52 enabled tinyint NOT NULL,
53 PRIMARY KEY (fid)
54 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ');
55 break;
56 }
57
58 return $return;
59 }
60
61 function user_types_update_2() {
62 $return = array();
63
64 switch ($GLOBALS['db_type']) {
65 case 'mysql':
66 case 'mysqli':
67 $return[] = update_sql('ALTER TABLE {user_types_type} ADD enable_registration tinyint NOT NULL');
68 break;
69 }
70
71 return $return;
72 }
73
74 function user_types_update_3() {
75 $return = array();
76
77 switch ($GLOBALS['db_type']) {
78 case 'mysql':
79 case 'mysqli':
80 $result = db_query('SELECT u.uid FROM {users} u LEFT JOIN {user_types_user} utu ON utu.uid = u.uid WHERE utu.uid IS NULL');
81 while ($user = db_fetch_object($result)) {
82 db_query('INSERT INTO {user_types_user} (uid, user_type_id) VALUES (%d, -1)', $user->uid);
83 }
84 break;
85 }
86
87 return $return;
88 }
89
90 /**
91 * Implementation of hook_uninstall().
92 */
93 function user_types_uninstall() {
94 db_query('DROP TABLE {user_types_type}');
95 db_query('DROP TABLE {user_types_user}');
96 db_query('DROP TABLE {user_types_profile_fields}');
97 db_query('DROP TABLE {user_types_quick_view}');
98 variable_del('user_types_untyped_name');
99 db_query("DELETE FROM {system} WHERE name = 'user_types'");
100 }

  ViewVC Help
Powered by ViewVC 1.1.2