Gossamer Forum
Home : Products : Links 2.0 : Customization :

Links 2.0 Ranged Date Searches Fix

Quote Reply
Links 2.0 Ranged Date Searches Fix
In Links 2.0 db.pl the code in the query routine varies from the code in DBMan db.cgi query routine. This causes the ranged search for date fields in Links 2.0 to fail.

In DBMan:
if ($in{"$column-gt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-gt"}) or return "Invalid date format: '$in{$column}'");
push(@search_gt_fields, $i); }
if ($in{"$column-lt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-lt"}) or return "Invalid date format: '$in{$column}'");
push(@search_lt_fields, $i); }

In Links 2.0
if ($in{"$column-gt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{$column}) or return "Invalid date format: '$in{$column}'");
push(@search_gt_fields, $i); }
if ($in{"$column-lt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{$column}) or return "Invalid date format: '$in{$column}'");
push(@search_lt_fields, $i); }

not that
(&date_to_unix($in{$column})

should be $column-gt (and -lt)

Without this change the script is looking for a form input from Date not Date-gt as required to work.

Please note that to do a ranged date search you must have a form with <input type="text" name="Date-gt"> <input type="text" name="Date-lt">. I have not tested it with search.cgi but I have verified it using the admin view, modify and delete searches.