-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathting_subsearch_suggestions.install
109 lines (100 loc) · 2.9 KB
/
ting_subsearch_suggestions.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
<?php
/**
* @file
* Installation of Suggestions sub search module.
*
* @TODO: Missing hook_uninstall to clean up after the module.
*/
/**
* Implements hook_schema().
*/
function ting_subsearch_suggestions_schema() {
$schema['ting_subsearch_kpi_index_popular_keys'] = array(
'fields' => array(
'id' => array(
'description' => 'Normal field identifier',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'popular_keys' => array(
'description' => 'The keys',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'numtotalsearches' => array(
'description' => 'The number of times the keys were searched',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'weekno' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'year' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'unique keys' => array(
'id' => array(
'id',
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'kpi_popular_keys' => array('popular_keys'),
'kpi_numtotalsearches' => array('numtotalsearches'),
'kpi_weekno' => array('weekno'),
'kpi_year' => array('year'),
'kpi_weekno_year' => array('weekno', 'year'),
),
);
return $schema;
}
/**
* Install translations.
*
* @TODO: Do every module have this, could the function be moved into the
* subsearch common module and called with the file as parameter.
*/
function ting_subsearch_suggestions_install() {
// Install translations.
$file = new stdClass();
$file->uri = drupal_get_path('module', 'ting_subsearch_suggestions') . '/translations/da.po';
$file->filename = basename($file->uri);
_locale_import_po($file, 'da', LOCALE_IMPORT_OVERWRITE, 'default');
variable_set('ting_subsearch_suggestions_service', 'kpi');
}
/**
* Add "weekno" column in database.
*/
function ting_subsearch_suggestions_update_7001() {
db_drop_table('ting_subsearch_kpi_index_popular_keys');
$schema = drupal_get_schema('ting_subsearch_kpi_index_popular_keys');
db_create_table('ting_subsearch_kpi_index_popular_keys', $schema);
}
/**
* Add "year" column in database and set indexes.
*/
function ting_subsearch_suggestions_update_7002() {
db_drop_table('ting_subsearch_kpi_index_popular_keys');
$schema = drupal_get_schema_unprocessed('ting_subsearch_suggestions', 'ting_subsearch_kpi_index_popular_keys');
db_create_table('ting_subsearch_kpi_index_popular_keys', $schema);
}
/**
* Set KPI as default suggestion service.
*/
function ting_subsearch_suggestions_update_7003(&$sandbox) {
variable_set('ting_subsearch_suggestions_service', 'kpi');
}