Index: openacs-4/packages/dotlrn/tcl/department-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/department-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn/tcl/department-procs.tcl 22 Jan 2002 00:13:09 -0000 1.1 +++ openacs-4/packages/dotlrn/tcl/department-procs.tcl 16 Mar 2002 17:38:08 -0000 1.2 @@ -9,13 +9,24 @@ namespace eval dotlrn_department { ad_proc -public new { - {-department_key:required} {-pretty_name:required} {-description ""} {-external_url ""} } { Create a new department. } { + + set department_key [dotlrn::generate_key -name $pretty_name] + + # check if the name is already in use, if so, complain loudly + if {![check_department_key_valid_p \ + -department_key $department_key]} { + ad_return_complaint \ + 1 \ + "The name $pretty_name is already in use. \n + Please select a different name." + } + db_transaction { dotlrn_community::new_type \ -community_type_key $department_key \ @@ -27,6 +38,18 @@ } } + ad_proc -public check_department_key_valid_p { + {-department_key:required} + } { + Checks if the key is in use as a department key + } { + if {[db_0or1row check {}]} { + return 0 + } else { + return 1 + } + } + ad_proc -public select_as_list { } { Select all departments as a list of tuples of format: