The attached patch, rolled against 7.x-2.x-dev provides Views integration for the ip_login_user data table.

It also provides a default view to list IP Login users at admin > people > ip login

Attached,

cheers,

DT

Comments

davidwhthomas’s picture

StatusFileSize
new19.63 KB

Updated patch, to supersede the first, that includes the hook_views_api in ip_login.module

davidwhthomas’s picture

StatusFileSize
new90.84 KB

Here's a somewhat redacted screenshot of the default IP Login users view attached.

davidwhthomas’s picture

I'm looking into a patch to provide a Field API field for IP Login, perhaps using the field_ipaddress module.

The Field API automatically provides Views integration, so this patch can probably wait until then.

It does work on the current codebase however.

jim kirkpatrick’s picture

I reckon having the IP Address Field module as a dependency is the best move, since that module will mean we can abstract all storage/validation for IP addresses to something that specialises in it.

There are some issues though with this approach, though:

  • We need to ensure that this new module's field can handle all the ranges, wildcards and other bits -- e.g. it appears to have separate widgets for CIDR notation, but that's at UI-level only (hopefully).
  • We'll need to have some hook_update and migrate code to move from the ip_login_users table to this field. OR support both, which kinda sucks from a code redundancy/maintenance/legacy PoV.
  • Since this approach (field API or other modules) won't work for D6, we'll always have this legacy codebase until D6 is end of lifed, and that'll be a looong while yet... On the bright side, 6.x-2.0 is nice and stable and we can just backport the views patch you're working on.

So at this point in time I don't see much point in supporting any other field types as we then need a load of extra validation code for nothing. So my current preferred approach is:

Use field_ipaddress only for future D7 3.x branches when that module has everything we need, but leave D6/7 2.x codebase with ip_login_users table PLUS your views patch.

What do you think? It's a question of how we get from here to there, as well as defining where 'there' is... It might be worth double-checking if there are alternatives to that IP field module, too.

davidwhthomas’s picture

Thanks Jim,

I like the idea of a dependency on field_ipaddress too, as the module specialises in IP address handling and also makes it quite easy to do the IP range matching to user.

As for the issues you mentioned:

We need to ensure that this new module's field can handle all the ranges, wildcards and other bits -- e.g. it appears to have separate widgets for CIDR notation, but that's at UI-level only (hopefully).

While there is a CIDR notation widget available, I've been testing with the "Shorthand" widget ( x.* ) which is more end-user friendly.
Theoretically, a familiar user could switch to use the CIDR style widget instead.
Does the current version of ip_login support both styles in the one textfield? If so, that may be a problem as it looks like the widget needs to be one or the other.
field_ipaddress does handle the required ranges, e.g 203.0.0.0 - 203.45.3.12, 203.45.0.0 - 203.45.3.12, or 203.45.3.12-14 as well as 203.45.3.*

We'll need to have some hook_update and migrate code to move from the ip_login_users table to this field. OR support both, which kinda sucks from a code redundancy/maintenance/legacy PoV.

Yes, just using the field storage is alot simpler here and saves duplication and rework.
I'm thinking either an update hook, or a page where an end-user can migrate the data across. Migration is quite easy to do.

Since this approach (field API or other modules) won't work for D6, we'll always have this legacy codebase until D6 is end of lifed, and that'll be a looong while yet... On the bright side, 6.x-2.0 is nice and stable and we can just backport the views patch you're working on.

Yes, that makes sense, we'd keep the existing approach for the 6.x branch.

As for:

Use field_ipaddress only for future D7 3.x branches when that module has everything we need, but leave D6/7 2.x codebase with ip_login_users table PLUS your views patch.

Agreed.

Cheers,

DT

davidwhthomas’s picture

OK, I've got an update working with field_ipaddress.

As field_ipaddress takes care of all the validation while data storage and retrieval is all done by the Field API, it means we're able to remove quite a bit of code from the base ip_login module, such as insert, update hooks/code

I've also put together an update hook that creates the field_ip_login ip address field and uses the batch api to migrate user ip data across to it.

All my 195 test IP addresses were migrated successfully across to the new field, including address patterns like

123.45.67.*
123.45.*.*
123.45.67.89/24

So that's looking good too.

cheers,

DT

davidwhthomas’s picture

Jim, there's a new 7.x-3.x branch committed to git that contains a working copy of IP Login using the field_ipaddress module.

An update hook / upgrade path is provided there for migration.

I'm thinking to publish a new 7.x-3.x-alpha/beta branch with this update soon.

Please test it out and let me know what you think.

cheers,

David

jim kirkpatrick’s picture

Title: Views integration for ip_login_user table » Views & IP Address Field module integration for IP Login
jim kirkpatrick’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
Assigned: Unassigned » davidwhthomas
Category: feature » task

Updating and clarifying... Cheekily assigning to David, too!

davidwhthomas’s picture

Heh, yes, this one's ready for testing.

Using it myself.

Cheers,

DT

peterx’s picture

Good to see the IP address field has useful indexes for high speed lookup. The unlimited number of addresses will remove our requirement to replace the 255 byte address field with 2000 bytes. Looking forward to beta testing. Two thumbs up!

dwatts3624’s picture

I've noticed mention of D6 support here. Are there any plans to do that or should we just anticipate waiting until our project is upgraded to D7?

Also, the main need is to include the data in a report/view. If there's a path to include the used range in a user view using the D6 version that we've missed a path to the documentation there would be greatly appreciated!

jim kirkpatrick’s picture

D6 support isn't planned by me, and there's no 6 verison of http://drupal.org/project/field_ipaddress so I would imagine this will be 7+ only, unless someone finds an alternative IP Address field module, or ports that one.

amateescu’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

Closing old issues.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.