You are here

record_shorten_views_handler_field_hostname.inc in Shorten URLs 8

A Views field handler for users' IP address.

File

modules/record_shorten/record_shorten_views_handler_field_hostname.inc
View source
<?php

/**
 * @file
 *   A Views field handler for users' IP address.
 */

/**
 * Restricts access to viewing the IP address field.
 * There doesn't seem to be a standard for what permissions are necessary.
 */
class record_shorten_views_handler_field_hostname extends views_handler_field {
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['notice'] = array(
      '#value' => '<p class="form-item"><strong>' . t('Users must have both the "administer users" and "access site reports" permission to view this field.') . '</strong></p>',
      '#weight' => -10,
    );
  }
  function render($values) {
    if (!\Drupal::currentUser()
      ->hasPermission('administer users') || !\Drupal::currentUser()
      ->hasPermission('access site reports')) {
      return;
    }
    return parent::render($values);
  }

}

Classes

Namesort descending Description
record_shorten_views_handler_field_hostname Restricts access to viewing the IP address field. There doesn't seem to be a standard for what permissions are necessary.