-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvotingapi.install
81 lines (76 loc) · 3.37 KB
/
votingapi.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
<?php
/**
* @file
* Installation file for VotingAPI module.
*/
function votingapi_schema() {
$schema['votingapi_vote'] = array(
'fields' => array(
'vote_id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'entity_type' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'node'),
'entity_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'value' => array('type' => 'float', 'not null' => TRUE, 'default' => 0),
'value_type' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'percent'),
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'vote'),
'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'timestamp' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'vote_source' => array('type' => 'varchar', 'length' => 255),
),
'primary key' => array('vote_id'),
'indexes' => array(
'content_uid' => array('entity_type', 'entity_id', 'uid'),
'content_uid_2' => array('entity_type', 'uid'),
'content_source' => array('entity_type', 'entity_id', 'vote_source'),
'content_value_tag' => array('entity_type', 'entity_id', 'value_type', 'tag'),
),
);
$schema['votingapi_cache'] = array(
'fields' => array(
'vote_cache_id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'entity_type' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'node'),
'entity_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
'value' => array('type' => 'float', 'not null' => TRUE, 'default' => 0),
'value_type' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'percent'),
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'vote'),
'function' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),
'timestamp' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
),
'primary key' => array('vote_cache_id'),
'indexes' => array(
'content' => array('entity_type', 'entity_id'),
'content_function' => array('entity_type', 'entity_id', 'function'),
'content_tag_func' => array('entity_type', 'entity_id', 'tag', 'function'),
'content_vtype_tag' => array('entity_type', 'entity_id', 'value_type', 'tag'),
'content_vtype_tag_func' => array('entity_type', 'entity_id', 'value_type', 'tag', 'function'),
),
);
return $schema;
}
/**
* The most recent update removed for version-to-version compatibility.
*/
function votingapi_update_last_removed() {
return 7203;
}
/**
* Delete VotingAPIOrphaned queue for the cleanup tasks.
*/
function votingapi_update_7301() {
DrupalQueue::get('VotingAPIOrphaned', TRUE)->deleteQueue();
}
/**
* Implements hook_uninstall().
*/
function votingapi_uninstall() {
// Delete variables created by voteapi module.
$variables = array(
'votingapi_last_cron',
'votingapi_anonymous_window',
'votingapi_user_window',
'votingapi_calculation_schedule',
);
foreach ($variables as $variable) {
variable_del($variable);
}
DrupalQueue::get('VotingAPIOrphaned', TRUE)->deleteQueue();
}