You are here

function mostpopular_services_form_submit in Drupal Most Popular 6

File

./mostpopular.admin.inc, line 429
Defines all the administration forms for the Most Popular module.

Code

function mostpopular_services_form_submit($form, $form_state) {
  $reset_menu = TRUE;
  switch ($form_state['values']['op']) {

    // Action: Reset Titles
    case $form_state['values']['reset']:
      MostPopularService::reset();
      drupal_set_message(t('Reset all service titles to their default values.'));
      break;

    // Action: Clear all cached values
    case $form_state['values']['clear']:
      mostpopular_clear_caches();
      $reset_menu = FALSE;

    // Fall through
    // Action: Save Configuration
    default:
      $services = $form_state['values']['services'];
      foreach ($services as $i => $service) {
        $s = unserialize($service['service']);
        unset($service['service']);
        $s
          ->update($service);
        $s
          ->save();
      }
      drupal_set_message(t('The service configuration has been saved.'));
  }

  // Rebuild the menus so we can create a menu item for each service.
  if ($reset_menu) {
    menu_rebuild();
  }
}