You are here

function bakery_settings_submit in Bakery Single Sign-On System 7.2

Same name and namespace in other branches
  1. 6.2 bakery.module \bakery_settings_submit()
  2. 6 bakery.module \bakery_settings_submit()
  3. 7.4 bakery.module \bakery_settings_submit()
  4. 7.3 bakery.pages.inc \bakery_settings_submit()

Submit handler for 'bakery_settings' form.

1 string reference to 'bakery_settings_submit'
bakery_settings in ./bakery.module
Bakery settings form.

File

./bakery.module, line 653
Module file for the Bakery.

Code

function bakery_settings_submit($form, &$form_state) {

  // Rebuild the menu because the router items are based on the selection of
  // the master site. (Rebuilding it immediately here would be too early,
  // because the 'bakery_is_master' variable doesn't get set until the next
  // submit handler runs. So we trigger a rebuild on the next page request
  // instead.)
  variable_set('menu_rebuild_needed', TRUE);

  // Updating of data on slave sites will not work unless
  // the url of the master site has a trailing slash.
  // We now remove the trailing slash (if present)
  // and concatenate with a new trailing slash.
  $form_state['values']['bakery_master'] = trim($form_state['values']['bakery_master'], '/') . '/';

  // The list of slave sites needs transforming from a text string into
  // array for storage.
  // Also, redirection after login will only work
  // if there is a trailing slash after each entry.
  if ($form_state['values']['bakery_slaves']) {

    // Transform the text string into an array.
    $form_state['values']['bakery_slaves'] = explode("\n", trim(str_replace("\r", '', $form_state['values']['bakery_slaves'])));

    // For each entry, remove the trailing slash (if present)
    // and concatenate with a new trailing slash.
    foreach ($form_state['values']['bakery_slaves'] as &$slave) {
      $slave = trim($slave, '/') . '/';
    }
  }
  else {
    $form_state['values']['bakery_slaves'] = array();
  }
}