function google_analytics_counter_requirements in Google Analytics Counter 7.2
Same name and namespace in other branches
- 8.3 google_analytics_counter.install \google_analytics_counter_requirements()
- 7.3 google_analytics_counter.install \google_analytics_counter_requirements()
Implements hook_requirements().
File
- ./
google_analytics_counter.install, line 103 - Install, update, and uninstall functions for the Google Analytics Counter module.
Code
function google_analytics_counter_requirements($phase) {
$requirements = array();
// Ensure translations don't break at install time
$t = get_t();
// Verify that the user has authenticated with Google Analytics. If not, display a warning on the status page.
if ($phase == 'runtime') {
$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>.', array(
'%google_analytics_counter_profile_id',
variable_get('google_analytics_counter_profile_id', 0),
)),
'severity' => REQUIREMENT_OK,
'value' => $t('A Google Analytics profile is authenticated: OK'),
);
$requirements['google_analytics_counter_core_statistics'] = array(
'title' => $t('Drupal core statistics counter'),
'description' => $t('Drupal core statistics <a href="/admin/config/system/statistics">counter</a> is switched off to allow Google Analytics Counter provide the values.'),
'severity' => REQUIREMENT_OK,
'value' => $t('Core statistics counter is off: 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!');
}
$corestats = variable_get('statistics_count_content_views');
// Core statistics module counter must be switched off
if ($corestats == 1) {
$requirements['google_analytics_counter_core_statistics']['title'] = $t('Drupal core statistics counter is switched on');
$requirements['google_analytics_counter_core_statistics']['description'] = $t('Drupal core statistics counter must be switched off. At the moment its values are being overwritten by those from Google Analytics Counter (and vice versa). Please switch it off <a href="/admin/config/system/statistics">here</a>.');
$requirements['google_analytics_counter_core_statistics']['severity'] = REQUIREMENT_ERROR;
$requirements['google_analytics_counter_core_statistics']['value'] = $t('Drupal core statistics module must be switched off!');
}
}
return $requirements;
}