function sheetnode_import_template_submit in Sheetnode 7
Same name and namespace in other branches
- 5 sheetnode.module \sheetnode_import_template_submit()
- 6 sheetnode.module \sheetnode_import_template_submit()
- 7.2 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 561 - Module file for the sheetnode module.
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->language = LANGUAGE_NONE;
$node->sheetnode['value'] = $template->value;
$node->sheetnode['template'] = NULL;
// Let other modules alter the sheetnode or do other work.
$context = array(
'template' => $template,
);
drupal_alter('sheetnode_import', $node, $context);
// Save the sheetnode.
$node = node_submit($node);
node_save($node);
if (!empty($node->nid)) {
$form_state['redirect'] = 'node/' . $node->nid . '/edit';
}
}