Index: openacs-4/packages/acs-subsite/tcl/group-type-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/group-type-procs-oracle.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/acs-subsite/tcl/group-type-procs-oracle.xql 3 Aug 2001 21:09:20 -0000 1.2 +++ openacs-4/packages/acs-subsite/tcl/group-type-procs-oracle.xql 11 Dec 2018 14:14:41 -0000 1.3 @@ -66,5 +66,38 @@ - + + + select case when exists (select 1 + from user_objects o + where o.object_type='PACKAGE' + and o.object_name = upper(:package_name)) + then 1 else 0 end + from dual + + + + + + drop package [DoubleApos $group_type] + + + + + + begin acs_object_type.drop_type(:group_type); end; + + + + + + select distinct o.object_id + from acs_objects o, acs_object_party_privilege_map perm + where perm.object_id = o.object_id + and perm.party_id = :user_id + and perm.privilege = 'delete' + and o.object_type = :group_type + + + Index: openacs-4/packages/acs-subsite/tcl/group-type-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/group-type-procs-postgresql.xql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/acs-subsite/tcl/group-type-procs-postgresql.xql 14 Jun 2018 09:16:48 -0000 1.4 +++ openacs-4/packages/acs-subsite/tcl/group-type-procs-postgresql.xql 11 Dec 2018 14:14:41 -0000 1.5 @@ -72,5 +72,35 @@ - + + + + select case when exists (select 1 + from pg_proc + where proname like :package_name || '%') + then 1 else 0 end + + + + + + select drop_package(:group_type) + + + + + + select acs_object_type__drop_type(:group_type, 'f') + + + + + + select o.object_id + from acs_objects o + where o.object_type = :group_type + and acs_permission__permission_p(o.object_id, :user_id, 'delete') + + + Index: openacs-4/packages/acs-subsite/tcl/group-type-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/group-type-procs.tcl,v diff -u -N -r1.11 -r1.12 --- openacs-4/packages/acs-subsite/tcl/group-type-procs.tcl 14 Jun 2018 09:18:13 -0000 1.11 +++ openacs-4/packages/acs-subsite/tcl/group-type-procs.tcl 11 Dec 2018 14:14:41 -0000 1.12 @@ -179,6 +179,76 @@ } + ad_proc -public delete { + -group_type:required + } { + Deletes a group type + + @param group_type type to be deleted + } { + # 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] + + 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 {}] } { + set package_name "" + } + + db_transaction { + # First delete the groups + if { $package_name ne "" } { + foreach group_id [db_list select_group_ids {}] { + group::delete $group_id + } + + db_exec_plsql package_drop {} + } + + # Remove the specified rel_types + db_dml delete_rel_types { + delete from group_type_rels where group_type = :group_type + } + + # Remove the group_type + db_dml delete_group_type { + delete from group_types where group_type = :group_type + } + + if { [db_string type_exists { + select exists (select 1 from acs_object_types t where t.object_type = :group_type) + from dual + }] } { + db_exec_plsql drop_type {} + } + + # Make sure we drop the table last + if { $table_name ne "" && [db_table_exists $table_name] } { + db_dml drop_table [subst { + drop table $table_name + }] + } + } + + # Reset the attribute view for objects of this type + package_object_view_reset $group_type + } + } # Local variables: Index: openacs-4/packages/acs-subsite/www/admin/group-types/delete-2-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/group-types/Attic/delete-2-oracle.xql,v diff -u -N --- openacs-4/packages/acs-subsite/www/admin/group-types/delete-2-oracle.xql 7 Aug 2017 23:47:58 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,79 +0,0 @@ - - - oracle8.1.6 - - - - - select case when exists (select 1 - from user_objects o - where o.object_type='PACKAGE' - and o.object_name = upper(:package_name)) - then 1 else 0 end - from dual - - - - - - - - - select case when exists (select 1 from acs_object_types t where t.object_type = :group_type) - then 1 - else 0 - end - from dual - - - - - - - drop package [DoubleApos $group_type] - - - - - - -delete from group_type_rels where group_type = :group_type - - - - - - -begin acs_object_type.drop_type(:group_type); end; - - - - - - -drop table $table_name - - - - - -begin -delete from group_types where group_type=:group_type; -end; - - - - - - - select distinct o.object_id - from acs_objects o, acs_object_party_privilege_map perm - where perm.object_id = o.object_id - and perm.party_id = :user_id - and perm.privilege = 'delete' - and o.object_type = :group_type - - - - - Index: openacs-4/packages/acs-subsite/www/admin/group-types/delete-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/group-types/Attic/delete-2-postgresql.xql,v diff -u -N --- openacs-4/packages/acs-subsite/www/admin/group-types/delete-2-postgresql.xql 11 Dec 2018 13:25:44 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,85 +0,0 @@ - - - postgresql9.0 - - - - - select case when exists (select 1 - from pg_proc - where proname like :package_name || '%') - then 1 else 0 end - - - - - - - - - - select case when exists (select 1 from acs_object_types t where t.object_type = :group_type) - then 1 - else 0 - end - - - - - - - - - select drop_package(:group_type) - - - - - - -begin - delete from group_type_rels where group_type = :group_type; - return 1; -end; - - - - - - -select acs_object_type__drop_type(:group_type, 'f') - - - - - - -begin - drop table $table_name; - return 1; -end; - - - - - - -begin -delete from group_types where group_type=:group_type; -return 1; -end; - - - - - - - select o.object_id - from acs_objects o - where o.object_type = :group_type - and acs_permission__permission_p(o.object_id, :user_id, 'delete') - - - - - 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: Index: openacs-4/packages/acs-subsite/www/admin/group-types/delete-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/group-types/Attic/delete-2.xql,v diff -u -N --- openacs-4/packages/acs-subsite/www/admin/group-types/delete-2.xql 7 Aug 2017 23:47:58 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,14 +0,0 @@ - - - - - - - select t.table_name, t.package_name - from acs_object_types t - where t.object_type=:group_type - - - - -