You are here

function _print_main_settings_validate in Printer, email and PDF versions 5.4

Same name and namespace in other branches
  1. 5.3 print.admin.inc \_print_main_settings_validate()
  2. 6 print.admin.inc \_print_main_settings_validate()
  3. 7.2 print.admin.inc \_print_main_settings_validate()
  4. 7 print.admin.inc \_print_main_settings_validate()
  5. 5.x print.admin.inc \_print_main_settings_validate()

Validate print_main_settings form.

File

./print.admin.inc, line 166
Contains the administrative functions of the PF module.

Code

function _print_main_settings_validate($form_id, $form_values, $form) {
  global $base_url;

  // Check for a new uploaded logo, and use that instead.
  if ($file = file_check_upload('print_logo_upload')) {
    if ($info = image_get_info($file->filepath)) {
      $parts = pathinfo($file->filename);
      $filename = 'print_logo.' . strtolower($parts['extension']);
      if ($file = file_save_upload('print_logo_upload', $filename, 1)) {
        form_set_value($form['settings']['logo']['print_logo_options'], 2);
        form_set_value($form['settings']['logo']['print_logo_url'], base_path() . $file->filepath);
      }
    }
    else {
      form_set_error('print_logo_upload', t('Only JPEG, PNG and GIF images are allowed to be used as logos.'));
    }
  }
}