-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracking.install
93 lines (90 loc) · 2.67 KB
/
tracking.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
<?php
function tracking_install(){
// include_once DRUPAL_ROOT . '/core/profiles/standard/standard.install';
// standard_install();
}
/**
* Implements hook_schema().
*/
function tracking_schema(){
$schema['tm_tracking_log'] = array(
'description' => 'logs the actual tracked items',
'fields' => array(
'lid' => array('type' => 'serial', 'unsigned' => true, 'length' => 11, 'not null' => true),
'recid' => array('type' => 'int', 'length' => 11, 'not null' => true),
'timestamp' => array('mysql_type' => 'timestamp', 'not null' => true),
'ipaddress' => array('type' => 'varchar', 'length' => 16),
'hosttype' => array('type' => 'varchar', 'length' => 500),
'email' => array('type' => 'varchar', 'length' => 250),
),
'primary key' => array('lid'),
);
$schema['tm_tracking'] = array(
'description' => t('Table to store tracking information from image displays and link clicks'),
'fields' => array(
'recid' => array(
'type' => 'serial',
'unsigned' => true,
'not null' => true,
'length' => 11
),
'track_type' => array(
'type' => 'varchar',
'not null' => true,
'length' => 5
),
'source' => array(
'type' => 'varchar',
'not null' => true,
'length' => 3
),
'campaign_id' => array(
'type' => 'varchar',
'length' => 45
),
'user_id' => array(
'type' => 'int',
'not null' => true,
'default'=> 1,
'length' => 11
),
'timestamp' => array(
'mysql_type' => 'timestamp',
'not null' => true
),
'destinationURL' => array(
'type' => 'varchar',
'length' => 250
),
'count' => array(
'type' => 'int',
'not null' => true,
'default'=> 1,
'length' => 11
),
),
'primary key' => array('recid'),
'unique keys' => array('validate' => array('track_type','source','campaign_id','user_id'))
);
return $schema;
}
function tracking_modules_installed(){
// make sure that tracking module sits below/after the tm_utilities module
$weight = \Drupal::configFactory()->get('core.extension')->get("module.tm_utilities");
if($weight === NULL) $weight = \Drupal::moduleHandler()->moduleExists('tm_utilities');
if($weight !== NULL) module_set_weight('module.tracking', $weight+1);
}
/**
* Implements hook_enable().
*/
function tracking_enable(){
// "drush en tracking" appears to NOT run the schema into the database.
if (!db_table_exists('tm_tracking')) drupal_install_schema('tracking');
}
/**
* Implements hook_uninstall().
*/
function tracking_uninstall(){
// "drush pmu tracking" appears to NOT remove the schema from the database.
drupal_uninstall_schema('tracking');
}