You are here

function theme_ip_tracker_user_records in IP address manager 6

Same name and namespace in other branches
  1. 7 ip.module \theme_ip_tracker_user_records()

Theme the IP tracker records for a user.

1 theme call to theme_ip_tracker_user_records()
ip_user_manage in ./ip.module
Page callback for user IP address management.

File

./ip.module, line 164
IP address manager module.

Code

function theme_ip_tracker_user_records($account) {

  // Set the page title.
  drupal_set_title(t('Manage IP addresses for %user', array(
    '%user' => $account->name,
  )));

  // Get the record data.
  $records = ip_tracker_user_records($account->uid);

  // Create a table header.
  $header = array(
    t('IP address'),
    t('Visits'),
    t('First visit'),
    t('Last visit'),
    t('User count'),
    t('Operations'),
  );
  foreach ($records as $record) {

    // Count the users tracked using this IP.
    $count = ip_tracker_ip_user_count($record['ip']);
    if ($count > 1) {

      // There are multiple users recorded with this IP - link to the IP page.
      $count_field = l(t('!count users', array(
        '!count' => $count,
      )), 'user/ip/' . $record['ip']);
    }
    else {

      // There is only this user recorded with this IP.
      $count_field = t('1 user');
    }

    // Build a table row.
    $rows[] = array(
      l($record['ip'], 'user/ip/' . $record['ip']),
      $record['visits'],
      format_date($record['first_visit']),
      format_date($record['last_visit']),
      $count_field,
      l(t('Ban IP'), 'admin/user/rules/add/' . $record['ip'] . '/host'),
    );
  }
  $out = theme('table', $header, $rows);
  return $out;
}