-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink_click_count.install
89 lines (81 loc) · 2.15 KB
/
link_click_count.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
<?php
/**
* @file
* Install file.
*/
/**
* Implements hook_schema().
*/
function link_click_count_schema() {
$schema = array();
$schema['link_click_count'] = array(
'description' => t('Table to store every click detail.'),
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'url' => array(
'type' => 'varchar',
'not null' => TRUE,
'length' => '2048',
),
'nid' => array(
'type' => 'int',
'length' => '10',
'not null' => TRUE,
),
'uid' => array(
'type' => 'int',
'length' => '10',
'not null' => TRUE,
),
'date' => array(
'type' => 'int',
'length' => '11',
'not null' => TRUE,
),
),
'primary key' => array('id'),
'indexes' => array(
'nid_url' => array(
0 => 'nid',
1 => 'url',
),
'date' => array(
0 => 'date',
),
),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function link_click_count_uninstall() {
drupal_uninstall_schema('link_click_count');
/*$fields = field_info_fields();
foreach ($fields as $field => $field_value) {
$key_exist = array_key_exists("parent_link_field", $field_value["settings"]);
if ($key_exist) {
$type = $field_value["bundles"]["node"][0];
$parent_field = $field_value["settings"]["parent_link_field"];
$nodes = node_load_multiple(array(), array('type' => $type));
foreach ($nodes as $nid => $node) {
$parent_field_value = $node->$parent_field;
$url_exist = $parent_field_value["und"][0]["url"];
$url_parts = parse_url($url_exist);
parse_str($url_parts['query'], $query);
$parent_field_value["und"][0]["url"] = $query["url"];
$node->$parent_field = $parent_field_value;
node_save($node);
}
variable_del("link_click_count_checkbox" . $parent_field);
field_delete_field($field_value["field_name"]);
}
}*/
}
function link_click_count_update_7100() {
db_query('ALTER TABLE {link_click_count} CHANGE url url LONGTEXT');
}