You are here

function flickrstyle_admin_settings_submit in Flickr 7

Submit form data.

1 string reference to 'flickrstyle_admin_settings_submit'
flickrstyle_form_flickr_admin_settings_alter in style/flickrstyle.admin.inc
Implements hook_form_FORM_ID_alter().

File

style/flickrstyle.admin.inc, line 267
The admin settings for the Flickr Style module.

Code

function flickrstyle_admin_settings_submit($form, &$form_state) {
  if (variable_get('flickr_css', 1) && module_exists('style_settings')) {

    // Rounded corners: concatenate the value and unit.
    variable_set('flickrstyle_radius', $form_state['values']['flickrstyle_radius_value'] . $form_state['values']['flickrstyle_radius_unit']);

    // IMAGE UPLOAD.
    if (!empty($form_state['values']['flickrstyle_magnifier_imgupload'])) {
      $image = file_load($form_state['values']['flickrstyle_magnifier_imgupload']);
      $url = '/' . variable_get('file_public_path', conf_path() . '/files') . '/' . file_uri_target($image->uri);
      variable_set('flickrstyle_magnifier_imgupload_url', $url);

      // If we have an uploaded file, use the URL of it.
      $form_state['values']['flickrstyle_magnifier_image'] = $url;
      $image->status = FILE_STATUS_PERMANENT;
      file_save($image);

      // Add a reference to prevent warnings.
      file_usage_add($image, 'flickrstyle', 'flickrstyle_upload', $image->fid);
    }

    // IMAGE URL: Reset to default if empty. Does not work after a
    // hook_form_FORM_ID_alter(). In that case move it to the submit handler
    // after hook_settings() in the 'parent' form.
    if (trim($form_state['values']['flickrstyle_magnifier_image']) == '') {
      $form_state['values']['flickrstyle_magnifier_image'] = '/' . drupal_get_path('module', 'flickrstyle') . '/img/magnifier.png';
      drupal_set_message(t('The image URL has been reset to the default.'), 'warning', FALSE);
    }
    variable_set('flickrstyle_magnifier_halfsize', '-' . floatval($form_state['values']['flickrstyle_magnifier_size']) / 2 . 'px');
    variable_set('flickrstyle_border_thickness_doubled', floatval($form_state['values']['flickrstyle_border_thickness']) * 2 . 'px');
  }
}