Index: openacs-4/packages/dotlrn/sql/oracle/dotlrn-communities-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/sql/oracle/Attic/dotlrn-communities-create.sql,v diff -u -r1.23 -r1.24 --- openacs-4/packages/dotlrn/sql/oracle/dotlrn-communities-create.sql 11 Feb 2002 05:16:58 -0000 1.23 +++ openacs-4/packages/dotlrn/sql/oracle/dotlrn-communities-create.sql 14 Feb 2002 19:43:11 -0000 1.24 @@ -6,7 +6,8 @@ -- for Oracle 8/8i. (We're guessing 9i works, too). -- -- @author Ben Adida (ben@openforce.net) --- @author yon (yon@openforce.net) +-- @author yon (yon@openforce.net +-- @author arjun (arjun@openforce.net) -- @creation-date September 20th, 2001 (redone) -- @version $Id$ -- @@ -38,9 +39,7 @@ references dotlrn_community_types (community_type), community_key varchar2(100) constraint dotlrn_c_community_key_nn - not null - constraint dotlrn_c_community_key_un - unique, + not null, pretty_name varchar2(100) constraint dotlrn_c_pretty_name_nn not null, @@ -54,7 +53,11 @@ portal_template_id constraint dotlrn_c_portal_template_id_fk references portals (portal_id), package_id constraint dotlrn_c_package_id_fk - references apm_packages (package_id) + references apm_packages (package_id), + -- We can't have two communities with the same parent with the same key (url) + -- even if the parent_community_id is NULL, which it will be for non-subcommunities + constraint dotlrn_c_community_key_un + unique(community_key,parent_community_id) ); create or replace view dotlrn_communities_not_closed Index: openacs-4/packages/dotlrn/tcl/club-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/club-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/dotlrn/tcl/club-procs.tcl 11 Dec 2001 00:45:15 -0000 1.4 +++ openacs-4/packages/dotlrn/tcl/club-procs.tcl 14 Feb 2002 19:43:11 -0000 1.5 @@ -52,6 +52,7 @@ {-pretty_name:required} {-description:required} {-join_policy "open"} + {-parent_community_id ""} } { creates a new club and returns the club key } { @@ -64,6 +65,7 @@ -community_key $key \ -pretty_name $pretty_name \ -description $description \ + -parent_community_id $parent_community_id \ -extra_vars $extra_vars] } Index: openacs-4/packages/dotlrn/tcl/community-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/community-procs-oracle.xql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/dotlrn/tcl/community-procs-oracle.xql 23 Jan 2002 00:15:43 -0000 1.8 +++ openacs-4/packages/dotlrn/tcl/community-procs-oracle.xql 14 Feb 2002 19:43:11 -0000 1.9 @@ -78,7 +78,10 @@ where supertype = 'dotlrn_community' start with object_type = (select community_type from dotlrn_communities - where community_id = :community_id) + where parent_id is NULL + and community_type != 'dotlrn_community' + start with community_id = :community_id + connect by community_id = prior parent_community_id) connect by object_type = prior supertype 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.56 -r1.57 --- openacs-4/packages/dotlrn/tcl/community-procs.tcl 11 Feb 2002 20:17:52 -0000 1.56 +++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 14 Feb 2002 19:43:11 -0000 1.57 @@ -307,6 +307,10 @@ return {dotlrn_member_rel dotlrn_admin_rel} } + if {$community_type == "dotlrn_community"} { + return {dotlrn_member_rel dotlrn_admin_rel} + } + return {} } @@ -623,6 +627,41 @@ return [db_string select_community {} -default ""] } + ad_proc -public get_parent_id { + {-community_id:required} + } { + Returns the parent community's id or null + } { + return [db_string select_parent_id {} -default ""] + } + + ad_proc -public subcommunity_p { + {-community_id:required} + } { + Returns 1 if the community is a subcommunity, else 0 + } { + if {[empty_string_p [get_parent_id -community_id $community_id]]} { + return 0 + } else { + return 1 + } + } + + ad_proc -public get_subcomm_list { + {-community_id:required} + } { + Returns a tcl list of the subcommunities of this community or + if none, the empty list + } { + set subcomm_list [list] + + db_foreach select_subcomms {} { + lappend subcomm_list $subcomm_id + } + + return $subcomm_list + } + ad_proc -public get_community_type_url { community_type } { @@ -680,6 +719,15 @@ return [db_string select_community_name {} -default ""] } + ad_proc -public get_community_description { + community_id + } { + get the description for a community + } { + return [db_string select_community_description {} -default ""] + } + + ad_proc -public get_portal_template_id { {community_id ""} } { Index: openacs-4/packages/dotlrn/tcl/community-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/community-procs.xql,v diff -u -r1.26 -r1.27 --- openacs-4/packages/dotlrn/tcl/community-procs.xql 12 Feb 2002 19:08:08 -0000 1.26 +++ openacs-4/packages/dotlrn/tcl/community-procs.xql 14 Feb 2002 19:43:11 -0000 1.27 @@ -192,6 +192,18 @@ + + +select parent_community_id from dotlrn_communities where community_id = :community_id + + + + + +select community_id as subcomm_id from dotlrn_communities where parent_community_id = :community_id + + + select package_id from dotlrn_community_types where community_type= :community_type @@ -226,6 +238,13 @@ + + +select description from dotlrn_communities where community_id= :community_id + + + + select portal_template_id from dotlrn_communities where community_id= :community_id Index: openacs-4/packages/dotlrn/www/dotlrn-main-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/dotlrn-main-portlet.adp,v diff -u -r1.5 -r1.6 --- openacs-4/packages/dotlrn/www/dotlrn-main-portlet.adp 23 Jan 2002 04:58:08 -0000 1.5 +++ openacs-4/packages/dotlrn/www/dotlrn-main-portlet.adp 14 Feb 2002 19:43:11 -0000 1.6 @@ -9,17 +9,20 @@ <%= [ad_parameter classes_pretty_plural] %> <%= [ad_parameter clubs_pretty_plural] %> Index: openacs-4/packages/dotlrn/www/one-community-not-member.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/Attic/one-community-not-member.adp,v diff -u -r1.10 -r1.11 --- openacs-4/packages/dotlrn/www/one-community-not-member.adp 28 Jan 2002 21:57:52 -0000 1.10 +++ openacs-4/packages/dotlrn/www/one-community-not-member.adp 14 Feb 2002 19:43:11 -0000 1.11 @@ -1,6 +1,6 @@ @context_bar@ -@pretty_name@ +@pretext@ @portal_id@ @admin_p@ Index: openacs-4/packages/dotlrn/www/one-community.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/one-community.adp,v diff -u -r1.12 -r1.13 --- openacs-4/packages/dotlrn/www/one-community.adp 28 Jan 2002 21:57:52 -0000 1.12 +++ openacs-4/packages/dotlrn/www/one-community.adp 14 Feb 2002 19:43:11 -0000 1.13 @@ -1,9 +1,10 @@ + + -@context_bar@ -@pretty_name@ +@pretext@ @portal_id@ @admin_p@ -Group Admin +@control_panel_text@

Index: openacs-4/packages/dotlrn/www/one-community.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/one-community.tcl,v diff -u -r1.18 -r1.19 --- openacs-4/packages/dotlrn/www/one-community.tcl 25 Jan 2002 22:28:27 -0000 1.18 +++ openacs-4/packages/dotlrn/www/one-community.tcl 14 Feb 2002 19:43:11 -0000 1.19 @@ -21,10 +21,21 @@ set community_id [dotlrn_community::get_community_id] # Get basic information -db_1row select_community_info {} +set pretty_name [dotlrn_community::get_community_name $community_id] set admin_p [dotlrn::user_can_admin_community_p $community_id] + +# are we in a subcomm? if so, we need to set up the text and navbar +set pretext "" +set parent_id [dotlrn_community::get_parent_id \ + -community_id $community_id] + +if {![empty_string_p $parent_id]} { + set parent_name [dotlrn_community::get_community_name $parent_id] + set pretext "$parent_name : " +} + # Check that this user is a member if {![dotlrn_community::member_p $community_id $user_id]} { set context_bar [list "Not a member"] @@ -49,10 +60,10 @@ # Pull out the NPP page ID and render it! set portal_id [dotlrn_community::get_portal_id $community_id $user_id] -# ad_return_complaint 1 "$portal_id" set rendered_page [dotlrn::render_page -hide_links_p "t" -page_num $page_num $portal_id] set context_bar {View} + set control_panel_text "Group Admin" set url_stub "one-community" ad_return_template Index: openacs-4/packages/dotlrn/www/subcommunity-new.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/subcommunity-new.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/www/subcommunity-new.adp 14 Feb 2002 19:43:11 -0000 1.1 @@ -0,0 +1,4 @@ + +@title@ + + Index: openacs-4/packages/dotlrn/www/subcommunity-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/subcommunity-new.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/www/subcommunity-new.tcl 14 Feb 2002 19:43:11 -0000 1.1 @@ -0,0 +1,107 @@ +ad_page_contract { + create a new subcommunity (aks subgroup) + + @author arjun (arjun@openforce.net) + @creation-date 2001-02-12 + @version $Id: subcommunity-new.tcl,v 1.1 2002/02/14 19:43:11 arjun Exp $ +} -query { + {referer "one-community-admin"} +} -properties { + title:onevalue +} + +set parent_community_id [dotlrn_community::get_community_id] + +set title "New [ad_parameter subcommunity_pretty_name]" + +form create add_subcomm + +element create add_subcomm subcomm_key \ + -label "[ad_parameter subcommunity_pretty_name] Key (a short name, no spaces)" \ + -datatype text \ + -widget text \ + -html {size 60} + +element create add_subcomm pretty_name \ + -label "Name" \ + -datatype text \ + -widget text \ + -html {size 60} + +element create add_subcomm description \ + -label "Charter" \ + -datatype text \ + -widget textarea \ + -html {rows 5 cols 60 wrap soft} + +element create add_subcomm join_policy \ + -label "Join Policy" \ + -datatype text \ + -widget select \ + -options {{Open open} {"Needs Approval" "needs approval"} {Closed closed}} + +element create add_subcomm referer \ + -label "Referer" \ + -datatype text \ + -widget hidden \ + -value $referer + +if {[form is_valid add_subcomm]} { + form get_values add_subcomm \ + subcomm_key pretty_name description join_policy referer + + # we set some extra vars based on the community_type of the parent + set parent_type \ + [dotlrn_community::get_community_type_from_community_id \ + $parent_community_id] + set extra_vars [ns_set create] + +# ad_return_complaint 1 "pt $parent_type" + + if {$parent_type == "dotlrn_community"} { + # we want to make a subcomm of a subcomm + # nothing for now + } elseif {$parent_type != [dotlrn_club::community_type]} { + # we want to make a subgroup of a class instance + # get the term_id, since the subgroup should not outlive the class + set term_id [dotlrn_class::get_term_id \ + -class_instance_id $parent_community_id] + + ns_set put $extra_vars term_id $term_id + } + + ns_set put $extra_vars join_policy $join_policy + + db_transaction { + set subcomm_id [dotlrn_community::new \ + -parent_community_id $parent_community_id \ + -description $description \ + -community_type "dotlrn_community" \ + -community_key $subcomm_key \ + -pretty_name $pretty_name \ + -extra_vars $extra_vars] + + + # let admins of the parent comm, be admins + set parent_admin_segment_id [dotlrn_community::get_rel_segment_id \ + -community_id $parent_community_id \ + -rel_type "dotlrn_admin_rel"] + + # granting admin privs to the admins of the parent comm over the subcomm + ad_permission_grant $parent_admin_segment_id $subcomm_id admin + + # for a subcomm of a "class" set the start and end dates + if {![string equal $parent_type [dotlrn_club::community_type]] && + ![string equal $parent_type "dotlrn_community"]} { + dotlrn_community::set_active_dates \ + -community_id $subbcomm_id \ + -start_date [dotlrn_term::get_start_date -term_id $term_id] \ + -end_date [dotlrn_term::get_end_date -term_id $term_id] + } + } + + ad_returnredirect $referer + ad_script_abort +} + +ad_return_template