You are here

statcounter.install in StatCounter 7.2

Same filename and directory in other branches
  1. 5 statcounter.install
  2. 6 statcounter.install

Installation file for Statcounter - Web analytics module.

File

statcounter.install
View source
<?php

/**
 * @file
 * Installation file for Statcounter - Web analytics module.
 */
function statcounter_install() {

  // Remove tracking from all administrative pages, see http://drupal.org/node/34970.
  variable_set('statcounter_visibility_roles', 0);
  variable_set('statcounter_visibility_pages', 0);
  $pages = array(
    'admin',
    'admin/*',
    'batch',
    'node/add*',
    'node/*/*',
    'user/*/*',
  );
  variable_set('statcounter_pages', implode("\n", $pages));
}
function statcounter_uninstall() {
  variable_del('statcounter_cache');
  variable_del('statcounter_custom');
  variable_del('statcounter_js_scope');
  variable_del('statcounter_last_cache');
  variable_del('statcounter_pages');
  variable_del('statcounter_privacy_donottrack');
  variable_del('statcounter_roles');
  variable_del('statcounter_project_id');
  variable_del('statcounter_security_code');
  variable_del('statcounter_visibility_pages');
  variable_del('statcounter_visibility_roles');
  variable_del('statcounter_invisible_tracking');
}

/**
 * Remove cache directory if module is disabled (or uninstalled).
 */
function statcounter_disable() {
  statcounter_clear_js_cache();
}

/**
 * Implements hook_requirements().
 */
function statcounter_requirements($phase) {
  $requirements = array();
  $t = get_t();
  switch ($phase) {
    case 'runtime':

      // Module cannot validate statcounter URL without external HTTP requests.
      if (variable_get('drupal_http_request_fails', TRUE) && !system_check_http_request()) {
        $requirements['http requests'] = array(
          'title' => $t('HTTP request status'),
          'value' => $t('Fails'),
          'severity' => REQUIREMENT_ERROR,
          'description' => $t('Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services.'),
        );
      }

      // Raise warning if Statcounter user account has not been set yet.
      if (!preg_match('/^\\d{1,}$/', variable_get('statcounter_project_id', ''))) {
        $requirements['statcounter'] = array(
          'title' => $t('Statcounter module'),
          'description' => $t('Statcounter module has not been configured yet. Please configure its settings from the <a href="@url">Statcounter settings page</a>.', array(
            '@url' => url('admin/config/system/statcounter'),
          )),
          'severity' => REQUIREMENT_ERROR,
          'value' => $t('Not configured'),
        );
      }
      break;
  }
  return $requirements;
}

Functions

Namesort descending Description
statcounter_disable Remove cache directory if module is disabled (or uninstalled).
statcounter_install @file Installation file for Statcounter - Web analytics module.
statcounter_requirements Implements hook_requirements().
statcounter_uninstall