You are here

function node_convert_template_delete_confirm_submit in Node Convert 7

Same name and namespace in other branches
  1. 6 node_convert.module \node_convert_template_delete_confirm_submit()

Submit callback for delete template confirmation form.

File

./node_convert.admin.inc, line 89
Administration page callbacks for the node_convert module.

Code

function node_convert_template_delete_confirm_submit($form, &$form_state) {
  if ($form_state['values']['confirm']) {
    ctools_include('export');
    $template = ctools_export_load_object(NODE_CONVERT_TEMPLATE_TABLE, 'conditions', array(
      'nctid' => $form_state['values']['template_id'],
    ));
    $template = array_shift($template);
    node_convert_delete_template($template);
    if ($form_state['values']['delete_action'] == 1) {
      db_delete('actions')
        ->condition('callback', 'node_convert_convert_action')
        ->condition('parameters', '%template";s:%:"' . $form_state['values']['template_id'] . '%', 'LIKE')
        ->execute();
    }
    else {
      $none = serialize(array(
        'template' => '0',
      ));
      db_update('actions')
        ->fields(array(
        'parameters' => $none,
      ))
        ->condition('callback', 'node_convert_convert_action')
        ->condition('parameters', '%template";s:%:"' . $form_state['values']['template_id'] . '%', 'LIKE')
        ->execute();
    }
  }
  $form_state['redirect'] = 'admin/structure/node_convert_templates';
}