You are here

function theme_restrict_by_ip_login_list in Restrict Login or Role Access by IP Address 7.3

Same name and namespace in other branches
  1. 6.3 restrict_by_ip.module \theme_restrict_by_ip_login_list()

Theme function to return a list of existing IP restrictions on user login.

1 theme call to theme_restrict_by_ip_login_list()
restrict_by_ip_login_settings in ./restrict_by_ip.module
Menu callback for restrict login settings

File

./restrict_by_ip.module, line 640
Allows the admin to select which ip addresses role or a user can login from for this site Some of the code below is taken from the cck_ipaddress_module

Code

function theme_restrict_by_ip_login_list() {
  $header = array(
    t("Username"),
    t("IP Restriction"),
    t("Edit"),
  );
  $rows = array();
  $output = '';

  // Handle user one as a special case
  $row = db_query("SELECT u.name, rbi.restrict_by_ip_address as restriction FROM {users} u LEFT JOIN {restrict_by_ip} rbi ON rbi.uid = u.uid WHERE u.uid = 1 ")
    ->fetchObject();
  $rows[] = array(
    $row->name . ' (DRUPAL USER 1)',
    isset($row->restriction) ? $row->restriction : '<strong><span style="color: red">No Restriction</span></strong>',
    l('edit', 'admin/config/people/restrict_by_ip/login/edit/1', array(
      'query' => array(
        'destination' => 'admin/config/people/restrict_by_ip/login',
      ),
    )),
  );

  // Grab all other restrictions and list beneath
  $result = db_query("SELECT u.name, rbi.uid, rbi.restrict_by_ip_address as restriction FROM {restrict_by_ip} rbi INNER JOIN {users} u ON rbi.uid = u.uid WHERE u.uid != 1 ORDER BY rbi.uid ASC");
  foreach ($result as $row) {
    $rows[] = array(
      $row->name,
      $row->restriction,
      l('edit', 'admin/config/people/restrict_by_ip/login/edit/' . $row->uid, array(
        'query' => array(
          'destination' => 'admin/config/people/restrict_by_ip/login',
        ),
      )),
    );
  }
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
  $output .= l('Add new IP restriction for user', 'admin/config/people/restrict_by_ip/login/add', array(
    'query' => array(
      'destination' => 'admin/config/people/restrict_by_ip/login',
    ),
  ));
  return $output;
}