-
Notifications
You must be signed in to change notification settings - Fork 0
/
social_stats.install
140 lines (132 loc) · 3.75 KB
/
social_stats.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
<?php
/**
* @file
* Table schema for the tables used by Social Stats module.
*/
/**
* Implementation of hook_schema().
*/
function social_stats_schema() {
$schema['social_stats_facebook'] = array(
'description' => 'Table containing stats from Facebook for Social Stats module.',
'fields' => array(
'nid' => array(
'description' => 'Node id of a node.',
'type' => 'int',
'not null' => TRUE,
),
'fb_likes' => array(
'description' => 'Number of facebook likes for this node.',
'type' => 'int',
'default' => 0,
),
'fb_shares' => array(
'description' => 'Number of facebook shares for this node.',
'type' => 'int',
'default' => 0,
),
'fb_comments' => array(
'description' => 'Number of facebook comments for this node.',
'type' => 'int',
'default' => 0,
),
'fb_total' => array(
'description' => 'Facebook likes + shares + comments for this node.',
'type' => 'int',
'default' => 0,
),
),
'primary key' => array('nid'),
);
$schema['social_stats_twitter'] = array(
'description' => 'Table containing Twitter data for Social Stats module.',
'fields' => array(
'nid' => array(
'description' => 'Node id of a node.',
'type' => 'int',
'not null' => TRUE,
),
'tweets' => array(
'description' => 'Number of times this node has been tweeted.',
'type' => 'int',
'default' => 0,
),
),
'primary key' => array('nid'),
);
$schema['social_stats_gplus'] = array(
'description' => 'Table containing stats from Google Plus for Social Stats module.',
'fields' => array(
'nid' => array(
'description' => 'Node id of a node.',
'type' => 'int',
'not null' => TRUE,
),
'plusone' => array(
'description' => 'Number of times this node has been plus oned.',
'type' => 'int',
'default' => 0,
),
'share' => array(
'type' => 'int',
'description' => "GooglePlus Shares",
'not null' => FALSE,
),
'total' => array(
'type' => 'int',
'description' => "GooglePlus Total",
'not null' => FALSE,
),
),
'primary key' => array('nid'),
);
$schema['social_stats_linkedin'] = array(
'description' => 'Table containing stats from LinkedIn for Social Stats module.',
'fields' => array(
'nid' => array(
'description' => 'Node id of a node.',
'type' => 'int',
'not null' => TRUE,
),
'linkedin_shares' => array(
'description' => 'Number of this node has been shared on LinkedIn.',
'type' => 'int',
'default' => 0,
),
),
'primary key' => array('nid'),
);
$schema['social_stats_total'] = array(
'description' => 'Value of (Facebook total + Twitter Shares + LinkedIn Shares + Google plus shares).',
'fields' => array(
'nid' => array(
'description' => 'Node id of a node.',
'type' => 'int',
'not null' => TRUE,
),
'total_virality' => array(
'description' => '(Facebook total + Twitter Shares + LinkedIn Shares + Google plus shares)',
'type' => 'int',
'default' => 0,
),
),
'primary key' => array('nid'),
);
return $schema;
}
/**
* Implementation of hook_install().
*/
function social_stats_install() {
drupal_install_schema('social_stats');
}
/**
* Implementation of hook_uninstall().
*/
function social_stats_uninstall() {
drupal_uninstall_schema('social_stats');
$result = db_query("SELECT name FROM {variable} WHERE name like 'social_stats%'");
while ($row = db_fetch_array($result)) {
variable_del($row['name']);
}
}