-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathopenruth.install
81 lines (72 loc) · 2.86 KB
/
openruth.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
<?php
/**
* @file
* Installation and update hooks for Openruth.
*/
/**
* Implements hook_requirements().
*/
function openruth_requirements($phase) {
$requirements = array();
// Ensure translations don't break at install time.
$t = get_t();
if ($phase == 'runtime') {
$requirements['openruth'] = array(
'title' => $t('Openruth'),
'value' => $t('Openruth configured'),
'severity' => REQUIREMENT_OK,
);
if (!variable_get('openruth_wsdl_url', FALSE) || !variable_get('openruth_agency_id', FALSE)) {
$requirements['openruth']['value'] = $t('Openruth not configured');
$requirements['openruth']['description'] = $t('Openruth is not properly configured, please visit <a href="@link">the settings page</a>.', array('@link' => url('admin/config/ding/provider/openruth')));
$requirements['openruth']['severity'] = REQUIREMENT_ERROR;
}
}
return $requirements;
}
/**
* Change most fields in the profile to virtual fields.
*/
function openruth_update_7000() {
return db_update('field_config')
->fields(array(
'storage_type' => 'virtual_field',
'storage_module' => 'virtual_field',
))
->condition('field_name', '%openruth%', 'LIKE')
->condition('field_name', 'field_openruth_interest_period', '!=')
->condition('field_name', 'field_openruth_reservation_pause', '!=')
->execute();
}
/**
* Remove old field_sql_storage file data from the database as they are using
* virtual fields now and don't need a database table.
*/
function openruth_update_7001() {
// Mobile phone.
db_drop_table('field_data_field_openruth_mobile_phone');
db_drop_table('field_revision_field_openruth_mobile_phone');
// Preferred branch.
db_drop_table('field_data_openruth_preferred_branch');
db_drop_table('field_revision_openruth_preferred_branch');
}
/**
* Move reservarion pause field data into new tabels.
*/
function openruth_update_7002() {
// Move field data.
db_query('INSERT INTO {field_data_field_openruth_reservation_pause}
SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta,
field_reservation_pause_value as field_openruth_reservation_pause_value,
field_reservation_pause_value2 as field_openruth_reservation_pause_value2
FROM {field_data_field_reservation_pause}');
// Move revision data.
db_query('INSERT INTO {field_revision_field_openruth_reservation_pause}
SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta,
field_reservation_pause_value as field_openruth_reservation_pause_value,
field_reservation_pause_value2 as field_openruth_reservation_pause_value2
FROM {field_revision_field_reservation_pause}');
// Remove the old field.
field_delete_field('field_reservation_pause');
field_purge_batch(100);
}