You are here

function _fupload_node_save in Image FUpload 6.3

1 call to _fupload_node_save()
image_fupload_imagefield_node_create in image_fupload_imagefield/image_fupload_imagefield.module

File

image_fupload_imagefield/image_fupload_imagefield.module, line 618

Code

function _fupload_node_save(&$form, $form_state, $form_build_id) {
  $node = node_form_submit_build_node($form, $form_state);
  $insert = empty($node->nid);

  // save node
  node_save($node);

  // report to watchdog
  $node_link = l(t('view'), 'node/' . $node->nid);
  $watchdog_args = array(
    '@type' => $node->type,
    '%title' => $node->title,
  );
  $t_args = array(
    '@type' => node_get_types('name', $node),
    '%title' => $node->title,
  );
  if ($insert) {
    watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
    drupal_set_message(t('@type %title has been created.', $t_args));
  }
  if ($node->nid) {

    // will be saved in cache so that only one gallery node will be created
    $form['gallery_nid']['#value'] = $node->nid;
    $form_state['values']['gallery_nid'] = $node->nid;

    // save form to cache
    form_set_cache($form_build_id, $form, $form_state);
    return $node;
  }
  else {

    // In the unlikely case something went wrong on save, the node will be
    // rebuilt and node form redisplayed the same way as in preview.
    drupal_set_message(t('The post could not be saved.'), 'error');
    return FALSE;
  }
}