You are here

function dynamic_background_admin_images_submit in Dynamic Background 6

Same name and namespace in other branches
  1. 7.2 includes/backgrounds.admin.inc \dynamic_background_admin_images_submit()
  2. 7 includes/backgrounds.admin.inc \dynamic_background_admin_images_submit()

Administration images form submittion handler.

1 string reference to 'dynamic_background_admin_images_submit'
dynamic_background_admin_images in includes/backgrounds.admin.inc
The image administation form.

File

includes/backgrounds.admin.inc, line 109
Implementation of the administration image upload and selecton form.

Code

function dynamic_background_admin_images_submit($form, &$form_state) {

  // Exclude unnecessary elements.
  unset($form_state['values']['submit'], $form_state['values']['reset'], $form_state['values']['form_id'], $form_state['values']['op'], $form_state['values']['form_token'], $form_state['values']['form_build_id']);

  // Active background enabled?
  $active = FALSE;

  // Build array with image informationer.
  $images_config = array();
  foreach ($form_state['values'] as $value) {
    $images_config[] = $value;

    // Save current selected image (so we load as little as possible in the front end).
    if ($value['picture_use']) {
      variable_set('dynamic_background_active', $value['default']);
      $active = TRUE;
    }
  }

  // Where a background selected, if not remove the previouse selected one.
  if (!$active) {
    variable_del('dynamic_background_active');
  }

  // Save the images information to the database.
  variable_set('dynamic_background_images', $images_config);
  drupal_set_message(t('The configuration options have been saved.'));
}