You are here

function superfish_menu_settings_submit in Superfish 6

Custom submission handler for the settings form.

1 string reference to 'superfish_menu_settings_submit'
superfish_system_settings_form in ./superfish.admin.inc
Overriding system settings form.

File

./superfish.admin.inc, line 113
Functions that are only called on the admin pages.

Code

function superfish_menu_settings_submit($form, &$form_state) {
  $values =& $form_state['values'];
  $before = variable_get('superfish_number', 4);
  $after = $values['superfish_number'];

  // If the number of blocks has been decreased.
  if ($before > $after) {

    // How many blocks should be removed?
    $reduce = $before - $after;

    // Remove each block with all its variables.
    $delta = $after;
    for ($i = 0; $i < $reduce; $i++) {
      $delta++;
      db_query("DELETE FROM {variable} WHERE name LIKE 'superfish_%%_" . $delta . "'");
      db_query("DELETE FROM {blocks} WHERE module = 'superfish'");
      db_query("DELETE FROM {blocks_roles} WHERE module = 'superfish'");
    }
    drupal_set_message(t('Successfully removed @number Superfish block(s).', array(
      '@number' => $reduce,
    )));
  }
}