Index: openacs-4/packages/dotlrn/tcl/community-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/community-procs.tcl,v diff -u -r1.169 -r1.169.2.1 --- openacs-4/packages/dotlrn/tcl/community-procs.tcl 10 Oct 2002 06:07:25 -0000 1.169 +++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 17 Oct 2002 12:23:12 -0000 1.169.2.1 @@ -217,7 +217,7 @@ where object_id = :community_id } - set template_id [dotlrn::get_portal_id_from_type -type $community_type] + set template_id [dotlrn::get_portal_id_from_type -type $object_type] # Create comm's portal page set portal_id [portal::create \ @@ -311,8 +311,21 @@ # this community should be able to read this instance (and # it's children) permission::set_not_inherit -object_id $community_id - - return $community_id + + #this block sets permissions for subcommunities + while {1} { + if {![empty_string_p $parent_community_id]} { + #admin of the parent need admin on the subcommunity. + set parent_admin_party [db_string "parent_admin_party" "select segment_id from rel_segments where group_id = :parent_community_id and rel_type='dotlrn_admin_rel'"] + permission::grant -party_id $parent_admin_party -object_id $community_id -privilege "admin" + + #if this community has a parent we need to work up the chain. + set parent_community_id [get_parent_id -community_id $parent_community_id] + + } else { + return $community_id + } + } } ad_proc set_active_dates { @@ -376,12 +389,10 @@ ad_proc -private get_default_roles_not_cached { {-community_type:required} } { - set toplevel_community_type [get_toplevel_community_type -community_type $community_type] - - if {[string match $toplevel_community_type dotlrn_class_instance]} { - set community_type dotlrn_class_instance - } else { + if {[string match $community_type dotlrn_club]} { set community_type dotlrn_community + } elseif {![string match $community_type dotlrn_community]} { + set community_type dotlrn_class_instance } return [db_list_of_lists select_role_data {}] @@ -571,6 +582,9 @@ set member_segment_id [get_members_rel_id -community_id $community_id] set admin_segment_id [get_admin_rel_id -community_id $community_id] + set parent_id [dotlrn_community::get_parent_id -community_id $community_id] + set parent_admin_segment_id [get_admin_rel_id -community_id $parent_id] + permission::grant \ -party_id $member_segment_id \ -object_id $community_id \ @@ -744,6 +758,7 @@ } util_memoize_flush "dotlrn_community::list_users_not_cached -rel_type $rel_type -community_id $community_id" + util_memoize_flush_regexp $user_id } ad_proc -public add_user_to_community { @@ -771,6 +786,12 @@ ns_set put $extra_vars user_id $user_id ns_set put $extra_vars community_id $community_id + ns_log notice "rel_type is sending the following to relation_add -member_state needs approval \ + -extra_vars $extra_vars \ + $rel_type \ + $community_id \ + $user_id " + # Set up the relationship if {[catch {set rel_id [relation_add \ -member_state "needs approval" \ @@ -860,8 +881,10 @@ # flush the list_users cache util_memoize_flush "dotlrn_community::list_users_not_cached -rel_type $rel_type -community_id $community_id" } + util_memoize_flush_regexp $user_id } + ad_proc -public get_all_communities_by_user { user_id } { @@ -1118,6 +1141,7 @@ {-community_id:required} {-pretext "