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.131 -r1.132 --- openacs-4/packages/dotlrn/tcl/community-procs.tcl 24 May 2002 01:58:45 -0000 1.131 +++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 24 May 2002 06:13:31 -0000 1.132 @@ -64,11 +64,11 @@ } ad_proc -public one_community_package_key {} { - return "dotlrn" + return dotlrn } ad_proc -public one_community_type_package_key {} { - return "dotlrn" + return dotlrn } ad_proc -public new_type { @@ -93,16 +93,16 @@ # Create the node set new_node_id [site_node_create \ - $parent_node_id \ - [ad_decode $url_part "" $community_type_key $url_part] + $parent_node_id \ + [ad_decode $url_part "" $community_type_key $url_part] \ ] # Instantiate the package set package_id [site_node_create_package_instance \ - $new_node_id \ - $pretty_name \ - $parent_node(object_id) \ - [one_community_type_package_key] + $new_node_id \ + $pretty_name \ + $parent_node(object_id) \ + [one_community_type_package_key] \ ] # Set some parameters @@ -112,8 +112,9 @@ # Set the site node dotlrn_community::set_type_package_id $community_type_key $package_id + } - return $community_type_key + return $community_type_key } ad_proc -public set_type_package_id { @@ -145,7 +146,7 @@ {-parent_community_id ""} {-description ""} {-community_type:required} - {-object_type "dotlrn_community"} + {-object_type dotlrn_community} {-community_key ""} {-pretty_name:required} {-extra_vars ""} @@ -179,89 +180,88 @@ db_transaction { set user_id [ad_conn user_id] - set community_id \ - [package_instantiate_object -extra_vars $extra_vars $object_type] - + set community_id [package_instantiate_object -extra_vars $extra_vars $object_type] + set template_id [dotlrn::get_portal_id_from_type -type $community_type] # Create comm's portal page set portal_id [portal::create \ - -template_id $template_id \ - -name "$pretty_name Portal" \ - -context_id $community_id \ - $user_id + -template_id $template_id \ + -name "$pretty_name Portal" \ + -context_id $community_id \ + $user_id \ ] - + # Create the comm's non-member page set non_member_portal_id [portal::create \ -name "$pretty_name Non-Member Portal" \ -default_page_name [dotlrn::parameter -name non_member_page_name] \ -context_id $community_id \ - $user_id + $user_id \ ] - + # Create the comm's admin page set admin_portal_id [portal::create \ -name "$pretty_name Administration Portal" \ -default_page_name [dotlrn::parameter -name admin_page_name] \ -context_id $community_id \ - $user_id + $user_id \ ] - + # Set up the rel segments dotlrn_community::create_rel_segments -community_id $community_id - + # Set up the node if {[empty_string_p $parent_community_id]} { set parent_node_id [get_type_node_id $community_type] } else { set parent_node_id [get_community_node_id $parent_community_id] } - + # Create the node set new_node_id [site_node_create $parent_node_id $community_key] - + # Instantiate the package set package_id [site_node_create_package_instance \ $new_node_id \ $pretty_name \ $community_id \ [one_community_package_key] \ ] - + # Set the right parameters ad_parameter -package_id $package_id -set 0 dotlrn_level_p ad_parameter -package_id $package_id -set 0 community_type_level_p ad_parameter -package_id $package_id -set 1 community_level_p - + # Set up the node dotlrn_community::set_package_id $community_id $package_id - + # update the portal_id and non_member_portal_id db_dml update_portal_ids {} # Add the default applets based on the community type # 2. the the list of default applets for this type - if {[string equal $community_type "dotlrn_community"]} { + if {[string equal $community_type dotlrn_community]} { set default_applets [parameter::get \ - -package_id $package_id \ - -parameter default_subcomm_applets + -package_id $package_id \ + -parameter default_subcomm_applets \ ] - } elseif {[string equal $community_type "dotlrn_club"]} { + } elseif {[string equal $community_type dotlrn_club]} { set default_applets [parameter::get \ - -package_id $package_id \ - -parameter default_club_applets + -package_id $package_id \ + -parameter default_club_applets \ ] - } elseif {[string equal $community_type "user"]} { + } elseif {[string equal $community_type user]} { set default_applets [parameter::get \ - -package_id $package_id \ - -parameter default_user_portal_applets + -package_id $package_id \ + -parameter default_user_portal_applets \ ] } else { set default_applets [parameter::get \ - -package_id $package_id \ - -parameter default_class_instance_applets + -package_id $package_id \ + -parameter default_class_instance_applets \ ] } @@ -530,15 +530,15 @@ permission::grant \ -party_id $member_segment_id \ -object_id $community_id \ - -privilege "read" + -privilege read permission::grant \ -party_id $member_segment_id \ -object_id $community_id \ - -privilege "write" + -privilege write permission::grant \ -party_id $admin_segment_id \ -object_id $community_id \ - -privilege "admin" + -privilege admin } ad_proc -private rel_segments_revoke_permission { @@ -552,17 +552,17 @@ permission::revoke \ -party_id $member_segment_id \ -object_id $community_id \ - -privilege "read" + -privilege read permission::revoke \ -party_id $member_segment_id \ -object_id $community_id \ - -privilege "write" + -privilege write permission::revoke \ -party_id $admin_segment_id \ -object_id $community_id \ - -privilege "admin" + -privilege admin } - + ad_proc -public create_rel_segments { {-community_id:required} } { @@ -572,14 +572,14 @@ db_transaction { set member_segment_id [rel_segments_new \ - $community_id \ - dotlrn_member_rel \ - "Members of $community_name" + $community_id \ + dotlrn_member_rel \ + "Members of $community_name" \ ] set admin_segment_id [rel_segments_new \ - $community_id \ - dotlrn_admin_rel \ - "Admins of $community_name" + $community_id \ + dotlrn_admin_rel \ + "Admins of $community_name" \ ] rel_segments_grant_permission -community_id $community_id } @@ -590,35 +590,24 @@ } { remove the rel segments for a community } { - # a useful bit of code to find privs that you may not have properly revoked - # set foo [db_list_of_lists select_outstanding_privs { - # select o.object_id, object_type, privilege - # from acs_objects o, acs_permissions p - # where o.object_id = p.object_id - # and p.grantee_id = :admin_segment_id - # }] - # ad_return_complaint 1 "$foo" - # end - set member_segment_id [get_members_rel_id -community_id $community_id] set admin_segment_id [get_admin_rel_id -community_id $community_id] - rel_segments_revoke_permission -community_id $community_id + rel_segments_revoke_permission -community_id $community_id rel_segments_delete $admin_segment_id rel_segments_delete $member_segment_id - } ad_proc -public list_admin_users { community_id } { Returns list of admin users } { - return [list_users -rel_type "dotlrn_admin_rel" $community_id] + return [list_users -rel_type dotlrn_admin_rel $community_id] } ad_proc -public list_users { - {-rel_type "dotlrn_member_rel"} + {-rel_type dotlrn_member_rel} community_id } { Returns the list of users with a membership_id, a user_id, first name, last name, email, and role @@ -666,7 +655,7 @@ ad_proc -public add_user { {-rel_type ""} - {-member_state "approved"} + {-member_state approved} community_id user_id } { @@ -675,13 +664,13 @@ set toplevel_community_type \ [get_toplevel_community_type_from_community_id $community_id] - if {[string equal $toplevel_community_type "dotlrn_class_instance"]} { + if {[string equal $toplevel_community_type dotlrn_class_instance]} { dotlrn_class::add_user \ -rel_type $rel_type \ -community_id $community_id \ -user_id $user_id \ -member_state $member_state - } elseif {[string equal $toplevel_community_type "dotlrn_club"]} { + } elseif {[string equal $toplevel_community_type dotlrn_club]} { dotlrn_club::add_user \ -rel_type $rel_type \ -community_id $community_id \ @@ -697,13 +686,13 @@ } ad_proc -public add_user_to_community { - {-rel_type "dotlrn_member_rel"} + {-rel_type dotlrn_member_rel} {-community_id:required} {-user_id:required} - {-member_state "approved"} + {-member_state approved} {-extra_vars ""} } { - Assigns a user to a particular role for that class. + Assigns a user to a particular role for that class. Roles in DOTLRN can be student, prof, ta, admin } { if {[member_p $community_id $user_id]} { @@ -738,7 +727,7 @@ } } - if {[string equal $member_state "approved"] == 1} { + if {[string equal $member_state approved] == 1} { membership_approve -user_id $user_id -community_id $community_id } } @@ -853,7 +842,7 @@ } { set type [get_community_type_from_community_id $community_id] - if {[string equal $type "dotlrn_community"] == 1} { + if {[string equal $type dotlrn_community] == 1} { return $type } @@ -893,17 +882,17 @@ } ad_proc -public get_community_id_from_url { - {-url ""} + {-url ""} } { - returns the community from a URL + returns the community from a URL } { - if {[empty_string_p $url]} { - set url [ad_conn url] - } + if {[empty_string_p $url]} { + set url [ad_conn url] + } - set package_id [site_node_closest_ancestor_package -url $url dotlrn] + set package_id [site_node_closest_ancestor_package -url $url dotlrn] - return [get_community_id -package_id $package_id] + return [get_community_id -package_id $package_id] } ad_proc -public get_community_id { @@ -996,26 +985,14 @@ sibling's name. } { if {![empty_string_p $parent_community_id]} { - set valid_p [ad_decode [db_string collision_check_with_parent {}] \ - 0 \ - 1 \ - 0 - ] + set valid_p [ad_decode [db_string collision_check_with_parent {}] 0 1 0] } else { - set valid_p [ad_decode [db_string collision_check_simple {}] \ - 0 \ - 1 \ - 0 - ] + set valid_p [ad_decode [db_string collision_check_simple {}] 0 1 0] } - -# ad_return_complaint 1 "valid $valid_p / key $community_key" if {$complain_if_invalid_p && !$valid_p} { - ad_return_complaint \ - 1 \ - "The name $community_key is already in use either by - an active or archived group. \n Please go back and select a different name." + ad_return_complaint 1 \ + "The name $community_key is already in use either by an active or archived group. \n Please go back and select a different name." ad_script_abort } else { return $valid_p @@ -1063,7 +1040,7 @@ {-community_id:required} } { Returns a tcl list of ns_sets with info about each subcomm. The keys - are: community_id, community_key, pretty_name, and url + are: community_id, community_key, pretty_name, and url } { return [db_list_of_ns_sets select_subcomms_info {}] } @@ -1072,7 +1049,7 @@ {-user_id ""} {-community_id:required} {-pretext "