forked from sdooms/sugestio-drupal
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sugestio.install
109 lines (97 loc) · 2.75 KB
/
sugestio.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
// $Id$
/**
* @file
* Install, update and uninstall functions for the sugestio module.
*/
/**
* Implementation of hook_requirements
*/
function sugestio_requirements($phase) {
$requirements = array();
// Ensure translations do not break at install time
$t = get_t();
$requirements['sugestio-php'] = array(
'title' => $t('Sugestio PHP library'),
);
$libraries = libraries_get_libraries();
if (isset($libraries['sugestio-php'])) {
$requirements['sugestio-php']['value'] = $t('Installed');
$requirements['sugestio-php']['severity'] = REQUIREMENT_OK;
}
else {
$requirements['sugestio-php']['value'] = $t('Not Installed');
$requirements['sugestio-php']['severity'] = REQUIREMENT_ERROR;
$requirements['sugestio-php']['description'] = $t('Please install the example library %url.', array('%url' => 'http://www.github.com/sugestio/sugestio-php'));
}
return $requirements;
}
/**
* Implementation of hook_install().
*/
function sugestio_install() {
drupal_install_schema('sugestio');
}
/**
* Implementation of hook_uninstall().
*/
function sugestio_uninstall() {
drupal_uninstall_schema('sugestio');
variable_del('sugestio_account');
variable_del('sugestio_key');
variable_del('sugestio_url');
variable_del('sugestio_number_recs');
variable_del('sugestio_expire');
variable_del('sugestio_rec_cache');
variable_del('sugestio_realtime_hook');
variable_del('sugestio_clicktracking');
variable_del('sugestio_anonymize');
variable_del('sugestio_salt');
}
/**
* Implementation of hook_schema().
*/
function sugestio_schema() {
$schema = array();
$schema['cron_sugestio_calls'] = sugestio_get_calls_structure();
//Recommendations cache.
$schema['cache_sugestio'] = drupal_get_schema_unprocessed('system', 'cache');
return $schema;
}
/**
* Returns the database structure for the storage
* of the hook events that should be cached and executed
* when cron is run.
*/
function sugestio_get_calls_structure() {
//Hook calls to external Sugestio recommendation engine cache.
$calls = array(
'fields' => array(
'cid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE),
'data' => array(
'type' => 'blob',
'serialize' => TRUE,
'not null' => TRUE),
'event' => array(
'type' => 'text',
'not null' => TRUE),
),
'primary key' => array('cid'),
'indexes' => array(
'event' => array(array('event',5)),),
);
return $calls;
}
/**
* Implementation of hook_flush_caches().
*
* This tells Drupal's cache handling system the name of our caching
* table, so expired items will be purged automatically and this table
* also affected by the empty all caches function.
*/
function sugestio_flush_caches() {
return array('cache_sugestio');
}