You are here

function _calendar_systems_is_patch_applied in Calendar Systems 7

Same name and namespace in other branches
  1. 8 calendar_systems.helpers.inc \_calendar_systems_is_patch_applied()
  2. 7.2 calendar_systems.helpers.inc \_calendar_systems_is_patch_applied()

Internal helper to check whether the required patch is applied or not.

Return value

Boolean value.

6 calls to _calendar_systems_is_patch_applied()
calendar_systems_format_date in ./calendar_systems.module
Simulating core format_date in case the patch wasn't applied Formats a date, using a date type or a custom date format string.
calendar_systems_form_alter in ./calendar_systems.module
Implements hook_form_alter().
calendar_systems_preprocess_comment in ./calendar_systems.module
The usage is to improve compatibility when the core patch is not available Implements hook_preprocess_comment().
calendar_systems_preprocess_node in ./calendar_systems.module
The usage is to improve compatibility when the core patch is not available Implements hook_preprocess_node().
calendar_systems_profile_overview in ./calendar_systems.admin.inc
Form callback for calendar systems profiles.

... See full list

File

./calendar_systems.helpers.inc, line 84

Code

function _calendar_systems_is_patch_applied($cache = TRUE) {
  static $result;
  if ($cache) {
    $cache_object = cache_get('calendar_systems_is_patch_applied');
    if (is_object($cache_object)) {
      $result = $cache_object->data;
    }
  }
  if (is_null($result)) {
    $content = file_get_contents(DRUPAL_ROOT . '/includes/common.inc');

    // Check against patch fingerprint:
    $very_old_patch_applied = strpos($content, 'foreach (module_implements(\'format_date\') AS $module) {') !== FALSE ? TRUE : FALSE;
    $old_patch_applied = strpos($content, 'foreach (module_implements(\'format_date_calendar_systems\') AS $module) {') !== FALSE ? TRUE : FALSE;
    $applied = strpos($content, 'drupal_alter(\'format_date\'') !== FALSE ? TRUE : FALSE;
    if ($applied) {
      $result = TRUE;
    }
    elseif ($old_patch_applied || $very_old_patch_applied) {
      $result = 'outdated';
    }
    else {
      $result = FALSE;
    }
    cache_set('calendar_systems_is_patch_applied', $result, 'cache', REQUEST_TIME + 60 * 60);
  }
  return $result;
}