You are here

function _cdn_requirements_detect_fallback in CDN 6.2

Detect whether the fallback mechanism (to alter file URLs, the best mechanism is the core patch, but a fallback to the theme layer is included) should be enabled or disabled, and actually enable/disable it, too.

1 call to _cdn_requirements_detect_fallback()
cdn_requirements in ./cdn.install
Implementation of hook_requirements().

File

./cdn.requirements.inc, line 162
Functionality to automatically detect if a patch has been applied.

Code

function _cdn_requirements_detect_fallback() {

  // Check if the core patch is applied properly (i.e. no core files don't
  // properly match the core patch). If it is properly applied, then the
  // fallback will be (or remain) disabled, if not, then the fallback will be
  // (or remain) enabled.
  $fallback_currently_enabled = variable_get(CDN_THEME_LAYER_FALLBACK_VARIABLE, FALSE);
  if (_cdn_requirements_is_patched_distribution() === FALSE && count(_cdn_requirements_check_patch_applied(_cdn_requirements_core_patch_patterns())) > 0) {
    if (!$fallback_currently_enabled) {
      variable_set(CDN_THEME_LAYER_FALLBACK_VARIABLE, TRUE);
      drupal_rebuild_theme_registry();
      drupal_set_message(t("Drupal CDN integration status changed: core patch not (properly) applied; fallback mechanism enabled."), 'warning');
      watchdog('cdn', "Drupal CDN integration status changed: core patch not (properly) applied; fallback mechanism enabled.");
    }
  }
  else {
    if ($fallback_currently_enabled) {
      variable_set(CDN_THEME_LAYER_FALLBACK_VARIABLE, FALSE);
      drupal_rebuild_theme_registry();
      drupal_set_message(t("Drupal CDN integration status changed: core patch properly applied; fallback mechanism disabled."), 'warning');
      watchdog('cdn', "Drupal CDN integration status changed: core patch properly applied; fallback mechanism disabled.");
    }
  }
}