You are here

function authcache_admin_pagecaching_submit in Authenticated User Page Caching (Authcache) 7

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

Page caching rules form submit

File

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

Code

function authcache_admin_pagecaching_submit($form, &$form_state) {
  $pagecaching = array();
  foreach ($form_state['values']['ajax'] as $key => $ray) {
    $values = $ray['fieldset'];
    if ($values['pages']) {
      $pagecaching[$key] = $values;
    }
    if (!array_sum($values['roles'])) {
      drupal_set_message(t('Ruleset #%key is disabled since no roles are associated with it.', array(
        '%key' => $key + 1,
      )), 'warning');
    }
  }
  if (!empty($pagecaching)) {
    variable_set('authcache_pagecaching', $pagecaching);
  }
  else {
    variable_set('authcache_pagecaching', array(
      array(
        'option' => 0,
        'pages' => AUTHCACHE_NOCACHE_DEFAULT,
        'noadmin' => 1,
        'roles' => $cache_roles,
      ),
    ));
  }
  variable_set('authcache_nonhtml', $form_state['values']['nonhtml']);
  drupal_set_message(t('Your page caching settings have been saved.'));
  cache_clear_all();
  drupal_set_message(t('Cached pages cleared.'));
}