You are here

function google_analytics_reports_requirements in Google Analytics Reports 7.3

Same name and namespace in other branches
  1. 6 google_analytics_reports/google_analytics_reports.install \google_analytics_reports_requirements()

Implements hook_requirements().

File

./google_analytics_reports.install, line 89
Contains install and update functions for Google Analytics Reports module.

Code

function google_analytics_reports_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break during installation.
  $t = get_t();

  // Do not install module if old Google Analytics Reports Views module
  // is exists.
  if ($phase == 'install' || $phase == 'runtime') {
    if (module_exists('google_analytics_reports_views')) {
      $requirements['google_analytics_reports_views'] = array(
        'title' => $t('Google Analytics Reports'),
        'value' => $t('You must uninstall and permanently delete all files of <strong>Google Analytics Reports Views</strong> module before installing the new version of Google Analytics Reports module.'),
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }

  // Warning about using Google Analytics Reports blocks without Ajax loading.
  if ($phase == 'runtime' && module_exists('blocks') && !module_exists('ajaxblocks')) {
    $theme_default = variable_get('theme_default');
    module_load_include('inc', 'block', 'block.admin');

    // List of all blocks.
    $blocks = block_admin_display_prepare_blocks($theme_default);
    foreach ($blocks as $block) {

      // Check if Google Analytics Reports blocks are enabled.
      if ($block['module'] == 'views' && $block['status'] && strpos($block['info'], 'Google Analytics Reports') === 0) {
        $requirements['google_analytics_reports_blocks'] = array(
          'title' => $t('Google Analytics Reports blocks'),
          'value' => $t('You are using Google Analytics Reports blocks which may increase page load time because of requests to Google Analytics. It is recommended to load these blocks using Ajax via !ajaxblocks module.', array(
            '!ajaxblocks' => l($t('Ajax Blocks'), 'https://www.drupal.org/project/ajaxblocks'),
          )),
          'severity' => REQUIREMENT_WARNING,
        );
      }
    }
  }
  return $requirements;
}