Index: openacs-4/packages/dotlrn-portlet/tcl/dotlrn-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-portlet/tcl/dotlrn-portlet-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn-portlet/tcl/dotlrn-portlet-procs.tcl 8 Oct 2001 20:56:19 -0000 1.1 +++ openacs-4/packages/dotlrn-portlet/tcl/dotlrn-portlet-procs.tcl 8 Oct 2001 23:44:00 -0000 1.2 @@ -1,7 +1,7 @@ -# /packages/bboard-portlets/tcl/bboard-portlets-procs.tcl +# /packages/dotlrn-portlets/tcl/dotlrn-portlets-procs.tcl ad_library { -Procedures to supports bboard portlets +Procedures to supports dotlrn portlets Copyright Openforce, Inc. Licensed under GNU GPL v2 @@ -12,34 +12,34 @@ } -namespace eval bboard_portlet { +namespace eval dotlrn_portlet { ad_proc -private my_name { } { - return "bboard-portlet" + return "dotlrn-portlet" } ad_proc -public add_self_to_page { page_id - instance_id + community_id } { - Adds a bboard PE to the given page with the instance key being + Adds a dotlrn PE to the given page with the community_id as opaque data in the portal configuration. @return element_id The new element's id @param page_id The page to add self to - @param instance_id The bboard instace to show + @param community_id The dotlrn community to show info about @author arjun@openforce.net @creation-date Sept 2001 } { # Tell portal to add this element to the page set element_id [portal::add_element $page_id [my_name]] - # The default param "instance_id" must be configured - set key "instance_id" + # The default param must be configured + set key "community_id" set value [portal::get_element_param $element_id $key] - portal::set_element_param $element_id $key $instance_id + portal::set_element_param $element_id $key $community_id return $element_id } @@ -57,86 +57,56 @@ array set config $cf - set query " - select message_id, - title, - num_replies, - first_names||' '||last_name as full_name, - to_char(last_reply_date,'MM/DD/YY hh12:Mi am') as last_updated - from bboard_messages_all b, persons, acs_objects ao - where b.forum_id = ao.object_id - and ao.context_id = $config(instance_id) - and person_id = sender - and reply_to is null - order by sent_date desc" - - set data "" - set rowcount 0 - - db_foreach select_messages $query { - append data "$title$full_name$num_replies$last_updated" - incr rowcount - } - - set template " - - - - - - - - $data -
SubjectAuthorRepliesLast update
" - - ns_log notice "AKS31 got here $rowcount" - - if {!$rowcount} { - set template "No messages" + set query "select pretty_name, description + from dotlrn_communities + where community_id = $config(community_id)" + + # for now query the DM directly + if { [db_0or1row select_comminity_info $query] } { + set data "$pretty_name - $description" + } else { + set data "Community info not found. Contact webmaster, please!" } - set code [template::adp_compile -string $template] - - set output [template::adp_eval code] - ns_log notice "AKS32 got here $output" + ns_log notice "AKS-dotlrn-portlet got here $data" - return $output + return $data } ad_proc -public remove_self_from_page { portal_id - instance_id + community_id } { - Removes a bboard PE from the given page + Removes a dotlrn PE from the given page - @param page_id The page to remove self from - @param instance_id - @author arjun@openforce.net - @creation-date Sept 2001 + @param page_id The page to remove self from + @param community_id + @author arjun@openforce.net + @creation-date Sept 2001 } { - # Find out the element_id that corresponds to this instance_id - if { [db0or1row get_element_id " - select pem.element_id as element_id - from portal_element_parameters pep, portal_element_map pem - where pem.portal_id = $portal_id and - pep.element_id = pem.element_id and - pep.key = 'instance_id' and - pep.value = $instance_id"] } { + # Find out the element_id that corresponds to this + # community_id/portal_id pair + if { [db0or1row get_element_id " + select pem.element_id as element_id + from portal_element_parameters pep, portal_element_map pem + where pem.portal_id = $portal_id and + pep.element_id = pem.element_id and + pep.key = 'community_id' and + pep.value = $community_id"] } { - # delete the params - # delete the element from the map - ns_log Notice "foo" + # delete the params + # delete the element from the map - } else { - ad_return_complaint 1 "bboard_portlet::remove_self_from_page: Invalid portal_id and/or instance_id given." - ad_script_abort - } + } else { + ad_return_complaint 1 "dotlrn_portlet::remove_self_from_page: Invalid portal_id and/or community_id given." + ad_script_abort + } - # this call removes the PEs params too - set element_id [portal::remove_element {$portal_id $element_id}] - } - } + # this call removes the PEs params too + set element_id [portal::remove_element {$portal_id $element_id}] + } +}