function gathercontent_mapping_form_templates_submit in GatherContent 7.3
Submit callback for Gather Content template import.
@inheritdoc
File
- forms/
gathercontent.mapping-create.inc, line 96 - Multistep mapping form.
Code
function gathercontent_mapping_form_templates_submit($form, &$form_state) {
if ($form_state['triggering_element']['#id'] == 'edit-submit') {
// Load all projects.
$pr_obj = new Project();
$projects = $pr_obj
->getProjects();
foreach ($form_state['values'] as $k => $tree) {
if (!is_array($tree)) {
continue;
}
$templates = array_filter($form_state['values'][$k]['templates']);
foreach ($templates as $template_id => $selected) {
$tmp_obj = new Template();
$template = $tmp_obj
->getTemplate($template_id);
$mapping_values = array(
'gathercontent_project_id' => $template->project_id,
'gathercontent_project' => $projects[$template->project_id],
'gathercontent_template_id' => $template_id,
'gathercontent_template' => $template->name,
'created' => time(),
'updated_gathercontent' => $template->updated_at,
'template' => serialize($template),
);
$mapping = entity_create('gathercontent_mapping', $mapping_values);
if (is_object($mapping)) {
$mapping
->save();
}
}
}
}
drupal_goto('admin/config/gathercontent/mapping');
}