Index: openacs-4/packages/dotlrn/tcl/class-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/class-procs.tcl,v diff -u -r1.42 -r1.43 --- openacs-4/packages/dotlrn/tcl/class-procs.tcl 9 Aug 2002 18:39:25 -0000 1.42 +++ openacs-4/packages/dotlrn/tcl/class-procs.tcl 14 Aug 2002 19:13:40 -0000 1.43 @@ -109,7 +109,10 @@ {-pretty_name:required} {-description ""} } { - Creates a new class, like "Structure and Interpretation of + Creates a new class - a class is a new community TYPE, not an actual + class instance + + A class is like "Structure and Interpretation of Computer Programs." The return value is the short class name, a key that works in SQL, and that uniquely identifies the class. @@ -140,6 +143,37 @@ } } + ad_proc -public delete { + {-class_key:required} + } { + Deletes an empty class (the TYPE), if there are no + instanciated classes of this type. + } { + # check that it's empty + if {![count_class_instances -class_key $class_key] == 0} { + ad_return_complaint 1 "Error: A [parameter::get -parameter classes_pretty_name] + must have no[parameter::get -parameter class_instances_pretty_plural] to be deleted" + ad_script_abort + } + + db_transaction { + # delete the dept from the table + db_dml delete_class {} + + # since depts are types, delete the type + dotlrn_community::delete_type -community_type_key $class_key + + } + } + + ad_proc -public count_class_instances { + {-class_key:required} + } { + returns the number of class instances with the given class key + } { + return [db_string select_count_class_instaces {} -default 0] + } + ad_proc -public new_instance { {-class_key:required} {-term_id:required} Index: openacs-4/packages/dotlrn/tcl/class-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/class-procs.xql,v diff -u -r1.13 -r1.14 --- openacs-4/packages/dotlrn/tcl/class-procs.xql 16 May 2002 13:29:15 -0000 1.13 +++ openacs-4/packages/dotlrn/tcl/class-procs.xql 14 Aug 2002 19:13:41 -0000 1.14 @@ -11,6 +11,21 @@ + + + delete from dotlrn_classes + where class_key = :class_key + + + + + + select count(*) + from dotlrn_class_instances + where class_key = :class_key + + + select node_id