To improve the management of long IP lists, forms should use textareas (resizable?) with one IP address (in CIDR notation) per line. This is more consistent with Drupal core.
Currently, IP lists are semi-colon delimited and shown in a textfield so you can't see or edit them easily.
Original summary:
Hi,
Could a maxlength of 256 be added to the 'restrict role by IP' fields as I'm finding the fields to short for the number of IP's I need to add?
Thanks,
Richard
| Comment | File | Size | Author |
|---|
Comments
Comment #1
rocketeerbkw commentedSorry about the delay, this patch will remove the maxlength for that field so it's set to the browser default (5000 ish). This should probably be converted to a text area though and use line breaks instead of semicolons, but I don't wanna hold you up right now.
Comment #2
rocketeerbkw commentedHere's an updated patch to remove the maxlength on all IP fields (global login, user login, roles). I went ahead and committed this, but I do want to change to one IP per line at some point.
Comment #5
rocketeerbkw commentedComment #6
loopduplicate commentedHi All,
I'm attaching a patch for 7.x-3 which changes the IP whitelist fields to textareas and also allows to separate the values on semi-colons and new lines.
Regards,
Jeff
Comment #7
kristen polI'm confused on this one. The title of the issue doesn't seem to match the issue summary and the first patch is for changing sizes. ?
Comment #8
kristen polAh... buried in #2 is "but I do want to change to one IP per line at some point." It would be good to update the issue summary as this is confusing.
Comment #9
kristen polI think all of these were in the original code but some nitpicks:
"seperated" => "separated"
"seperated" => "separated"
Use single quotes?
The only other thing is there is an inconsistency between using $ipaddresses and $ip_address in different places but that is in the original code so I wouldn't worry about trying to make this consistent.
Comment #10
kristen polComment #11
rocketeerbkw commentedSorry for the confusion. I actually want to convert from semi-colons to line breaks, not both. So only one IP per line, which is more consistent with Drupal core. I've updated the issue summary.
In addition,
variable_get()andvariable_set()will automatically serialize arrays, so I'd like to see something like this in the form submitvariable_set('restrict_by_ip_login_range', explode("/n", $form_values[])). Then everywhere you need the data you only need to dovariable_get('restrict_by_ip_login_range', array())and then iterate over the array. This requires more work than what you provided already, but I think it's cleaner.An update function will also be needed to convert semi-colons to line breaks.
Thanks for the patch and reviews! There are coding standards problems with the original code, so I don't expect you to fix/catch them all in this patch.
Comment #12
loopduplicate commentedRegarding #9
Perhaps cleaning up comments could be done in another issue since there are quite a few places in the code where cleanup would be nice.
Regarding #11:
Converting semi-colons to line breaks in an update hook seems like it would be difficult. I think that it would be difficult to run the update reliably without using drush because the user might not have access to the front end. Any suggestions about this would be appreciated... it's getting late today and I'm running out of time to make further updates.
Using arrays in variables is a good idea too but perhaps that could be a separate issue?
Regards,
Jeff
Comment #13
rocketeerbkw commentedI don't think an update function would be difficult, but it'd have to be tested for sure.
I guess we can avoid it by not changing how the data is stored at all. Instead, let's just change the admin forms so that it converts
;to\non load, and vice-versa on save. That way the UI is improved, but the storage and rest of the code doesn't have to change.I've been using all my spare time to complete the D8 port, so I'm afraid I won't get to this yet.
Comment #14
mfbAlthough it's documented in the UI, the fact that the configuration cannot have a trailing semi-colon makes it especially easy for admins to shoot themselves in foot. The configuration could be provided thru other means like config files, environment variables, drush, etc. where there is no documentation...
A trailing semi-colon seems to be interpreted as matching any IP address, i.e. disables the IP address restriction :/
Comment #15
darvanen