You are here

function authcache_admin_config_submit in Authenticated User Page Caching (Authcache) 7.2

Same name and namespace in other branches
  1. 6 authcache.admin.inc \authcache_admin_config_submit()
  2. 7 authcache.admin.inc \authcache_admin_config_submit()

Authcache config form submit.

File

./authcache.admin.inc, line 113
Admin forms and pages.

Code

function authcache_admin_config_submit($form, &$form_state) {

  // Roles.
  $cache_roles = drupal_map_assoc(array_filter($form_state['values']['authcache_roles']));

  // Figure out key lifetime.
  if ($form_state['values']['key_lifetime'] === 'session') {
    variable_del('authcache_key_lifetime');
  }
  else {
    variable_set('authcache_key_lifetime', $form_state['values']['key_lifetime']);
  }

  // Delete variable if not in use.
  foreach (array(
    'http200',
    'su',
    'noajax',
    'mimetype',
  ) as $key) {
    if ($value = $form_state['values'][$key]) {
      variable_set("authcache_{$key}", $value);
    }
    else {
      variable_del("authcache_{$key}");
    }
  }
  variable_set('authcache_roles', $cache_roles);
  drupal_set_message(t('Your Authcache settings have been saved.'));
  cache_clear_all('*', 'cache_page', TRUE);
  drupal_set_message(t('Cached pages cleared.'));
}