-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathweixin.install
188 lines (181 loc) · 4.57 KB
/
weixin.install
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
<?php
/*
* This file is licensed under GPLv2+.
*/
/**
* @file
* Install, update and uninstall functions for the weixin module.
*/
/**
* Implementation of hook_schema().
*/
function weixin_schema() {
// users_weixin connection
$schema['users_weixin'] = array(
'description' => t('Provides binding information between users and weixin openid'),
'fields' => array(
'uid' => array(
'type' => 'int',
'not null' => TRUE,
'description' => t('Primary Key: Unique user ID.'),
),
'wx_openid' => array(
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
'description' => t('Unique Key: weixin_openid.'),
),
'status' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'nickname' => array(
'type' => 'varchar',
'length' => '100',
'not null' => FALSE,
),
'avatar' => array(
'type' => 'blob',
'not null' => FALSE,
),
),
'primary key' => array('uid'),
'unique keys' => array(
'wx_openid' => array('wx_openid'),
),
);
// weixin binding and validation codes
$schema['weixin_validation'] = array(
'description' => t('Provides temporary information when binding users and weixin openid'),
'fields' => array(
'uid' => array(
'type' => 'int',
'not null' => TRUE,
'description' => t('Primary Key: Unique user ID.'),
),
'seed' => array(
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
'description' => t('Unique Key: seed to display on the web.'),
),
'validation_code' => array(
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
'description' => t('Unique Key: validation code to match.'),
),
'expiration_time' => array(
'type' => 'int',
'description' => t('The expiration time of current seed.'),
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('uid'),
'unique keys' => array(
'seed' => array('seed'),
'validation_code' => array('validation_code'),
),
'indexes' => array(
'expiration_time' => array('expiration_time'),
),
);
// weixin_rules used with regexp
$schema['weixin_rules'] = array(
'description' => t('Provides customized rules to response weixin request'),
'fields' => array(
'ruleid' => array(
'type' => 'int',
'not null' => TRUE,
'description' => t('Unique Key: the id of specific rule.'),
),
'rule' => array(
'type' => 'varchar',
'length' => '300',
'not null' => TRUE,
'description' => t('regexp rules to match.'),
),
'response' => array(
'type' => 'varchar',
'length' => '300',
'not null' => TRUE,
'description' => t('When corresponding rule be match, return relative response.'),
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => t('Index Key: weight of specific rule.'),
),
),
'primary key' => array('ruleid'),
'indexes' => array(
'weight' => array('weight'),
),
);
// weixin_logs
$schema['weixin_log'] = array(
'description' => t('Provides weixin logging feature'),
'fields' => array(
'logid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => t('Unique Key: the id of log.'),
),
'refid' => array(
'type' => 'varchar',
'length' => '50',
'not null' => FALSE,
'description' => t('Unique key: reference id (upstream or local id).'),
),
'direction' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'description' => t('Message direction: income, outcome or massive pushing.'),
),
'opposite' => array(
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
'description' => t('The opposite of the message.'),
),
'timestamp' => array(
'type' => 'int',
'not null' => TRUE,
'description' => t('The timestamp of the message.'),
),
'previouslid' => array(
'type' => 'int',
'not null' => FALSE,
'description' => t('The last message of the conversation.'),
),
'content' => array(
'type' => 'varchar',
'length' => '4096',
'not null' => TRUE,
'description' => t('The content of message.'),
'serialize' => TRUE,
),
),
'primary key' => array('logid'),
'indexes' => array(
'refid' => array('refid'),
'direction' => array('direction'),
'opposite' => array('opposite'),
'timestamp' => array('timestamp'),
'previouslid' => array('previouslid'),
),
);
return $schema;
}
function weixin_update_7000() {
$nickname = array('type' => 'varchar', 'length' => '100', 'not null' => FALSE);
db_add_field('users_weixin', 'nickname', $nickname, $index);
$avatar = array('type' => 'blob', 'not null' => FALSE);
db_add_field('users_weixin', 'avatar', $avatar, $index);
}