You are here

function menu_badges_tabs_admin_form_submit in Menu Badges 7

Submit handler for tabs admin form.

_state

Parameters

$form:

File

./menu_badges.admin.inc, line 96
Menu Badges admin forms.

Code

function menu_badges_tabs_admin_form_submit(&$form, &$form_state) {
  if ($form_state['values']['op'] == $form_state['values']['search']['search']) {
    $form_state['rebuild'] = TRUE;
  }
  else {
    $tab_badges = variable_get('menu_badges_tab_callbacks', array());
    $badges = menu_badges_get_badges();
    foreach (array_keys($form_state['values']['results']) as $path) {
      if (!empty($form_state['values']['results'][$path]['menu_badges_callback'])) {
        $tab_badges[$path] = array(
          'callback' => $badges[$form_state['values']['results'][$path]['menu_badges_callback']]['callback'],
          'key' => $badges[$form_state['values']['results'][$path]['menu_badges_callback']]['key'],
        );
        if (!empty($badges[$form_state['values']['results'][$path]['menu_badges_callback']]['arguments'])) {
          $tab_badges[$path]['arguments'] = $badges[$form_state['values']['results'][$path]['menu_badges_callback']]['arguments'];
        }
      }
      else {
        unset($tab_badges[$path]);
      }
    }
    variable_set('menu_badges_tab_callbacks', $tab_badges);
    drupal_set_message(t('Tab menu badges saved.'));
    $form_state['rebuild'] = TRUE;
  }
}