You are here

function sheetnode_import_template_submit in Sheetnode 6

Same name and namespace in other branches
  1. 5 sheetnode.module \sheetnode_import_template_submit()
  2. 7.2 sheetnode.module \sheetnode_import_template_submit()
  3. 7 sheetnode.module \sheetnode_import_template_submit()

Submit function for sheetnode_import_template form.

1 call to sheetnode_import_template_submit()
sheetnode_import_template in ./sheetnode.module
Form function for node/add/sheetnode_template.

File

./sheetnode.module, line 521

Code

function sheetnode_import_template_submit($form, &$form_state) {
  global $user;
  module_load_include('inc', 'node', 'node.pages');
  $template = _sheetnode_template_load($form_state['values']['template']);
  $node = new StdClass();
  $node->type = 'sheetnode';
  node_object_prepare($node);
  $node->title = $template->name;
  $node->name = $user->name;
  $node->sheetnode['value'] = $template->value;
  $node->sheetnode['template'] = NULL;

  // Let other modules alter the sheetnode or do other work.
  drupal_alter('sheetnode_import', $node, array(), array(
    'template' => $template,
  ));

  // Save the sheetnode.
  $node = node_submit($node);
  node_save($node);
  if (!empty($node->nid)) {
    $form_state['redirect'] = 'node/' . $node->nid . '/edit';
  }
}