This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
open_data_federal_extras.install
62 lines (56 loc) · 1.94 KB
/
open_data_federal_extras.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
<?php
/**
* @file
* Installation file for ODFE.
*/
/**
* Implements hook_install().
*/
function open_data_federal_extras_install() {
// Updates values for field_frequency.
open_data_federal_extras_update_field_frequency();
}
/**
* Sets select list for field_odfe_bureau_code.
*/
function open_data_federal_extras_update_7001() {
$ret = array();
if (!db_table_exists('field_data_field_odfe_bureau_code')) {
$out = array(
'#abort' => array(
'success' => FALSE,
'query' => t("The field_odfe_bureau_code table doesn\'t exist yet.)."),
),
);
return $out;
}
$field_odfe_bureau_code = field_info_field('field_odfe_bureau_code');
unset($field_odfe_bureau_code['settings']['allowed_values']);
$field_odfe_bureau_code['settings']['allowed_values_function'] = 'field_odfe_bureau_code_allowed_values';
field_update_field($field_odfe_bureau_code);
return $ret;
}
/**
* Updates existing values to use the colon format rather than dashes.
*/
function open_data_federal_extras_update_7002() {
// Allowed values have been changed, so change existing values as well
$sql = "UPDATE field_data_field_odfe_program_code
SET field_odfe_program_code_value = REPLACE(field_odfe_program_code_value, '-', ':')";
$result = db_query($sql);
$sql = "UPDATE field_revision_field_odfe_program_code
SET field_odfe_program_code_value = REPLACE(field_odfe_program_code_value, '-', ':')";
$result = db_query($sql);
$sql = "UPDATE field_data_field_odfe_bureau_code
SET field_odfe_bureau_code_value = REPLACE(field_odfe_bureau_code_value, '-', ':')";
$result = db_query($sql);
$sql = "UPDATE field_revision_field_odfe_bureau_code
SET field_odfe_bureau_code_value = REPLACE(field_odfe_bureau_code_value, '-', ':')";
$result = db_query($sql);
}
/**
* Updates values for field_frequency.
*/
function open_data_federal_extras_update_7003() {
open_data_federal_extras_update_field_frequency();
}