You are here

function devel_generate_node_insert in Devel 7

Inserts nodes properly based on generation options.

Parameters

$node: The base node created on submit. Inspects $node->devel_generate.

File

devel_generate/devel_generate.module, line 375

Code

function devel_generate_node_insert($node) {
  if (isset($node->devel_generate)) {
    $results = $node->devel_generate;
    if (!empty($results['max_comments']) && $node->comment >= COMMENT_NODE_OPEN) {
      devel_generate_add_comments($node, $results['users'], $results['max_comments'], $results['title_length']);
    }

    // Add an url alias. Cannot happen before save because we don't know the nid.
    if (!empty($results['add_alias'])) {
      $path = array(
        'source' => 'node/' . $node->nid,
        'alias' => 'node-' . $node->nid . '-' . $node->type,
      );
      path_save($path);
    }

    // Add node statistics.
    if (!empty($results['add_statistics']) && module_exists('statistics')) {
      devel_generate_add_statistics($node);
    }
  }
}