You are here

function authcache_admin_pagecaching_submit in Authenticated User Page Caching (Authcache) 6

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

Page caching rules form submit

File

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

Code

function authcache_admin_pagecaching_submit($form, &$form_state) {

  // Ignore AHAH events
  if ($form_state['clicked_button']['#id'] == 'edit-submit') {
    $pagecaching = array();
    foreach ($form_state['values']['ahah'] 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,
          '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.'));
  }
}