-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoopit.install
183 lines (171 loc) · 4.87 KB
/
scoopit.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
<?php
// scoopit.install
/**
* Implementation of hook_schema().
*/
function scoopit_schema() {
$schema['scoopit_api_users'] = array(
'description' => 'Stores scoopit api user credential data.',
'fields' => array(
'id' => array(
'description' => 'Primary Key: Unique user ID.',
'type' => 'serial',
'not null' => TRUE,
),
'consumer_key' => array(
'description' => 'Unique user key.',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
),
'consumer_secret' => array(
'description' => 'User’s secret (hashed).',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
),
'email' => array(
'description' => 'User’s e-mail address.',
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
),/*
'created_date' => array(
'description' => 'User’s created time.',
'type' => 'timestamp',
'mysql_type' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP',
'not null' => TRUE,
),*/
'created_date' => array(
'description' => t('The timestamp for when the user was created.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'description' => 'User’s status.',
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
'default' => 'Active',
),
),
'primary key' => array('id'),
);
$schema['scoopit_api_sync'] = array(
'description' => 'Stores scoopit api content sync data.',
'fields' => array(
'id' => array(
'description' => 'Primary Key: Unique user ID.',
'type' => 'serial',
'not null' => TRUE,
),
'content_id' => array(
'description' => t('The id for local content.'),
'type' => 'int',
'not null' => TRUE,
),
'remote_id' => array(
'description' => t('The id for remote content'),
'type' => 'int',
'not null' => TRUE,
),
'created_date' => array(
'description' => t('The timestamp for when the map was created.'),
'type' => 'int',
'not null' => TRUE,
),
'modified_date' => array(
'description' => t('The timestamp for when the map was modified.'),
'type' => 'int',
'not null' => TRUE,
),
),
'primary key' => array('id'),
'unique keys' => array(
'content_id' => array('content_id', 'remote_id')
),
);
$schema['scoopit_api_content_map'] = array(
'description' => 'Stores scoopit api content mapping data.',
'fields' => array(
'id' => array(
'description' => 'Primary Key: Unique map ID.',
'type' => 'serial',
'not null' => TRUE,
),
'local_type' => array(
'description' => 'local field type for object',
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
'remote_type' => array(
'description' => 'remote field type for object',
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
'local_field_name' => array(
'description' => 'local field name for object',
'type' => 'varchar',
'length' => '100',
'not null' => TRUE,
),
'remote_field_name' => array(
'description' => 'remote field name for object',
'type' => 'varchar',
'length' => '100',
'not null' => TRUE,
),
'created_date' => array(
'description' => t('The timestamp for when the map was created.'),
'type' => 'int',
'not null' => TRUE,
),
'created_by' => array(
'description' => t('The person that created the map.'),
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
),
'primary key' => array('id'),
'unique keys' => array(
'local_type' => array(
'local_type',
'remote_type',
'local_field_name',
'remote_field_name'
)
),
);
return $schema;
}
/**
* Implementation of hook_schema().
*/
function scoopit_uninstall() {
//remove the database table
/**/
db_query('DROP TABLE IF EXISTS {scoopit_api_users}');
db_query('DROP TABLE IF EXISTS {scoopit_api_sync}');
db_query('DROP TABLE IF EXISTS {scoopit_api_content_map}');
$scoopit_oauth_var = 'scoopit_oauth_var';
$scoopit_oauth_val = variable_get($scoopit_oauth_var, '');
if (trim($scoopit_oauth_val) != '') {
$scoopit_oauth_id_arr = explode('|', $scoopit_oauth_val);
foreach ($scoopit_oauth_id_arr as $oauth_id) {
try {
$qry = "DELETE FROM {oauth_clients} where client_id = '$oauth_id'";
db_query($qry);
} catch (Exception $ex) {
}
}
variable_set($scoopit_oauth_var, '');
}
}
?>