Index: openacs-4/packages/dotlrn/sql/oracle/dotlrn-communities-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/sql/oracle/Attic/dotlrn-communities-package-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/dotlrn/sql/oracle/dotlrn-communities-package-create.sql 3 Apr 2002 00:33:12 -0000 1.2 +++ openacs-4/packages/dotlrn/sql/oracle/dotlrn-communities-package-create.sql 4 Apr 2002 05:55:45 -0000 1.3 @@ -164,13 +164,14 @@ party_id in parties.party_id%TYPE ) return char; + function url ( + community_id in dotlrn_communities.community_id%TYPE + ) return varchar2; + function has_subcomm_p ( community_id in dotlrn_communities.community_id%TYPE ) return char; - function url ( - community_id in dotlrn_communities.community_id%TYPE - ) return varchar2; end dotlrn_community; / show errors @@ -325,14 +326,12 @@ is v_rv char(1); begin - - select decode(count(*), 0, 'f', 't') into v_rv - from dual where exists ( - select 'x' - from dotlrn_communities - where parent_community_id = community_id - ); - + select decode(count(*), 0, 'f', 't') + into v_rv + from dual + where exists (select 1 + from dotlrn_communities + where parent_community_id = has_subcomm_p.community_id); return v_rv; end; 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.96 -r1.97 --- openacs-4/packages/dotlrn/tcl/community-procs.tcl 3 Apr 2002 00:33:12 -0000 1.96 +++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 4 Apr 2002 05:55:45 -0000 1.97 @@ -885,11 +885,20 @@ ad_proc -public has_subcommunity_p { {-community_id:required} } { + Returns 1 if the community has a subcommunity, memoized for 1 min + } { + return [util_memoize "dotlrn_community::has_subcommunity_p_memoized -community_id $community_id" 60] + } + + ad_proc -public has_subcommunity_p_memoized { + {-community_id:required} + } { Returns 1 if the community has a subcommunity } { return [db_0or1row select_subcomm_check {}] } + ad_proc -public get_subcomm_list { {-community_id:required} } { @@ -914,8 +923,10 @@ member of all the supergroups to the leaf subgroup. Not even admins see the whole tree. - FIXME: totally unoptimized!! + FIXME: still rather slow + things to get: has_subcom, member_p, url, name, admin_p, not_closed_p, member_pending, needs_approval + things to send: user_id, sc_id, } { set chunk "" @@ -987,6 +998,117 @@ return $chunk } + + ad_proc -public get_subcomm_chunk_new { + {-user_id ""} + {-community_id:required} + {-pretext "
debug: $has_subcomm_p / $m_s = $member_p / $a_s = $admin_p " + + if {$admin_p} { + append chunk \ + "\[admin\]" + } + + append chunk \ + "
debug: $has_subcomm_p / $m_s = $member_p / $a_s = $admin_p "
+
+ if {!$member_p && [not_closed_p -community_id $sc_id]} {
+
+ append chunk \
+ "\["
+
+ if {[member_pending_p -community_id $sc_id -user_id $user_id]} {
+ append chunk \
+ "waiting for approval"
+ } elseif {[needs_approval_p -community_id $sc_id]} {
+ append chunk \
+ "request membership"
+ } else {
+ append chunk \
+ "join"
+ }
+
+ append chunk "\]\n"
+ }
+
+ if {$admin_p} {
+ append chunk \
+ " \[admin\]\n"
+ }
+ }
+ }
+
+ return $chunk
+ }
+
ad_proc -public get_community_type_url {
community_type
} {
@@ -1041,6 +1163,14 @@
} {
get the name for a community
} {
+ return [util_memoize "dotlrn_community::get_community_name_memoized $community_id"]
+ }
+
+ ad_proc -public get_community_name_memoized {
+ community_id
+ } {
+ memo helper
+ } {
return [db_string select_community_name {} -default ""]
}
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.45 -r1.46
--- openacs-4/packages/dotlrn/tcl/community-procs.xql 29 Mar 2002 19:38:25 -0000 1.45
+++ openacs-4/packages/dotlrn/tcl/community-procs.xql 4 Apr 2002 05:55:45 -0000 1.46
@@ -256,7 +256,7 @@
-