-
Notifications
You must be signed in to change notification settings - Fork 2
/
vinculum.install
executable file
·172 lines (159 loc) · 4.74 KB
/
vinculum.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
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
<?php
/**
* @file
* Install functions for the Vinculum module.
*/
/**
* Implements hook_requirements.
*/
function vinculum_requirements($phase) {
$requirements = array();
switch ($phase) {
case 'runtime':
// Vinculum is an API which requires at least one handler.
$handlers = vinculum_get_handler();
$requirements['vinculum'] = array(
'title' => t('Vinculum API handlers'),
'value' => format_plural(count($handlers), '@count handler', '@count handlers'),
);
if (empty($handlers)) {
$requirements['vinculum'] += array(
'description' => t('Vinculum requires at least one enabled handler-module to function correctly.'),
'severity' => REQUIREMENT_ERROR,
);
}
else {
$requirements['vinculum']['severity'] = REQUIREMENT_OK;
}
break;
}
return $requirements;
}
/**
* Implements hook_schema().
*/
function vinculum_schema() {
// Provide the tables:
// - node_vinculum_settings Flags which show if vinculum send/receive is
// enabled for a given node.
// - node_vinculum_sent A list of the vinculums which have already been
// sent for a given node.
// - node_vinculum_received A list of the vinculums which have been received
// for a given node.
$schema = array();
$schema['node_vinculum_settings'] = array(
'description' => 'Flags which show if vinculum send/receive is enabled for a given node.',
'fields' => array(
'nid' => array(
'description' => 'The {node}.nid this record affects.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'send' => array(
'description' => 'Flag if the node may send pingbacks',
'type' => 'int',
'size' => 'tiny',
'default' => 1,
),
'receive' => array(
'description' => 'Flag if the node may receive pingbacks',
'type' => 'int',
'size' => 'tiny',
'default' => 1,
),
),
'indexes' => array(
'nid' => array('nid'),
),
);
$schema['node_vinculum_sent'] = array(
'description' => 'A list of the vinculums which have already been sent for a given node.',
'fields' => array(
'nid' => array(
'description' => 'The {node}.nid for this record.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'url' => array(
'description' => 'The third-party URL',
'type' => 'varchar',
'length' => 255,
'default' => '',
),
'handler' => array(
'description' => "The vinculum handler (i.e. the module's name) which reported success.",
'type' => 'varchar',
'length' => 255,
'default' => NULL,
),
'timestamp' => array(
'description' => 'The Unix timestamp when the vinculum was most recently attempted.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'nid' => array('nid'),
),
);
$schema['node_vinculum_received'] = array(
'description' => 'A list of the vinculums which have been received for a given node.',
'fields' => array(
'nid' => array(
'description' => 'The {node}.nid for this record.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'url' => array(
'description' => 'The URL of the remote site',
'type' => 'varchar',
'length' => 255,
'default' => '',
),
'handler' => array(
'description' => 'The handler (module) which reported the vinculum (e.g. pingback, trackback, etc).',
'type' => 'varchar',
'length' => 255,
'default' => NULL,
),
'origin_ip' => array(
'description' => 'Identifier of the origin, such as an IP address or hostname.',
'type' => 'varchar',
'length' => 128,
'default' => '',
),
'timestamp' => array(
'description' => 'The Unix timestamp when the vinculum was received.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'nid' => array('nid'),
),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function vinculum_uninstall() {
// Query the variables-table for a list of all variables provided by the
// vinculum module.
$variables = db_select('variable', 'v', array('target' => 'slave'))
->fields('v', array('name'))
->condition("v.name", 'vinculum%', 'LIKE')
->execute()
->fetchAll();
foreach ($variables as $variable) {
variable_del($variable);
}
}