-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuserpoints.install
More file actions
231 lines (217 loc) · 6.74 KB
/
userpoints.install
File metadata and controls
231 lines (217 loc) · 6.74 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<?php
/**
* Implementation of hook_schema().
*/
function userpoints_schema() {
$schema = array();
$schema['userpoints'] = array(
'description' => 'Holds the user points',
'fields' => array(
'pid' => array(
'description' => t('User ID'),
'type' => 'serial',
'not null' => TRUE,
),
'uid' => array(
'description' => t('User ID'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'points' => array(
'description' => t('Current Points'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'max_points' => array(
'description' => t('Out of a maximum points'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'last_update' => array(
'description' => t('Timestamp'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'tid' => array(
'description' => t('Category ID'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('pid'),
'indexes' => array(
'last_update' => array('last_update'),
),
);
$schema['userpoints_txn'] = array(
'description' => t('Userpoints Transactions'),
'fields' => array(
'txn_id' => array(
'description' => t('Transaction ID'),
'type' => 'serial',
'not null' => TRUE,
),
'uid' => array(
'description' => t('User ID'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'approver_uid' => array(
'description' => t('Approving User ID'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'points' => array(
'description' => t('Points'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'time_stamp' => array(
'description' => t('Timestamp'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'description' => t('Status'),
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'description' => array(
'description' => t('Description'),
'type' => 'text',
),
'reference' => array(
'description' => t('Reserved for module specific use'),
'type' => 'varchar',
'length' => 128,
),
'expirydate' => array(
'description' => t('Expirydate'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'expired' => array(
'description' => t('User ID'),
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'parent_txn_id' => array(
'description' => t('Parent Transaction ID'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'tid' => array(
'description' => t('Category ID'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'entity_id' => array(
'description' => t('ID of an entity in the Database'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'entity_type' => array(
'description' => t('Type of entity'),
'type' => 'varchar',
'length' => 32,
),
'operation' => array(
'description' => t('Operation being carried out'),
'type' => 'varchar',
'length' => 32,
),
),
'primary key' => array('txn_id'),
'indexes' => array(
'operation' => array('operation'),
'reference' => array('reference'),
'status' => array('status'),
)
);
return $schema;
}
/**
* Install the initial schema.
*/
function userpoints_install() {
drupal_install_schema('userpoints');
}
/**
* Implementation of hook_uninstall().
*/
function userpoints_uninstall() {
drupal_uninstall_schema('userpoints');
db_query("DELETE FROM {variable} WHERE name like '%userpoints%'");
$vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='userpoints'"));
if ($vid) {
taxonomy_del_vocabulary($vid);
}
}
function userpoints_update_1() {
return _system_update_utf8(array('userpoints'));
}
function userpoints_update_2() {
$ret = array();
db_add_field($ret, 'userpoints', 'max_points', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'lenght' => 10));
db_change_field($ret, 'userpoints', 'points', 'points', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'lenght' => 10));
return $ret;
}
function userpoints_update_3() {
$ret = array();
db_add_field($ret, 'userpoints_txn', 'description', array('type' => 'text'));
return $ret;
}
function userpoints_update_4() {
$ret = array();
db_change_field($ret, 'userpoints_txn', 'event', 'event', array('type' => 'varchar', 'lenght' => 32 ));
db_change_field($ret, 'userpoints_txn', 'status', 'status', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0 ));
return $ret;
}
function userpoints_update_5() {
$ret = array();
db_add_field($ret, 'userpoints_txn', 'reference', array('type' => 'varchar', 'lenght' => 128));
db_add_index($ret, 'userpoints_txn', 'reference', array('reference'));
return $ret;
}
function userpoints_update_6() {
$ret = array();
db_add_field($ret, 'userpoints_txn', 'expirydate', array('type' => 'int', 'lenght' => 11, 'not null' => true));
db_add_field($ret, 'userpoints_txn', 'expired', array('type' => 'int', 'lenght' => 1, 'not null' => true, 'size' => 'tiny'));
db_add_field($ret, 'userpoints_txn', 'parent_txn_id', array('type' => 'int'));
db_add_field($ret, 'userpoints_txn', 'tid', array('type' => 'int'));
db_drop_primary_key($ret, 'userpoints');
db_add_field($ret, 'userpoints', 'tid', array('type' => 'int'));
db_add_field($ret, 'userpoints', 'pid', array('type' => 'serial', 'not null' => true));
db_add_primary_key($ret, 'userpoints', 'pid');
return $ret;
}
function userpoints_update_7() {
$ret = array();
db_add_field($ret, 'userpoints_txn', 'entity_id', array('type' => 'int', 'lenght' => 11, 'not null' => true));
db_add_field($ret, 'userpoints_txn', 'entity_type', array('type' => 'varchar', 'lenght' => 32));
db_change_field($ret, 'userpoints_txn', 'event', 'operation', array('type' => 'varchar'));
return $ret;
}
function userpoints_update_8() {
$ret = array();
db_change_field($ret, 'userpoints_txn', 'tid', 'tid', array('type' => 'int', 'not null' => true, 'default' => 0, 'lenght' => 11));
db_change_field($ret, 'userpoints', 'tid', 'tid', array('type' => 'int', 'not null' => true, 'default' => 0, 'lenght' => 11));
return $ret;
}