Commit e41c3c6e authored by KarenS's avatar KarenS

#256141 Add old updates back to fieldgroup.install for situations where the...

#256141 Add old updates back to fieldgroup.install for situations where the module was briefly enabled and then disabled and never used so the update process doesn't throw an error for the missing updates.
parent 2a262e23
......@@ -41,10 +41,6 @@ function fieldgroup_disable() {
content_notify('disable', 'fieldgroup');
}
function fieldgroup_update_last_removed() {
return 4;
}
/**
* Implementation of hook_schema.
*/
......@@ -72,6 +68,111 @@ function fieldgroup_schema() {
return $schema;
}
/**
* rename groups form "group-*" to "group_*"
*/
function fieldgroup_update_1() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
$ret[] = update_sql("UPDATE {node_group} SET group_name = 'group_'||SUBSTRING(group_name FROM 7)");
$ret[] = update_sql("UPDATE {node_group_fields} SET group_name = 'group_'||SUBSTRING(group_name FROM 7)");
break;
case 'mysql':
case 'mysqli':
$ret[] = update_sql("UPDATE {node_group} SET group_name = CONCAT('group_', SUBSTRING(group_name FROM 7))");
$ret[] = update_sql("UPDATE {node_group_fields} SET group_name = CONCAT('group_', SUBSTRING(group_name FROM 7))");
break;
}
return $ret;
}
/**
* add display settings for the group
*/
function fieldgroup_update_2() {
$ret = array();
// set settings column to accept larger values
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('ALTER TABLE {node_group} CHANGE settings settings mediumtext NOT NULL');
break;
case 'pgsql':
db_change_column($ret, 'node_group', 'settings', 'settings', 'text', array('not null' => TRUE));
break;
}
// move description into the settings array, and add new settings
$result = db_query("SELECT * FROM {node_group}");
while ($group = db_fetch_array($result)) {
$settings = array();
$settings['form'] = unserialize($group['settings']);
$settings['form']['description'] = $group['description'];
$settings['display'] = array('collapsible' => 0, 'collapsed' => 0, 'description' => '');
$ret[] = update_sql("UPDATE {node_group} SET settings = '". db_escape_string(serialize($settings)) ."', description = '' WHERE group_name = '". $group['group_name'] ."'");
}
// drop description column
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('ALTER TABLE {node_group} DROP description');
break;
case 'pgsql':
// Postgres only supports dropping of columns since 7.4
break;
}
return $ret;
}
/**
* converts group settings collapsible/collapsed => style
*/
function fieldgroup_update_3() {
$ret = array();
$result = db_query("SELECT * FROM {node_group}");
while ($group = db_fetch_array($result)) {
$group['settings'] = unserialize($group['settings']);
if (!isset($group['settings']['form']['style'])) {
foreach (array('form', 'display') as $context) {
if (isset($group['settings'][$context]['collapsible']) && $group['settings'][$context]['collapsible']) {
if (isset($group['settings'][$context]['collapsed']) && $group['settings'][$context]['collapsed']) {
$group['settings'][$context]['style'] = 'fieldset_collapsed';
}
else {
$group['settings'][$context]['style'] = 'fieldset_collapsible';
}
}
else {
$group['settings'][$context]['style'] = 'fieldset';
}
}
$ret[] = update_sql("UPDATE {node_group} SET settings = '". db_escape_string(serialize($group['settings'])) ."' WHERE group_name = '". $group['group_name'] ."'");
}
}
return $ret;
}
/*
* Increases module weight, so that other modules can form_alter() cck forms before the fields
* are moved in groups
*/
function fieldgroup_update_4() {
$ret = array();
$ret[] = update_sql("UPDATE {system} SET weight = 9 WHERE name = 'fieldgroup'");
return $ret;
}
/**
* Placeholder update to set newly installed versions to the latest update number.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment