Index: openacs-4/packages/lars-blogger/www/blog.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lars-blogger/www/blog.tcl,v diff -u -r1.8.2.6 -r1.8.2.7 --- openacs-4/packages/lars-blogger/www/blog.tcl 1 Jul 2003 13:28:26 -0000 1.8.2.6 +++ openacs-4/packages/lars-blogger/www/blog.tcl 10 Jul 2003 09:47:46 -0000 1.8.2.7 @@ -22,18 +22,54 @@ if { ![info exists screen_name] } { set screen_name "" + set blog_user_id {} +} else { + set blog_user_id [cc_screen_name_user $screen_name] } -if { ![info exists type] } { - set type "current" -} +# TODO: +# - Upgrade the installed package to get the latest parameters +# - Test on PG and Oracle + +set max_num_entries [parameter::get \ + -package_id $package_id \ + -parameter MaxNumEntriesOnFrontPage \ + -default {}] + +set min_num_entries [parameter::get \ + -package_id $package_id \ + -parameter MinNumEntriesOnFrontPage \ + -default {}] + +set num_days [parameter::get \ + -package_id $package_id \ + -parameter NumDaysOnFrontPage \ + -default {}] + + + switch -exact $type { archive { set date_clause "[db_map date_clause_archive]" + set limit {} } + current { + set date_clause {} + set limit {} + + if { ![empty_string_p $max_num_entries] && $max_num_entries != 0 } { + # MaxNumEntriesOnFrontPage parameter is set, which means we should limit to that + set limit $max_num_entries + } + + if { ![empty_string_p $num_days] && $num_days != 0 } { + # NumDaysOnFrontPage parameter is set, which means we should limit to that + set date_clause [db_map date_clause_default] + } + } default { - set date_clause "[db_map date_clause_default]" + error "Only knows of type 'archive' or 'current'" } } @@ -49,18 +85,30 @@ set blog_url {} } -set count 0 - -if { ![exists_and_not_null screen_name] } { +# Check that the date limit is not limiting us to show less than min_num_entries entries +if { ![string equal $type "archive"] && \ + ![empty_string_p $min_num_entries] && $min_num_entries != 0 && \ + ![empty_string_p $num_days] && $num_days != 0 + } { + if { [empty_string_p $blog_user_id] } { + set num_entries [db_string num_entries_by_date_all {}] + } else { + set num_entries [db_string num_entries_by_date {}] + } + if { $num_entries < $min_num_entries } { + # Eliminate date clause, and set the limit to the minimum number of entries + set date_clause {} + set limit $min_num_entries + } +} + +if { [empty_string_p $blog_user_id] } { db_multirow blog all_blogs { *SQL* } set archive_url "${package_url}archive/" - } else { - db_multirow blog blog { *SQL* } set archive_url "${package_url}user/$screen_name/archive/" - } set arrow_url "${package_url}graphics/arrow-box.gif"