You are here

uiplog.module in User IP Log 6

Same filename and directory in other branches
  1. 8 uiplog.module
  2. 7 uiplog.module
  3. 9.1.x uiplog.module

User IP Log module file.

File

uiplog.module
View source
<?php

/**
 * @file
 *   User IP Log module file.
 */

/**
 * Implementation of hook_form_alter()
 */
function uiplog_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_admin_settings') {
    $form['uiplog'] = array(
      '#type' => 'fieldset',
      '#title' => 'User IP Log Settings',
      '#weight' => -1,
    );
    $form['uiplog']['uiplog_user_delete_log'] = array(
      '#type' => 'radios',
      '#title' => t('User IP on account delete'),
      '#default_value' => variable_get('uiplog_user_delete_log', 1),
      '#options' => array(
        1 => t('Yes, Delete IP logged'),
        0 => t("No, Don't delete"),
      ),
      '#description' => t('Choose "Yes" to delete IP logging pertaining to user on his account delete. "No" to preserve all.'),
    );
  }
}

/**
 * Implementation of hook_views_api().
 */
function uiplog_views_api() {
  return array(
    'api' => views_api_version(),
    'path' => drupal_get_path('module', 'uiplog') . '/views',
  );
}

/**
 * Implementation of hook_user().
 */
function uiplog_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'login') {
    $ip_address = ip_address();
    if (filter_var($ip_address, FILTER_VALIDATE_IP)) {
      db_query('INSERT into {uiplog} (uid, ip, timestamp) VALUES (%d, "%s", %d)', $account->uid, $ip_address, time());
    }
  }
  else {
    if ($op == 'delete' && variable_get('uiplog_user_delete_log', 0) == 1) {
      db_query('DELETE FROM {uiplog} WHERE uid = %d', $account->uid);
    }
  }
}

Functions

Namesort descending Description
uiplog_form_alter Implementation of hook_form_alter()
uiplog_user Implementation of hook_user().
uiplog_views_api Implementation of hook_views_api().