forked from artesis/alma
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalma.install
More file actions
119 lines (99 loc) · 2.72 KB
/
alma.install
File metadata and controls
119 lines (99 loc) · 2.72 KB
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
<?php
// Installation and update hooks for Openruth.
/**
* Implements hook_update_N.
* update system table set alma weight=10
* to ensure form_alter hooks are called AFTER ding_user and ding_provider
*/
function alma_update_7001() {
$num_upd = db_update('system')
->fields(array(
'weight' => 10,
))
->condition('name', 'alma', '=')
->execute();
echo $num_upd;
return t('system weight for alma updated to 10');
}
/**
* Expands the limit length for the phone field.
*/
function alma_update_7002() {
field_cache_clear();
$field_name = 'field_alma_mobile_phone';
// Get the current settings
$result = db_query('SELECT data FROM {field_config} WHERE field_name = :name', array(':name' => $field_name))->fetchField();
// Change the settings
$data = unserialize($result);
$data['settings']['max_length'] = '255';
// Write settings back to the database.
db_update('field_config')
->fields(array('data' => serialize($data)))
->condition('field_name', $field_name)
->execute();
$definition = array(
'type' => 'varchar',
'length' => 255,
);
$col_name = $field_name. '_value';
// Fetch existing data.
$rows = db_select("field_data_$field_name", 'f')
->fields('f')
->execute();
// Reset value.
db_update("field_data_$field_name")
->fields(array(
$col_name => NULL,
))
->execute();
// Change schema.
db_change_field(
"field_data_$field_name",
$col_name,
$col_name,
$definition
);
// Restore data.
foreach ($rows as $row) {
db_update("field_data_$field_name")
->fields(array(
$col_name => $row->$col_name,
))
->condition('entity_id', $row->entity_id, '=')
->condition('revision_id', $row->revision_id, '=')
->condition('language', $row->language, '=')
->condition('deleted', $row->deleted, '=')
->condition('delta', $row->delta, '=')
->execute();
}
// Fetch existing data.
$rows = db_select("field_revision_$field_name", 'f')
->fields('f')
->execute();
// Reset value.
db_update("field_revision_$field_name")
->fields(array(
$col_name => NULL,
))
->execute();
db_change_field(
"field_revision_$field_name",
$col_name,
$col_name,
$definition
);
// Restore data.
foreach ($rows as $row) {
db_update("field_revision_$field_name")
->fields(array(
$col_name => $row->$col_name,
))
->condition('entity_id', $row->entity_id, '=')
->condition('revision_id', $row->revision_id, '=')
->condition('language', $row->language, '=')
->condition('deleted', $row->deleted, '=')
->condition('delta', $row->delta, '=')
->execute();
}
field_cache_clear();
}