Index: openacs-4/contrib/packages/cop-ui/lib/contributions.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/lib/contributions.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/cop-ui/lib/contributions.tcl 29 Apr 2004 15:56:04 -0000 1.2 +++ openacs-4/contrib/packages/cop-ui/lib/contributions.tcl 7 May 2004 17:25:39 -0000 1.3 @@ -1,22 +1,36 @@ # /packages/cop-ui/lib/contributions -# Display the site contributions for user user_id -if {![info exists user_id]} { +# Display the site contributions +# If user_id set it will be limited by that user otherwise all users. +# if limit set then only limit items will be displayed. +# if root_node_id exists then only return things under root node. + +if {![info exists user_id]} { set user_id {} } +if {![info exists category]} { + set category {} +} +if {[info exists root_node_id]} { + set packages [cop::util::packages -node_id $root_node_id] +} else { + set packages {} +} + + lappend elements rating_img { label "Rating" display_template "@content.rating_img;noquote@" } lappend elements ratings { label \# display_template "@content.ratings;noquote@" - html {align right} + html {align right} } -lappend elements views { +lappend elements views { label "Views" - html {align right} + html {align right} } lappend elements object_title { @@ -31,10 +45,10 @@ lappend elements last_modified { label {Last update} display_template "@content.last_modified;noquote@" - html {align right} + html {align right} } -if {[empty_string_p $user_id]} { +if {[empty_string_p $user_id]} { lappend elements name { label {Created by} display_template {@content.name@} @@ -46,28 +60,28 @@ -multirow content \ -key object_id \ -elements $elements \ - -filters { + -filters { user_id {} } \ - -orderby { - rating_img { + -orderby { + rating_img { orderby_desc {coalesce(rating_ave,99) asc, o.last_modified desc} orderby_asc {coalesce(rating_ave,0) desc, o.last_modified desc} } - object_title { + object_title { orderby lower(o.title) } - views { + views { orderby_desc {views asc} orderby_asc {views desc} } - ratings { + ratings { orderby ratings } - object_type { + object_type { orderby lower(t.pretty_name) } - last_modified { + last_modified { orderby_asc {o.last_modified desc} orderby_desc {o.last_modified asc} } @@ -80,37 +94,46 @@ set icons [cop::rating::icon_base] set now [clock_to_ansi [clock seconds]] -if {![empty_string_p $user_id]} { - set restrict "and o.creation_user = :user_id" -} else { - set restrict {} +set restrict {} + +if {![empty_string_p $user_id]} { + append restrict "\nand o.creation_user = :user_id" } +if {![empty_string_p $category]} { + append restrict "\nand exists (select 1 from category_object_map c where c.object_id = o.object_id and c.category_id = :category)" +} + +if {![empty_string_p $packages]} { + append restrict "\nand o.package_id in ([join $packages ,])" +} + # TODO: need to get the dimension to display, need to find the right CoP db_multirow -extend {rating_img url_one ratings_url user_url} content content " SELECT o.title, o.object_id, o.title, t.pretty_name as object_type, r.rating_ave, r.ratings, v.views, to_char(o.last_modified,'YYYY-MM-DD HH24:MI:SS') as last_modified, u.user_id, u.first_names || ' ' || u.last_name as name - FROM acs_object_types t, acs_users_all u, acs_objects o + FROM acs_object_types t, acs_objects o left outer join cr_items i on (o.object_id = i.item_id) left outer join cop_rating_aggregates r on (o.object_id = r.object_one) left outer join cop_object_view_agg v on (v.object_id = o.object_id) + left outer join acs_users_all u on (u.user_id = o.creation_user) WHERE t.object_type = case when o.object_type = 'content_item' then i.content_type else o.object_type end and o.object_type in ('content_item','pinds_blog_entry','forums_forum','forums_message', - 'content_item','cal_item','bt_bug','bt_patch', 'faq', 'faq_q_and_a', 'bookshelf_book') - and (o.object_type != 'content_item' or i.content_type in ('content_extlink','file_storage_object','pa_album','pa_photo')) - and u.user_id = o.creation_user + 'cal_item','bt_bug','bt_patch', 'faq', 'faq_q_and_a', 'bookshelf_book') + and (o.object_type != 'content_item' or i.content_type in ('content_extlink','file_storage_object','pa_album','pa_photo','static_page')) $restrict - [template::list::orderby_clause -orderby -name "content"]" { + [template::list::orderby_clause -orderby -name "content"] limit 20" { if {![empty_string_p $rating_ave]} { set ratings_url "/cop1/cop/ratings/ratings?object_id=$object_id" set rating [format %.1f [expr {(round(2.0*$rating_ave))/2.0}]] set rating_img "\"$rating\"" set ratings "$ratings" - } else { + } else { set rating_img {} } + regsub {/www/cop1/static} $title {} title set last_modified [regsub -all { } [util::age_pretty -hours_limit 0 -mode_2_fmt "%X %a" -mode_3_fmt "%x" -timestamp_ansi $last_modified -sysdate_ansi $now] {\ }] set user_url [acs_community_member_url -user_id $user_id] - if {[catch {set url_one [acs_sc_call -error FtsContentProvider url [list $object_id] $object_type]} errMsg]} { + if {[catch {set url_one [acs_sc_call -error FtsContentProvider url [list $object_id] $object_type]} errMsg]} { global errorCode set url_one $errorCode }