You are here

function fupload_list_images_submit in Image FUpload 6

Same name and namespace in other branches
  1. 6.3 includes/images.previewlist.inc \fupload_list_images_submit()
  2. 6.2 includes/images.previewlist.inc \fupload_list_images_submit()

File

includes/images.previewlist.inc, line 89

Code

function fupload_list_images_submit($form, &$form_state) {

  // get nids of images and start batch process (saving)
  $image_nids = explode(';', $form_state['values']['image_nodes']);
  for ($i = 0; $i < count($image_nids); $i++) {

    // load full node object
    $node = node_load($image_nids[$i]);

    // new changes to node object
    $node->status = 1;

    // publish node
    $node->title = !empty($form_state['values']['title_' . $image_nids[$i]]) ? check_plain($form_state['values']['title_' . $image_nids[$i]]) : $node->title;

    // work around [#227966]
    $node->body = $form_state['values']['body_' . $image_nids[$i]];
    if ($node->body == IMAGE_NOT_COMPLETED) {

      // nothing changed ==> empty body field
      $node->body = "";
    }
    $node->teaser = node_teaser($node->body, $form_state['values']['format_' . $image_nids[$i]]);
    $node->format = $form_state['values']['format_' . $image_nids[$i]];

    // save new node object
    node_save($node);
  }
  drupal_set_message(t('All images have been saved and published.'));
  drupal_set_message(t('Additonal images can be selected and uploaded now.'));
  drupal_redirect_form($form);
}