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.78 -r1.79 --- openacs-4/packages/dotlrn/tcl/community-procs.tcl 16 Mar 2002 02:02:07 -0000 1.78 +++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 16 Mar 2002 17:38:08 -0000 1.79 @@ -138,6 +138,15 @@ # generate the key from the passed in name set community_key [dotlrn::generate_key -name $pretty_name] + # check if the name is already in use, if so, complain loudly + if {![check_community_key_valid_p \ + -community_key $community_key \ + -parent_community_id $parent_community_id]} { + ad_return_complaint \ + 1 "The name $pretty_name is already in use. \n + Please select a different name." + } + # Add core vars ns_set put $extra_vars parent_community_id $parent_community_id ns_set put $extra_vars community_type $community_type @@ -771,6 +780,22 @@ return [db_string select_parent_id {} -default ""] } + ad_proc -public check_community_key_valid_p { + {-community_key:required} + {-parent_community_id ""} + } { + Checks if the community_key passed in is valid for creating a new + community by checking that it's not the same as an existing (possible) + sibling's name. + } { + if {[db_0or1row collision_check {}]} { + # got a collision + return 0 + } else { + return 1 + } + } + ad_proc -public subcommunity_p { {-community_id:required} } {