-
- # they have choosen a new report and the area to report on
- $template->param(
- 'build2' => 1,
- 'area' => $input->param('areas'),
- 'types' => get_report_types(),
- );
+ my $cache_expiry_units = $input->param('cache_expiry_units'),
+ my $cache_expiry = $input->param('cache_expiry');
+
+ # we need to handle converting units
+ if( $cache_expiry_units eq "minutes" ){
+ $cache_expiry *= 60;
+ } elsif( $cache_expiry_units eq "hours" ){
+ $cache_expiry *= 3600; # 60 * 60
+ } elsif( $cache_expiry_units eq "days" ){
+ $cache_expiry *= 86400; # 60 * 60 * 24
+ }
+ # check $cache_expiry isnt too large, Memcached::set requires it to be less than 30 days or it will be treated as if it were an absolute time stamp
+ if( $cache_expiry >= 2592000 ){ # oops, over the limit of 30 days
+ # report error to user
+ $template->param(
+ 'cache_error' => 1,
+ 'build1' => 1,
+ 'areas' => get_report_areas(),
+ 'cache_expiry' => $cache_expiry,
+ 'usecache' => $usecache,
+ 'public' => $input->param('public'),
+ );
+ } else {
+ # they have choosen a new report and the area to report on
+ $template->param(
+ 'build2' => 1,
+ 'area' => $input->param('areas'),
+ 'types' => get_report_types(),
+ 'cache_expiry' => $cache_expiry,
+ 'public' => $input->param('public'),
+ );
+ }