You are here

function google_analytics_counter_requirements in Google Analytics Counter 7.3

Same name and namespace in other branches
  1. 8.3 google_analytics_counter.install \google_analytics_counter_requirements()
  2. 7.2 google_analytics_counter.install \google_analytics_counter_requirements()

Implements hook_requirements().

File

./google_analytics_counter.install, line 112
Update, and uninstall functions for the Google Analytics Counter module.

Code

function google_analytics_counter_requirements($phase) {
  $requirements = array();
  $t = get_t();

  // Verify that the user has authenticated with Google Analytics.
  // If not, display a warning on the status page.
  if ($phase == 'runtime') {
    $params = array(
      '%google_analytics_counter_profile_id' => variable_get('google_analytics_counter_profile_id', 0),
    );
    $requirements['google_analytics_counter_authentication'] = array(
      'title' => $t('Google Analytics Counter'),
      'description' => $t('Google Analytics account ga:%google_analytics_counter_profile_id has been authenticated. You can change it or revoke authentication <a href="/admin/config/system/google_analytics_counter/authentication">here</a>.', $params),
      'severity' => REQUIREMENT_OK,
      'value' => $t('A Google Analytics profile is authenticated: OK'),
    );
    $authenticated = FALSE;

    // It's a weak test but better than none.
    if (variable_get('google_analytics_counter_profile_id') != '') {
      $authenticated = TRUE;
    }
    if (!$authenticated) {
      $requirements['google_analytics_counter_authentication']['title'] = $t('Google Analytics Counter requirements');
      $requirements['google_analytics_counter_authentication']['description'] = $t('No Google Analytics profile has been authenticated. Google Analytics Counter can not fetch any new data. Please authenticate <a href="/admin/config/system/google_analytics_counter/authentication">here</a>.');
      $requirements['google_analytics_counter_authentication']['severity'] = REQUIREMENT_ERROR;
      $requirements['google_analytics_counter_authentication']['value'] = $t('No Google Analytics profile has been authenticated!');
    }
  }
  return $requirements;
}