Index: openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-dotlrn-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-dotlrn-procs.tcl,v diff -u -r1.29 -r1.30 --- openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-dotlrn-procs.tcl 15 May 2002 23:56:00 -0000 1.29 +++ openacs-4/packages/dotlrn-dotlrn/tcl/dotlrn-dotlrn-procs.tcl 24 May 2002 01:58:46 -0000 1.30 @@ -14,74 +14,125 @@ # details. # +ad_library { + + Procs to set up the core dotLRN portlets. + 1. the soon-to-be-renamed "dotlrn-main" portlet + (The thing that lists a users communities on their portal) + 2. the "dotlrn" portlet (aka "subgroups" on comm portals) + 3. the "dotlrn-admin portlet" (basic group admin) -# -# Procs for DOTLRN Dotlrn Applet -# Copyright 2001 OpenForce, inc. -# Distributed under the GNU GPL v2 -# -# October 5th, 2001 -# + and experimentally (so we eliminate these 2 applets): -ad_library { - - Procs to set up the dotLRN Dotlrn applet - + 4. "dotlrn-members" for clubs and subcomms + 5. "dotlrn-members-staff" for classi's + @author ben@openforce.net,arjun@openforce.net - @creation-date 2001-10-05 - + @version $Id$ } namespace eval dotlrn_dotlrn { - ad_proc -public package_key { + ad_proc portal_element_key { } { - get the package_key this applet deals with + What portlet is this applet associated with? } { - return "dotlrn" + return "dotlrn-portlet" } - ad_proc portal_element_key { + ad_proc -public get_pretty_name { } { - return the portal element key } { - return "dotlrn-portlet" + return "Core DotLRN Applets" } - ad_proc -public get_pretty_name { + ad_proc -public applet_key { } { - returns the pretty name } { - return "Group Admin and Subgroup Info" + return "dotlrn_dotlrn" } ad_proc -public add_applet { } { - Add the dotlrn applet to dotlrn - one time init - must be repeatable! + Add the applet to dotlrn - one time init - must be repeatable! } { - dotlrn_applet::add_applet_to_dotlrn -applet_key "dotlrn_dotlrn" + dotlrn_applet::add_applet_to_dotlrn -applet_key [applet_key] } ad_proc -public remove_applet { package_id } { - remove the applet from dotlrn + Remove the applet from dotlrn. } { + ad_return_complaint \ + 1 \ + "[applet_key] remove_applet called - this should not happen ever!" } ad_proc -public add_applet_to_community { community_id } { - Add the dotlrn applet to a specific community + Add the core dotlrn applets to a specific community } { + # + # comm type-specific stuff + # + # we call add_self_to_page again with the + # real comm_id, and it gets overwritten + set portal_id [dotlrn_community::get_portal_id \ -community_id $community_id ] - set args [ns_set create args] + + set type [dotlrn_community::get_community_type_from_community_id \ + $community_id + ] + + if {[string equal $type "dotlrn_club"]} { + + # clubs have the "dotlrn members" portlet + dotlrn_members_portlet::add_self_to_page \ + -portal_id $portal_id \ + -community_id $community_id \ + -page_name [members_community_default_page] + + } elseif {[string equal $type "dotlrn_community"] } { + + # subgroups have the "dotlrn members" portlet + dotlrn_members_portlet::add_self_to_page \ + -portal_id $portal_id \ + -community_id $community_id \ + -page_name [members_subcomm_default_page] + + } else { + # and class instances have the "dotlrn members staff" portlet + dotlrn_members_staff_portlet::add_self_to_page \ + -portal_id $portal_id \ + -community_id $community_id + } + + # + # common to all comm's + # + + # set up the admin portlet + set admin_portal_id [dotlrn_community::get_admin_portal_id \ + -community_id $community_id + ] + + dotlrn_admin_portlet::add_self_to_page \ + -portal_id $admin_portal_id \ + -community_id $community_id + + + set portal_id [dotlrn_community::get_portal_id \ + -community_id $community_id + ] + set args [ns_set create] ns_set put $args community_id $community_id - dotlrn_dotlrn::add_portlet $portal_id $args + dotlrn_dotlrn::add_portlet_helper $portal_id $args # this is not supposed to return anything, since # any return value here is interpreted as a valid package_id! @@ -93,34 +144,36 @@ } { remove the dotlrn applet from a specific community } { - set portal_id portal_id [dotlrn_community::get_portal_id \ - -community_id $community_id - ] - set args [ns_set create args] - ns_set put $args community_id $community_id - - dotlrn_dotlrn::remove_portlet $portal_id $args + ad_return_complaint \ + 1 \ + "[applet_key] remove_applet_from_community not implimented!" } ad_proc -public add_user { user_id } { - Called for one time init when this user is added to dotlrn + Called for one time init when this user is added to dotlrn. + Do nothing, since the portal system will copy the dotlrn-main + portal from the user template. that's set up below } { + # noop } ad_proc -public remove_user { user_id } { + remove a user from dotlrn } { + ad_return_complaint 1 "[applet_key] remove_user not implimented!" } ad_proc -public add_user_to_community { community_id user_id } { - Called when a user is added to a spceific dotlrn community + Add user to a comm } { + # noop } ad_proc -public remove_user_from_community { @@ -130,38 +183,66 @@ Remove a user from a community. Since this applet is not shown on a user's portal, no action is required here. } { + # noop } ad_proc -public add_portlet { portal_id - args } { - A helper proc to add the underlying portlet to the given portal. - @param portal_id - @param args An ns_set of key-value pairs. (community_id?) } { - # since this portlet is only added to community portals or portal templates - # we only need to check for community_id in the ns_set - set community_id [ns_set get $args "community_id"] + set community_id 0 + set args [ns_set create] + ns_set put $args community_id $community_id - if {![empty_string_p $community_id] - && ![dotlrn_community::dummy_comm_p -community_id $community_id]} { - # portal_id is a community portal - # set up the DS for the admin page - set admin_portal_id [dotlrn_community::get_admin_portal_id \ - -community_id $community_id] - dotlrn_admin_portlet::add_self_to_page \ - -portal_id $admin_portal_id \ - -community_id $community_id + set type [dotlrn::get_type_from_portal_id -portal_id $portal_id] + + if {[string equal $type "user"]} { + + # the user portal type, set up the dotlrn-main portlet + dotlrn_main_portlet::add_self_to_page \ + -portal_id $portal_id + + # bail out here since we don't want to add the "subgroups" + # portlet to the user's portal + return + + } elseif {[string equal $type "dotlrn_club"]} { + + # clubs have the "dotlrn members" portlet + dotlrn_members_portlet::add_self_to_page \ + -portal_id $portal_id \ + -community_id $community_id \ + -page_name [members_community_default_page] + + } elseif {[string equal $type "dotlrn_community"] } { + + # subgroups have the "dotlrn members" portlet + dotlrn_members_portlet::add_self_to_page \ + -portal_id $portal_id \ + -community_id $community_id \ + -page_name [members_subcomm_default_page] + } else { - # portal_id is a portal template - set community_id 0 + # and class instances have the "dotlrn members staff" portlet + dotlrn_members_staff_portlet::add_self_to_page \ + -portal_id $portal_id \ + -community_id $community_id } + add_portlet_helper $portal_id $args + } + + ad_proc -private add_portlet_helper { + portal_id + args + } { + Does the call to add the portlet to the portal. + Params for the portlet are sent to this proc by the caller. + } { dotlrn_portlet::add_self_to_page \ -portal_id $portal_id \ - -community_id $community_id + -community_id [ns_set get $args "community_id"] } ad_proc -public remove_portlet { @@ -171,39 +252,38 @@ A helper proc to remove the underlying portlet from the given portal. @param portal_id - @param args ns_set (community_id?) + @param args } { - # since this portlet is only added to community portals or portal templates - # we only need to check for community_id in the ns_set - set community_id [ns_set get $args "community_id"] - - if {![empty_string_p $community_id]} { - # portal_id is a community portal - # set up the DS for the admin page - set admin_portal_id [dotlrn_community::get_admin_portal_id \ - -community_id $community_id] - dotlrn_admin_portlet::remove_self_to_page \ - -portal_id $admin_portal_id \ - -community_id $community_id - } else { - # portal_id is a portal template - set community_id 0 - } - - dotlrn_portlet::remove_self_to_page \ - -portal_id $portal_id \ - -community_id $community_id + ad_return_complaint 1 "[applet_key] remove_portlet not implimented!" } ad_proc -public clone { old_community_id new_community_id } { Clone this applet's content from the old community to the new one. - Since there's no data to copy, just add the applet to the new community. - + Since there's no data to copy, just add the applet to the new + community. } { + ns_log notice "Cloning: [applet_key]" dotlrn_dotlrn::add_applet_to_community $new_community_id } + + # misc procs + + ad_proc -public members_community_default_page {} { + Returns the user default page to add the portlet to. + FIXME Should be a ad_param. + } { + return "People" + } + + ad_proc -public members_subcomm_default_page {} { + FIXME Should be a ad_param. + } { + return "Subgroup Info" + } + + }