You are here

visitors.install in Visitors 8.2

Install/uninstall visitors module.

File

visitors.install
View source
<?php

/* vim: set filetype=php: */

/**
 * @file
 * Install/uninstall visitors module.
 */

/**
 * Implements hook_install().
 */
function visitors_install() {
  \Drupal::configFactory()
    ->getEditable('visitors.config')
    ->set('chart_height', 430)
    ->set('chart_width', 700)
    ->set('exclude_administer_users', 0)
    ->set('flush_log_timer', 0)
    ->set('items_per_page', 10)
    ->set('show_last_registered_user', 1)
    ->set('show_published_nodes', 1)
    ->set('show_registered_users_count', 1)
    ->set('show_since_date', 1)
    ->set('show_total_visitors', 1)
    ->set('show_unique_visitor', 1)
    ->set('show_user_ip', 1)
    ->set('start_count_total_visitors', 0)
    ->save();
}

/**
 * Uninstall the module with database table and module settings.
 */
function visitors_uninstall() {
  drupal_uninstall_schema('visitors');
  \Drupal::configFactory()
    ->getEditable('visitors.config')
    ->delete();
}

/**
 * Implementats of hook_schema().
 */
function visitors_schema() {
  $schema['visitors'] = array(
    'fields' => array(
      'visitors_id' => array(
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'visitors_uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'visitors_ip' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'visitors_date_time' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'visitors_url' => array(
        'type' => 'text',
        'not null' => TRUE,
      ),
      'visitors_referer' => array(
        'type' => 'text',
        'not null' => TRUE,
      ),
      'visitors_path' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'visitors_title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'visitors_user_agent' => array(
        'type' => 'text',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'visitors_id',
    ),
  );
  return $schema;
}

Functions

Namesort descending Description
visitors_install Implements hook_install().
visitors_schema Implementats of hook_schema().
visitors_uninstall Uninstall the module with database table and module settings.