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.7 -r1.8
--- openacs-4/packages/dotlrn/tcl/department-procs.tcl 9 Aug 2002 18:39:25 -0000 1.7
+++ openacs-4/packages/dotlrn/tcl/department-procs.tcl 14 Aug 2002 19:16:12 -0000 1.8
@@ -75,4 +75,34 @@
return [db_list_of_lists select_departments {}]
}
+ ad_proc -public count_classes {
+ {-department_key:required}
+ } {
+ retuns the number of classes under this department
+ } {
+ return [db_string select_count_classes {} -default 0]
+ }
+
+ ad_proc -public delete {
+ {-department_key:required}
+ } {
+ Deletes an empty department. Use count_classes to verify it's empty.
+ } {
+ # check that it's empty
+ if {![count_classes -department_key $department_key] == 0} {
+ ad_return_complaint 1 "Error: [parameter::get -parameter departments_pretty_name]
+ must be empty to be deleted"
+ ad_script_abort
+ }
+
+ db_transaction {
+ # delete the dept from the table
+ db_dml delete_department {}
+
+ # since depts are types, delete the type
+ dotlrn_community::delete_type -community_type_key $department_key
+
+ }
+ }
+
}
Index: openacs-4/packages/dotlrn/tcl/department-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/department-procs.xql,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/dotlrn/tcl/department-procs.xql 1 May 2002 01:19:47 -0000 1.5
+++ openacs-4/packages/dotlrn/tcl/department-procs.xql 14 Aug 2002 19:16:12 -0000 1.6
@@ -28,4 +28,16 @@
+
+
+ select count(*) from dotlrn_classes where department_key = :department_key
+
+
+
+
+
+ delete from dotlrn_departments where department_key = :department_key
+
+
+