-- Classified Ads Package
--
-- @author Deds Castillo (deds@infiniteinfo.com)
-- @creation-date 2002-10-08
-- @cvs-id $Id: ads-drop.sql,v 1.1 2003/07/16 04:52:31 rmello Exp $
--

-- DEDS: FIXME - drop ads
create function inline_0 ()
returns integer as '
declare
    v_rec       record;
begin


-- unregister the mime types
    PERFORM content_type__unregister_mime_type (
        ''ca_ad'',                      -- content_type
	    ''text/html''                   -- mime_type
    );

    PERFORM content_type__unregister_mime_type (
        ''ca_ad'',                      -- content_type
	    ''text/plain''                  -- mime_type
    );

-- drop the attributes
    for v_rec in select attribute_id,attribute_name
                 from acs_attributes
                 where object_type = ''ca_ad''
    LOOP
        PERFORM ca_attributes__unregister_widget (
            v_rec.attribute_id
        );

        PERFORM ca_attributes__drop_attribute (
            ''ca_ad'',
            v_rec.attribute_name
        );
    end LOOP;

-- delete the content_type
    PERFORM content_type__drop_type (
        ''ca_ad'',           -- object_type
        ''t'',               -- drop children?
        ''t''                -- drop table?
    );  

    return null;
end;' language 'plpgsql';

select inline_0();
drop function inline_0 ();

