You are here

function _context_breakpoint_check_disable_cache in Context Breakpoint 7

If the contexts are added to the url, wee need to disable caching if the users contexts in the cookie differ from the ones in the url.

Returns flag whether caching should be disabled.

Return value

bool

1 call to _context_breakpoint_check_disable_cache()
context_breakpoint_init in ./context_breakpoint.module
Implements hook_init().

File

./context_breakpoint.module, line 49
context_screenresolution.module Main module file.

Code

function _context_breakpoint_check_disable_cache() {
  $disable = false;
  $settings = context_breakpoint_get_settings();
  if ($settings['breakpoints_in_url']) {
    $url = isset($_GET['context-breakpoints']) ? $_GET['context-breakpoints'] : null;
    $cookie = isset($_COOKIE['context_breakpoints']) ? $_COOKIE['context_breakpoints'] : null;
    if ($cookie === null) {

      // When no cookie is set, always diable caching to be sure.
      $disable = true;
    }
    else {
      if ($url === null) {

        // If no url is set, but the cookie contains an
        // active breakpoint, we have a mismatch.
        if ($cookie !== '') {
          return true;
        }
      }
      else {
        if ($url !== null && $cookie !== null) {

          // If they differ, caching should be disabled.
          $disable = $url !== $cookie;
        }
      }
    }
  }
  return $disable;
}