Newer
Older
<?php
/**
* @file
* Installation file for the heartbeat module.
* @author
* Jochen Stals - Menhir - www.menhir.be
*/
/**
* Implementation of hook_install().
*/
function heartbeat_install() {
// Module weights in core: put heartbeat after most modules in the chain.
// especially core modules, rules, token and pathauto
Jochen Stals
committed
/*db_update('system')
->fields(array('weight' => 50))
->condition('name', 'heartbeat')
Jochen Stals
committed
->execute();*/
}
/**
* Implementation of hook_uninstall().
*/
function heartbeat_uninstall() {
variable_del('heartbeat_activity_grouping_seconds');
variable_del('heartbeat_activity_grouping_how_many');
variable_del('heartbeat_activity_log_cron_delete');
}
/**
* Implementation of hook_schema().
*/
function heartbeat_schema() {
$schema = array();
$schema += _heartbeat_update_7010();
$schema['heartbeat_messages'] = array(
'description' => t('Table that contains predefined messages that can be used in heartbeat views.'),
// CTools export definitions.
'export' => array(
'key' => 'message_id',
'key name' => 'Message ID',
'primary key' => 'message_id',
'bulk export' => TRUE,
'identifier' => 'heartbeatmessagetemplate',
'object' => 'HeartbeatMessageTemplate',
'default hook' => 'heartbeat_template_info',
'list callback' => 'heartbeat_templates_names',
'delete callback' => 'heartbeat_message_template_delete',
//'export callback' => 'heartbeat_message_template_export',
'can disable' => TRUE,
'api' => array(
'owner' => 'heartbeat',
'api' => 'heartbeat',
'minimum_version' => 1,
'current_version' => 1,
),
),
'fields' => array(
'hid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => t('Primary Key: Unique heartbeat_messages event ID.'),
),
'message_id' => array(
'type' => 'varchar',
'length' => 250,
'not null' => FALSE,
'default' => '',
'description' => t('The message id which is unique to identify activity.'),
),
'description' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'description' => t('Description and/or help text.'),
),
'message' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => t('Text of log message to be passed into the t() function.'),
'alias' => 'message_orig', // Internal heartbeat field/property
),
'message_concat' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => t('Text of translatable log message for in concatenated form.'),
'alias' => 'message_concat_orig', // Internal heartbeat field/property
),
'perms' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 4,
'description' => t('Permissions for this message.'),
),
'group_type' => array(
'type' => 'varchar',
'length' => 20,
'not null' => TRUE,
'default' => 'single',
'description' => t('The group type of the template'),
),
'concat_args' => array(
'description' => t('Arguments for concatenation message.'),
'type' => 'blob',
'serialize' => TRUE,
'not null' => FALSE,
),
'variables' => array(
'description' => t('Variables to parse into the message (used in message).'),
'type' => 'blob',
'serialize' => TRUE,
'not null' => FALSE,
),
'attachments' => array(
'description' => t('Attachments on messages.'),
'type' => 'blob',
'serialize' => TRUE,
'not null' => FALSE,
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
),
),
'primary key' => array('hid'),
'indexes' => array(
'message_id' => array('message_id'),
),
);
$schema['heartbeat_activity'] = array(
'description' => t('Table that contains logs of all user triggerable actions.'),
'fields' => array(
'uaid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => t('Primary Key: Unique heartbeat_activity event ID.'),
),
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => t('The {users}.uid of the user who triggered the event (requester).'),
),
'uid_target' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'description' => t('The target User ID'),
),
'nid' => array(
'description' => t('The Node ID.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'nid_target' => array(
'description' => t('The target Node ID (E.g. Group id, node reference, ...).'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'cid' => array(
'description' => t('The target comment ID (optional).'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'access' => array(
'type' => 'int',
'not null' => TRUE,
'size' => 'tiny',
'description' => t('Access for this message to others.'),
'default' => 0,
),
'message_id' => array(
'type' => 'varchar',
'length' => 250,
'not null' => FALSE,
'default' => '',
'description' => t('The message id which links to the heartbeat message.'),
),
'timestamp' => array(
'description' => t('The activity\'s unix timestamp when action occurred'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'language' => array(
'type' => 'varchar',
'length' => 12,
'not null' => FALSE,
'default' => 'en',
'description' => t('language for a log".'),
),
'variables' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'description' => t('Serialized array of variables that match the message string and that is passed into the t() function.'),
),
),
'primary key' => array('uaid'),
'indexes' => array(
'timestamp' => array('timestamp'),
'uid' => array('uid'),
'message_id' => array('message_id'),
'uid_target' => array('uid_target'),
'nid' => array('nid'),
'nid_target' => array('nid_target'),
'cid' => array('cid'),
'language' => array('language'),
),
);
Jochen Stals
committed
$schema['heartbeat_user_templates'] = heartbeat_install_table_user_templates();
Jochen Stals
committed
function heartbeat_install_table_user_templates() {
return array(
'description' => t('Table that connects translations of the same activity.'),
'fields' => array(
'uid' => array(
'type' => 'int',
'not null' => TRUE,
'description' => t('The referenced user ID.'),
),
'message_id' => array(
'type' => 'varchar',
'length' => 250,
'not null' => FALSE,
'default' => '',
'description' => t('The template message ID.'),
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
'description' => t('The status of the template.'),
),
),
);
}
/**
* Helper function to add the new schema for streams.
*/
function _heartbeat_update_7010() {
$schema['heartbeat_streams'] = array(
'description' => t('Table that contains heartbeat streams.'),
// CTools export definitions.
'export' => array(
'key' => 'class',
'key name' => 'name',
'primary key' => 'class',
'bulk export' => TRUE,
'identifier' => 'heartbeatstream',
'object' => 'HeartbeatStreamConfig',
'default hook' => 'heartbeat_stream_info',
'load callback' => '_heartbeat_stream_config_load',
'load all callback' => '_heartbeat_stream_config_load_all',
'can disable' => TRUE,
'api' => array(
'owner' => 'heartbeat',
'api' => 'heartbeat',
'minimum_version' => 1,
'current_version' => 1,
),
),
'fields' => array(
'class' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
'description' => t('Class of the stream to load.'),
),
Jochen Stals
committed
'real_class' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
'description' => t('Real Class of the stream to load.'),
),
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
'name' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
'description' => t('Name of the stream. Cloned streams will have the same object but same class.'),
),
'module' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
'description' => t('The module that defines the class and where the query builder is located.'),
),
'title' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
'description' => t('Human readable name of the stream.'),
),
'path' => array(
'type' => 'varchar',
'length' => 250,
'not null' => TRUE,
'default' => '',
'description' => t('Path to the stream object.'),
),
'settings' => array(
'description' => t('Serialized settings for this stream.'),
'type' => 'blob',
'serialize' => TRUE,
'not null' => FALSE,
),
'variables' => array(
'description' => t('Variables to parse into the message (used in message).'),
'type' => 'blob',
'serialize' => TRUE,
'not null' => FALSE,
),
),
'primary key' => array('class'),
'indexes' => array(
'name' => array('name'),
),
);
return $schema;
}
Jochen Stals
committed
* Removing fields from D6 branch, replacing some things by ctools export.
*/
function heartbeat_update_7010() {
// Type, export_type, disabled, and some others are taken over by ctools.
db_drop_field('heartbeat_messages', 'custom');
db_drop_field('heartbeat_messages', 'disabled');
db_change_field('heartbeat_messages', 'variables', 'variables', array('type' => 'blob', 'not null' => FALSE, 'size' => 'big','serialize' => TRUE));
db_change_field('heartbeat_messages', 'concat_args', 'concat_args', array('type' => 'blob', 'not null' => FALSE, 'size' => 'big','serialize' => TRUE));
db_change_field('heartbeat_messages', 'attachments', 'attachments', array('type' => 'blob', 'not null' => FALSE, 'size' => 'big', 'serialize' => TRUE));
if (!db_field_exists('heartbeat_messages', 'group_type')) {
db_add_field('heartbeat_messages', 'group_type', array('type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => 'single', 'description' => t('The group type of the template')));
}
if (!db_table_exists('heartbeat_streams')) {
$schema =_heartbeat_update_7010();
db_create_table('heartbeat_streams', $schema['heartbeat_streams']);
}
db_drop_field('heartbeat_activity', 'message');
db_drop_field('heartbeat_activity', 'message_concat');
Jochen Stals
committed
}
/**
Jochen Stals
committed
* Adding a field to hold comments for activity.
Jochen Stals
committed
*/
function heartbeat_update_7011() {
if (!db_field_exists('heartbeat_activity', 'uaid_comments')) {
db_add_field('heartbeat_activity', 'uaid_comments', array(
'type' => 'int',
'not null' => FALSE,
'default' => '0',
'description' => 'The comment count for a heartbeat message.',
));
}
}
Jochen Stals
committed
/**
* Removed the count field for comments specific.
*/
function heartbeat_update_7012() {
db_drop_field('heartbeat_activity', 'uaid_comments');
}
Jochen Stals
committed
/**
* Add a real_class field so clones can get their original class.
*/
function heartbeat_update_7013() {
if (!db_field_exists('heartbeat_streams', 'real_class')) {
db_add_field('heartbeat_streams', 'real_class', array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
'description' => t('Real Class of the stream to load.'),
));
}
}
Jochen Stals
committed
/**
* Add database table for the heartbeat user templates.
*/
function heartbeat_update_7014() {
if (!db_table_exists('heartbeat_user_templates')) {
db_create_table('heartbeat_user_templates', heartbeat_install_table_user_templates());
}
}
Jochen Stals
committed
/**
* Remove table {heartbeat_translations} and making activity language independant.
*/
function heartbeat_update_7015() {
db_drop_table('heartbeat_translations');
}