You are here

function dynamic_background_admin_images_submit in Dynamic Background 7.2

Same name and namespace in other branches
  1. 6 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.

File

includes/backgrounds.admin.inc, line 179
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;

  // Set currently active background image.
  foreach ($form_state['values'] as $field => $data) {
    if (preg_match('/^image_(\\d{1,2})/', $field) && isset($data['picture_use']) && $data['picture_use']) {
      dynamic_background_set_active($data['fid'], 'default', -1);
      $active = TRUE;
    }
  }

  // If no active background where selecte, remove the previouse selected one.
  if (!$active) {
    dynamic_background_set_active(NULL, 'default', -1);
  }
  drupal_set_message(t('The configuration options have been saved.'));
}