group_type::delete (public)

 group_type::delete -group_type group_type

Defined in packages/acs-subsite/tcl/group-type-procs.tcl

Deletes a group type

Switches:
-group_type (required)
type to be deleted

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_subsite_group_type acs_subsite_group_type (test acs-subsite) group_type::delete group_type::delete test_acs_subsite_group_type->group_type::delete ad_conn ad_conn (public) group_type::delete->ad_conn db_0or1row db_0or1row (public) group_type::delete->db_0or1row db_dml db_dml (public) group_type::delete->db_dml db_exec_plsql db_exec_plsql (public) group_type::delete->db_exec_plsql db_list db_list (public) group_type::delete->db_list packages/acs-subsite/www/admin/group-types/delete-2.tcl packages/acs-subsite/ www/admin/group-types/delete-2.tcl packages/acs-subsite/www/admin/group-types/delete-2.tcl->group_type::delete

Testcases:
acs_subsite_group_type
Source code:
        # 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 {
                   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')
                }] {
                    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 case when exists
                (select 1 from acs_object_types t where t.object_type = :group_type)
                then 1 else 0 end
                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
Generic XQL file:
packages/acs-subsite/tcl/group-type-procs.xql

PostgreSQL XQL file:
<fullquery name="group_type::delete.package_exists">
    <querytext>
    select case when exists (select 1
    from pg_proc
    where proname like :package_name || '%')
    then 1 else 0 end
  </querytext>
</fullquery>

<fullquery name="group_type::delete.package_drop">
    <querytext>
    select drop_package(:group_type)
  </querytext>
</fullquery>

<fullquery name="group_type::delete.drop_type">
    <querytext>
    select acs_object_type__drop_type(:group_type, 'f')
  </querytext>
</fullquery>
packages/acs-subsite/tcl/group-type-procs-postgresql.xql

Oracle XQL file:
<fullquery name="group_type::delete.package_exists">
    <querytext>
    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
  </querytext>
</fullquery>

<fullquery name="group_type::delete.package_drop">
    <querytext>
    drop package [DoubleApos $group_type]
  </querytext>
</fullquery>

<fullquery name="group_type::delete.drop_type">
    <querytext>
    begin acs_object_type.drop_type(:group_type); end;
  </querytext>
</fullquery>
packages/acs-subsite/tcl/group-type-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: