You are here

function rotor_submit in Rotor Banner 6

Same name and namespace in other branches
  1. 5.7 rotor.module \rotor_submit()
  2. 5 rotor.module \rotor_submit()
  3. 6.2 rotor.module \rotor_submit()
  4. 7 rotor.module \rotor_submit()

Node form submit function. We handle the image submition.

1 string reference to 'rotor_submit'
rotor_form in ./rotor.module
Node form hook

File

./rotor.module, line 374
A rotor banner consists in a set of images that will be changing. This module is made using jquery.

Code

function rotor_submit(&$node, &$form_state) {
  $upload_dir = file_directory_path();
  if (!empty($_FILES['files']['name']['rotor_image'])) {
    if (file_check_directory($upload_dir, FILE_CREATE_DIRECTORY)) {
      $file_saved = file_save_upload('rotor_image', array(), file_directory_path(), FILE_EXISTS_RENAME);
      if (!$file_saved) {
        drupal_set_message(t("The uploaded file %filename was unable to be saved. The destination directory may not be writable.", array(
          '%filename' => $file_saved['filename'],
        )), "error");
        watchdog('rotor', 'Imaged not saved: ' . $file_saved->file_path);
      }
      else {
        file_set_status($file_saved, FILE_STATUS_PERMANENT);
        $form_state['values']['rotor_image'] = $file_saved->filepath;
        watchdog('rotor', 'Imaged saved: ' . $file_saved->file_path);
      }
    }
    else {
      drupal_set_message(t("The uploaded file was unable to be saved. The destination directory does not exist."), "error");
    }
  }

  // Remove the target attribute if not selected.
  if (!$form_state['values']['link_target'] || $form_state['values']['link_target'] == "default") {
    unset($form_state['values']['link_target']);
  }
}