function bundle_copy_clone_submit in Bundle Copy 7.2
Submit callback: Clone data.
File
- ./
bundle_copy.module, line 687 - Bundle copy.
Code
function bundle_copy_clone_submit($form, &$form_state) {
$src_btype = $form_state['values']['bundle'];
$new_bname = $form_state['values']['name'];
$new_btype = $form_state['values']['type'];
$entity_type = $form_state['storage']['entity_type'];
$bc_info = bundle_copy_get_info();
if (isset($bc_info[$entity_type])) {
$bundle_export_callback = $bc_info[$entity_type]['bundle_export_callback'];
$bundle_save_callback = $bc_info[$entity_type]['bundle_save_callback'];
$new_bundle = $bundle_export_callback($src_btype, $entity_type);
$new_bundle->type = $new_bundle->orig_type = $new_btype;
$new_bundle->name = $new_bname;
$new_bundle->custom = 1;
$bundle_status = $bundle_save_callback($new_bundle);
$new_fields = field_info_instances($entity_type, $src_btype);
foreach ($new_fields as $key => $value) {
$new_fields[$key]['bundle'] = $new_btype;
field_create_instance($new_fields[$key]);
}
if (module_exists('field_group')) {
$all_field_groups = field_group_info_groups();
if (isset($all_field_groups[$entity_type][$src_btype])) {
$field_groups = $all_field_groups[$entity_type][$src_btype];
ctools_include('export');
foreach ($field_groups as $mode => $mode_value) {
foreach ($mode_value as $fieldgroup_key => $fieldgroup) {
unset($fieldgroup->id);
$fieldgroup->bundle = $new_btype;
$fieldgroup->identifier = $fieldgroup->group_name . '|' . $entity_type . '|' . $new_btype . '|' . $mode;
$fieldgroup->export_type = 0;
if (!isset($fieldgroup->disabled)) {
$fieldgroup->disabled = FALSE;
}
ctools_export_crud_save('field_group', $fieldgroup);
ctools_export_crud_set_status('field_group', $fieldgroup, $fieldgroup->disabled);
}
cache_clear_all('field_groups', 'cache_field');
}
}
}
field_info_cache_clear();
$form_state['redirect'] = str_replace("clone", "list", $bc_info[$entity_type]['clone_menu']['path']);
}
}