You are here

function ad_image_global_settings_submit in Advertisement 6.3

Same name and namespace in other branches
  1. 5.2 image/ad_image.module \ad_image_global_settings_submit()
  2. 5 image/ad_image.module \ad_image_global_settings_submit()
  3. 6 image/ad_image.module \ad_image_global_settings_submit()
  4. 6.2 image/ad_image.module \ad_image_global_settings_submit()
  5. 7 image/ad_image.module \ad_image_global_settings_submit()

Save min and max image width and height values for ad groups.

1 string reference to 'ad_image_global_settings_submit'
ad_image_global_settings in image/ad_image.module
Image ad settings form.

File

image/ad_image.module, line 209
Enhances the ad module to support banner ads.

Code

function ad_image_global_settings_submit($form, &$form_state) {
  variable_set('ad_image_remote_images', $form_state['values']['remote_images']);
  $groups = module_invoke('ad', 'groups_list', TRUE);
  foreach ($groups as $group) {

    // TODO: Update the database schema, convert gid to tid.
    $gid = db_result(db_query('SELECT gid FROM {ad_image_format} WHERE gid = %d', $group->tid));
    if (is_numeric($gid)) {
      db_query("UPDATE {ad_image_format} SET min_width = %d, max_width = %d, min_height = %d, max_height = %d, max_size = %d WHERE gid = %d", $form_state['values']["min-width-{$group->tid}"], $form_state['values']["max-width-{$group->tid}"], $form_state['values']["min-height-{$group->tid}"], $form_state['values']["max-height-{$group->tid}"], $form_state['values']["max-size-{$group->tid}"], $group->tid);
    }
    else {
      db_query("INSERT INTO {ad_image_format} (gid, min_width, max_width, min_height, max_height, max_size) VALUES (%d, %d, %d, %d, %d, %d)", $group->tid, $form_state['values']["min-width-{$group->tid}"], $form_state['values']["max-width-{$group->tid}"], $form_state['values']["min-height-{$group->tid}"], $form_state['values']["max-height-{$group->tid}"], $form_state['values']["max-size-{$group->tid}"]);
    }
  }
  drupal_set_message(t('Image ad global settings updated.'));
}