This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
/
interlink.install
112 lines (102 loc) · 3.32 KB
/
interlink.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
<?php
// $Id$
/**
* @file
* Install, update, and uninstall functions for the interlink module.
*/
/**
* Implementation of hook_schema().
*/
function interlink_schema() {
$schema['interlink_term'] = array(
'description' => t('Stores terms (abbreviations/synonyms) for referenced objects.'),
'fields' => array(
'object_type' => array(
'description' => t('The object type the term references.'),
'type' => 'varchar',
'length' => '12',
'not null' => TRUE,
),
'object_id' => array(
'description' => t('The object id the term references.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'term' => array(
'description' => t('The term for the referenced object.'),
'type' => 'varchar',
'length' => '64',
'not null' => TRUE,
),
'type' => array(
'description' => t('The type of the term (abbreviation, synonym).'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'indexes' => array(
'object_type_id' => array('object_type', 'object_id'),
),
'unique keys' => array(
'term' => array('term'),
),
);
$schema['interlink_title'] = array(
'description' => t('Stores unabbreviated titles of referenced objects.'),
'fields' => array(
'object_type' => array(
'description' => t('The object type the title belongs to.'),
'type' => 'varchar',
'length' => '12',
'not null' => TRUE,
),
'object_id' => array(
'description' => t('The object id the title belongs to.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'title' => array(
'description' => t('The unabbreviated title of the referenced object.'),
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
),
'unique keys' => array(
'object_type_id' => array('object_type', 'object_id'),
),
);
return $schema;
}
/**
* Implementation of hook_requirements().
*/
function interlink_requirements($phase) {
$requirements = array();
$t = get_t();
if (!file_exists('./sites/all/libraries/simplehtmldom/simple_html_dom.php')) {
// Required library wasn't found. Abort installation.
$requirements['interlink']['title'] = $t('Simple HTML DOM library');
$requirements['interlink']['value'] = $t('Not found');
$requirements['interlink']['description'] = $t('The <a href="@simplehtmldom">Simple HTML DOM</a> library is missing. <a href="@download">Download</a> and extract it to the <em>sites/all/libraries</em> directory. See <a href="@readme">README.txt</a> for more info.', array('@simplehtmldom' => 'http://simplehtmldom.sourceforge.net', '@download' => 'http://sourceforge.net/projects/simplehtmldom/files/', '@readme' => url(drupal_get_path('module', 'interlink') . '/README.txt')));
$requirements['interlink']['severity'] = REQUIREMENT_ERROR;
}
return $requirements;
}
/**
* Implementation of hook_install().
*/
function interlink_install() {
drupal_install_schema('interlink');
}
/**
* Implementation of hook_uninstall().
*/
function interlink_uninstall() {
drupal_uninstall_schema('interlink');
// Delete variables.
db_query("DELETE FROM {variable} WHERE name LIKE 'interlink_%%'");
}