Commit deec7129 authored by fago's avatar fago

#107320: added fieldgroup support for contenttype duplication

parent 624e6d39
......@@ -185,6 +185,9 @@ function _content_admin_type_edit_submit($form_id, $form_values) {
// and move existing fields to separate shared table, if not already shared
_content_admin_field_add_existing_submit('_content_admin_field_add_existing', $field_values);
}
if (module_exist('fieldgroup')) {
fieldgroup_duplicate($form_values['original_type_name'], $form_values['type_name']);
}
}
drupal_set_message(t('Saved content type %type.', array('%type' => theme('placeholder', $form_values['label']))));
......
......@@ -322,3 +322,18 @@ function fieldgroup_get_group($content_type, $field_name) {
}
return FALSE;
}
/*
* Duplicates all fieldgroups, used when content types are duplicated
*/
function fieldgroup_duplicate($original_content_type, $content_type) {
foreach (fieldgroup_groups($original_content_type) as $group_name => $group) {
db_query("INSERT INTO {node_group} (type_name, group_name, label, settings, description, weight)
VALUES ('%s', '%s', '%s', '%s', '%s', %d)", $content_type, $group_name, $group['label'], serialize($group['settings']), $group['description'], $group['weight']);
foreach ($group['fields'] as $field_name => $field) {
db_query("INSERT INTO {node_group_fields} (type_name, group_name, field_name) VALUES ('%s', '%s', '%s')",
$content_type, $group_name, $field_name);
}
}
cache_clear_all('fieldgroup_data');
}
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