summaryrefslogtreecommitdiff
path: root/modules/profile/profile.install
blob: 31ac41e19d3f3e99a693de5711e3124a20fe9bf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
// $Id$

/**
 * @file
 * Install, update and uninstall functions for the profile module.
 */

/**
 * Implements hook_uninstall().
 */
function profile_uninstall() {
  variable_del('profile_block_author_fields');
}

/**
 * Implements hook_schema().
 */
function profile_schema() {
  $schema['profile_field'] = array(
    'description' => 'Stores profile field information.',
    'fields' => array(
      'fid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique profile field ID.',
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'description' => 'Title of the field shown to the end user.',
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Internal name of the field used in the form HTML and URLs.',
      ),
      'explanation' => array(
        'type' => 'text',
        'not null' => FALSE,
        'description' => 'Explanation of the field to end users.',
      ),
      'category' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'description' => 'Profile category that the field will be grouped under.',
      ),
      'page' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'description' => "Title of page used for browsing by the field's value",
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
        'description' => 'Type of form field.',
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Weight of field in relation to other profile fields.',
      ),
      'required' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Whether the user is required to enter a value. (0 = no, 1 = yes)',
      ),
      'register' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Whether the field is visible in the user registration form. (1 = yes, 0 = no)',
      ),
      'visibility' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'The level of visibility for the field. (0 = hidden, 1 = private, 2 = public on profile but not member list pages, 3 = public on profile and list pages)',
      ),
      'autocomplete' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Whether form auto-completion is enabled. (0 = disabled, 1 = enabled)',
      ),
      'options' => array(
        'type' => 'text',
        'not null' => FALSE,
        'description' => 'List of options to be used in a list selection field.',
      ),
    ),
    'indexes' => array(
      'category' => array('category'),
    ),
    'unique keys' => array(
      'name' => array('name'),
    ),
    'primary key' => array('fid'),
  );

  $schema['profile_value'] = array(
    'description' => 'Stores values for profile fields.',
    'fields' => array(
      'fid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {profile_field}.fid of the field.',
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {users}.uid of the profile user.',
      ),
      'value' => array(
        'type' => 'text',
        'not null' => FALSE,
        'description' => 'The value for the field.',
      ),
    ),
    'primary key' => array('uid', 'fid'),
    'indexes' => array(
      'fid' => array('fid'),
    ),
    'foreign keys' => array(
      'profile_field' => array(
        'table' => 'profile_field',
        'columns' => array('fid' => 'fid'),
      ),
      'profile_user' => array(
        'table' => 'users',
        'columns' => array('uid' => 'uid'),
      ),
    ),
  );

  return $schema;
}

/**
 * Rename {profile_fields} table to {profile_field} and {profile_values} to {profile_value}.
 */
function profile_update_7001() {
  db_rename_table('profile_fields', 'profile_field');
  db_rename_table('profile_values', 'profile_value');
}

/**
 * Change the weight column to normal int.
 */
function profile_update_7002() {
  db_change_field('profile_field', 'weight', 'weight', array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
    'description' => 'Weight of field in relation to other profile fields.',
  ));
}