Index: openacs-4/packages/acs-subsite/www/admin/group-types/delete-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/group-types/delete-2.tcl,v diff -u -N -r1.11 -r1.12 --- openacs-4/packages/acs-subsite/www/admin/group-types/delete-2.tcl 9 May 2018 15:33:28 -0000 1.11 +++ openacs-4/packages/acs-subsite/www/admin/group-types/delete-2.tcl 11 Dec 2018 14:14:41 -0000 1.12 @@ -31,70 +31,14 @@ ad_script_abort } -set plsql [list] - -if { ![db_0or1row select_type_info { - select t.table_name, t.package_name - from acs_object_types t - where t.object_type=:group_type -}] } { - set table_name "" - set package_name $group_type -} - -if { [db_string package_exists {}] } { - lappend plsql [list "package_drop" [db_map package_drop]] -} else { - set package_name "" -} - -# Remove the specified rel_types -lappend plsql [list "delete_rel_types" [db_map delete_rel_types]] - -# Remove the group_type -lappend plsql [list "delete_group_type" [db_map delete_group_type]] - -if { [db_string type_exists {}] } { - lappend plsql [list "drop_type" [db_map drop_type]] -} - -# Make sure we drop the table last -if { $table_name ne "" && [db_table_exists $table_name] } { - lappend plsql [list "drop_table" [db_map drop_table]] -} - -# How do we handle the situation where we delete the groups we can, -# but there are groups that we do not have permission to delete? For -# now, we check in advance if there is a group that must be deleted -# that this user can't delete, and if there is, we return an error -# message (in the validate block of page contract). If another group -# is added while we're deleting, then it's possible that we'll fail -# when actually dropping the type, but that seems reasonable to me. -# - mbryzek (famous last words...) - -set user_id [ad_conn user_id] - -db_transaction { - # First delete the groups - if { $package_name ne "" } { - - foreach group_id [db_list select_group_ids {}] { - group::delete $group_id - } - } - - foreach pair $plsql { - db_exec_plsql [lindex $pair 0] [lindex $pair 1] - } -} on_error { +if {[catch { + group_type::delete -group_type $group_type +} errmsg]} { ad_return_error "Error deleting group type" "We got the following error trying to delete this group type:
$errmsg
" - return + ad_script_abort } -# Reset the attribute view for objects of this type -package_object_view_reset $group_type - -ad_returnredirect $return_url +ad_returnredirect $return_url ad_script_abort # Local variables: