-
Notifications
You must be signed in to change notification settings - Fork 0
/
ting_visual_relation.install
170 lines (160 loc) · 5.04 KB
/
ting_visual_relation.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
<?php
/**
* @file
*
* Install file for the Ting visual relation module.
*/
/**
* Implements hook_schema().
*/
function ting_visual_relation_schema() {
$schema = array();
// The table used to hold settings for each slide in the relation browser
// slideshow. Used by the visual relation application. See:
// https://github.com/vejlebib/visual_relation.git
$schema['ting_visual_relation_slides'] = array(
'description' => 'A table to hold the settings for the visual relation browser slides.',
'fields' => array(
'slide_id' => array(
'description' => 'Primary key for a relation browser slide.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'type' => array(
'description' => 'The machine readable name of relation browser type (external, circular or search)',
'type' => 'varchar',
'length' => 24,
'not null' => TRUE,
'default' => 'external'
),
'position' => array(
'description' => 'The position in the slideshow.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'datawell_pid' => array(
'description' => 'The datawell-PID to use in an external or circular relation browser slide.',
'type' => 'varchar',
'length' => 40,
),
'search_query' => array(
'description' => 'The search query to use in a Search relation browser slide (Search visualization)',
'type' => 'varchar',
'length' => 255,
),
'name' => array(
'description' => 'The human readable name of the slide.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'Name',
),
),
'primary key' => array('slide_id'),
);
return $schema;
}
/**
* Implements hook_install().
*/
function ting_visual_relation_install() {
_ting_visual_relation_modify_mail_system_variable();
}
/**
* Modify Drupal's mail_system variable to use our custom class when sending
* mails from this module only.
*/
function _ting_visual_relation_modify_mail_system_variable() {
variable_set('mail_system',
array_merge(
variable_get('mail_system', array('default-system' => 'DefaultMailSystem')),
array('ting_visual_relation' => 'TingVisualRelationMailSystem')
)
);
}
/**
* Implements hook_uninstall().
*/
function ting_visual_relation_uninstall() {
$mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
unset($mail_system['ting_visual_relation']);
variable_set('mail_system', $mail_system);
}
/**
* Adds the first version of the ting_visual_relation_slides table
*/
function ting_visual_relation_update_7000(&$sandbox) {
// For an exlanation of why we don't use hook_schema here see:
// https://www.drupal.org/node/150220
$schema = array();
$schema['slides'] = array(
'description' => 'A table to hold the settings for the visual relation browser slides.',
'fields' => array(
'slide_id' => array(
'description' => 'Primary key for a relation browser slide.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'type' => array(
'description' => 'The machine readable name of relation browser type (external, circular or search)',
'type' => 'varchar',
'length' => 24,
'not null' => TRUE,
'default' => 'external'
),
'position' => array(
'description' => 'The position in the slideshow.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'datawell_pid' => array(
'description' => 'The datawell-PID to use in an external or circular relation browser slide.',
'type' => 'varchar',
'length' => 40,
),
'search_query' => array(
'description' => 'The search query to use in a Search relation browser slide (Search visualization)',
'type' => 'varchar',
'length' => 255,
),
),
'primary key' => array('slide_id'),
'unique keys' => array(
'position' => array('position'),
),
);
if (!db_table_exists('ting_visual_relation_slides')) {
db_create_table('ting_visual_relation_slides', $schema['slides']);
}
}
/**
* Drop unique key 'position' in ting_visual_relation_slides table.
*/
function ting_visual_relation_update_7001(&$sandbox) {
db_drop_unique_key('ting_visual_relation_slides', 'position');
}
/**
* Adds the 'name' field to the 'ting_visual_relation_slides' table.
*/
function ting_visual_relation_update_7002(&$sandbox) {
$field = array(
'description' => 'The human readable name of the slide.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'Name'
);
if (!db_field_exists('ting_visual_relation_slides', 'name')) {
db_add_field('ting_visual_relation_slides', 'name', $field);
}
}
/**
* Tell Drupal to use our custom class when sending mails from this module.
*/
function ting_visual_relation_update_7003(&$sandbox) {
_ting_visual_relation_modify_mail_system_variable();
}