#####################################################################
### W H A T ' S N E W
### Last modified: 10 Aug 2000
### Written by JPDeni
### Additional coding by Lee Leisure.
#####################################################################
# This modification allows you to set up a link to search for records
# added within the past x number of days -- whatever you want. You
# must have a field that contains the date the record was added. In
# the code below, I have called this field "Date." You may call it
# anything you wish, but you must change the reference to "Date-gt"
# below to match your field name. #
#####################################################################
# In sub query in the db.cgi file after
local (%sortby);
# add
if($in{'listnew'}) {
$days = 6; # Number of days for What's New, +1.
$new = &get_date(time() - ($days * 86400));
# Change Date below to match the *exact* name of your date field.
$in{'Date-gt'} = $new;
# Change 2 below to match the number of your date field.
$in{'sb'} = 2; # Number of your date field
$in{'so'} = 'descend';
}
# Add the following to html.pl. Where you put it will depend on where
# you want the link to What's New to be. If you only want the link to
# be in your DBMan home page, put it in sub html_home. If you want it
# to be in the footer, along with "View" "Add" "List All," etc.,
# put it in sub html_footer.
# If you want it in html_home, before
&html_footer
# add
print qq|What's New|;
#
# If, instead, you want the link to appear on every page with the
# footer, somewhere in sub html_footer, add
print qq!| What's New ! if ($per_view);
#####################################################################
# Create the link on your static page in the form of
What's New
####################################################################
#
# There are a couple of other things that are required to make this
# work.
#
# Open db.cgi and look for sub query. Locate the following section of
# the script. (I kept the comment lines and tabs from the original to
# make it easier to find.
# Copy the code below and paste it over the code in the script, being
# very sure you match up the brackets.
else { # Otherwise this is a regular search, and we only want records
$i = 0; # that match everything the user specified for.
foreach $column (@db_cols) {
if ($in{$column} =~ /^\>(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or return "Invalid date format: '$1'");
push (@search_gt_fields, $i); $in{"$column-gt"} = $1; $i++; next; }
if ($in{$column} =~ /^\<(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or return "Invalid date format: '$1'");
push (@search_lt_fields, $i); $in{"$column-lt"} = $1; $i++; next; }
if ($in{$column} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{$column}) or return "Invalid date format: '$in{$column}'");
push(@search_fields, $i); $i++; next; }
if ($in{"$column-gt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-gt"}) or return qq|Invalid date format: '$in{"$column-gt"}'|);
push(@search_gt_fields, $i); }
if ($in{"$column-lt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-lt"}) or return qq|Invalid date format: '$in{"$column-lt"}'|);
push(@search_lt_fields, $i); }
$i++;
}
}
#####################################################################
#
# Still in db.cgi, search for sub get_date. Copy the following code
# and paste it over the subroutine in the script. Be sure you match
# up the brackets.
#
#
sub get_date {
# --------------------------------------------------------
# Returns the date in the format "dd-mmm-yyyy".
# Warning: If you change the default format, you must also modify the &date_to_unix
# subroutine below which converts your date format into a unix time in seconds for sorting
# purposes.
$time1 = @_[0];
($time1) or ($time1 = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1);
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}
####################################################################
#
# In auth.pl, search for sub auth_logging.
#
# Replace
#
# my ($date) = &get_date; # in get_time and get_date.
#
# with
my ($date) = &get_date(time()); # in get_time and get_date.
####################################################################
# #
# Warning: If you change the default date format, you must also
# modify the date_to_unix subroutine and the get_date subroutine to
# match. sub get_date and sub date_to_unix must be identical. #
####################################################################