-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvisualscience.install
More file actions
executable file
·238 lines (221 loc) · 6.65 KB
/
visualscience.install
File metadata and controls
executable file
·238 lines (221 loc) · 6.65 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
232
233
234
235
236
237
238
<?php
/**
* @file
* The install file for the VisualScience module.
*
* It includes:
* - Definition of the DB tables.
* - Definition of the basic configuration for VisualScience.
*/
include_once 'includes/visualscience.utils.inc';
/**
* Implements hook_schema().
*/
function visualscience_schema() {
// Table for saved searches.
// Seb: Keep it, just in case you need to save the searches.
/*
* $schema[visualscience_get_save_table_name()] = array(
* 'description' => 'Stores searches.',
* 'fields' => array(
* 'sid' => array(
* 'type' => 'serial',
* 'unsigned' => TRUE,
* 'not null' => TRUE,
* 'description' => 'Primary Key: Unique search ID.',
* ),
* 'uid' => array(
* 'type' => 'int',
* 'unsigned' => TRUE,
* 'not null' => TRUE,
* 'description' => 'Secondary Key: User ID who has saved the search.',
* ),
* 'name' => array(
* 'type' => 'varchar',
* 'length' => 55,
* 'default' => '',
* 'description' => 'Machine readable name of this search.',
* ),
* 'search' => array(
* 'type' => 'varchar',
* 'length' => 1024,
* 'default' => '',
* 'description' => 'The text of this search.',
* ),
* ),
* 'primary key' => array('sid'),
* 'unique keys' => array('name' => array('name'))
* );
*/
// Table to save the config of visualscience search tables.
$schema['visualscience_search_config'] = array(
'description' => 'Stores VisualScience Configuration.',
'fields' => array(
'cid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique Field ID.',
),
'name' => array(
'type' => 'varchar',
'length' => 255,
'default' => '',
'description' => 'Machine readable name of the field.',
),
'mini' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
'description' => 'Should this field be present in the mini table ? 1 or 0',
),
'full' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
'description' => 'Should this field be present in the full table ? 1 or 0',
),
'first' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
'description' => 'Is this the First Name field ? 1 or 0',
),
'last' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
'description' => 'Is this the last name field ? 1 or 0',
),
'field' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
'description' => 'Is this field contained in field_config ? 1 or 0',
),
),
'primary key' => array('cid'),
);
// Table for uploaded files and their permissions.
$schema['visualscience_uploaded_files'] = array(
'description' => 'Uploaded Files and Permissions',
'fields' => array(
'fid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique file ID.',
),
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'User Id of the user who can access the file.',
),
'email' => array(
'type' => 'varchar',
'length' => 1024,
'default' => '',
'description' => 'The email of the user who can acces the file.',
),
'name' => array(
'type' => 'varchar',
'length' => 1024,
'default' => '',
'description' => 'Name of the file, as uploaded by user',
),
'url' => array(
'type' => 'varchar',
'length' => 4096,
'default' => '',
'description' => 'The url of the file in the private directory.(Common to each message)',
),
),
'primary key' => array('fid'),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function visualscience_uninstall() {
// Deleting the previously set persistent variables.
variable_del('visualscience_user_sent_per_ajax_request');
variable_del('visualscience_user_per_search_page');
variable_del('visualscience_show_csv_button');
variable_del('visualscience_show_messages_button');
variable_del('visualscience_show_livingscience_button');
variable_del('visualscience_show_conference_button');
}
/**
* Implements hook_install().
*/
function visualscience_install() {
// Test: drupal_install_schema('visualscience');.
$name = new stdClass();
$mail = new stdClass();
$roles = new stdClass();
$last = new stdClass();
$first = new stdClass();
$name->name = 'name';
$name->mini = 1;
$name->full = 1;
$name->first = 1;
$mail->last = 1;
$name->field = 0;
$roles->name = 'roles';
$roles->mini = 1;
$roles->full = 1;
$roles->first = 0;
$roles->field = 0;
$mail->last = 0;
$mail->name = 'mail';
$mail->mini = 1;
$mail->full = 1;
$mail->first = 0;
$mail->field = 0;
$mail->last = 0;
$first->name = 'first_name';
$first->mini = 1;
$first->full = 1;
$first->first = 1;
$first->field = 0;
$first->last = 0;
$last->name = 'last_name';
$last->mini = 1;
$last->full = 1;
$last->first = 0;
$last->field = 0;
$last->last = 1;
$exist_first = field_info_field('first_name');
$exist_last = field_info_field('last_name');
$exist_first_field = field_info_field('field_first_name');
$exist_last_field = field_info_field('field_last_name');
if ((isset($exist_first) || isset($exist_first_field)) && (isset($exist_last) || isset($exist_last_field))) {
drupal_write_record('visualscience_search_config', $first);
drupal_write_record('visualscience_search_config', $last);
}
else {
drupal_write_record('visualscience_search_config', $name);
drupal_write_record('visualscience_search_config', $roles);
}
drupal_write_record('visualscience_search_config', $mail);
// Setting some persistent variables that can be changed in the config page.
variable_set('visualscience_user_sent_per_ajax_request', 500);
variable_set('visualscience_user_per_search_page', 150);
// Settings for visibility of actionbar's buttons.
variable_set('visualscience_show_csv_button', 1);
variable_set('visualscience_show_messages_button', 1);
variable_set('visualscience_show_livingscience_button', 1);
variable_set('visualscience_show_conference_button', 1);
}