You are here

function theme_ip_tracker_user_records in IP address manager 7

Same name and namespace in other branches
  1. 6 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 214
IP address manager module.

Code

function theme_ip_tracker_user_records($variables) {
  $account =& $variables['account'];

  // Set the page title.
  drupal_set_title(t('Manage IP addresses for @user', array(
    '@user' => format_username($account),
  )));
  $out = '';

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

    // Create a table header.
    $header = array(
      t('IP address'),
      t('Visits'),
      t('First visit'),
      t('Last visit'),
      t('User count'),
    );
    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,
        )), 'admin/people/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, 'admin/people/ip/' . $record->ip),
        $record->visits,
        format_date($record->first_visit),
        format_date($record->last_visit),
        $count_field,
      );
    }
    $out = theme('table', array(
      'header' => $header,
      'rows' => $rows,
    ));
  }
  return $out;
}