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

create function inline_0 ()
returns integer as'
declare
    v_package_key           apm_packages.package_key%TYPE;
    v_name                  cr_items.name%TYPE;
    v_label                 cr_folders.label%TYPE;
    v_folder_description    cr_folders.description%TYPE;
    v_folder_id             cr_folders.folder_id%TYPE;
begin

-- these are magic values
    v_package_key := ''classified-ads'';
    v_name := v_package_key;
    v_label := v_package_key;
    v_folder_description := v_package_key || '' Root Folder, all classified ads items go here'';

    
-- get the root folder for classified ads
    select folder_id into v_folder_id
    from cr_folders f, cr_items i
    where i.name = v_name and
          f.label = v_label and
          f.description = v_folder_description;

-- associate content types with classified ads folder
    PERFORM content_folder__register_content_type (
        v_folder_id,        -- folder_id
        ''ca_ad'',          -- content_type
        ''t''               -- include_subtypes
    );

    PERFORM content_folder__register_content_type (
        v_folder_id,            -- folder_id
        ''content_revision'',   -- content_type
        ''t''                   -- include_subtypes
    );

    PERFORM content_folder__register_content_type (
        v_folder_id,            -- folder_id
        ''content_folder'',     -- content_type
        ''t''                   -- include_subtypes
    );

    return null;
end;' language 'plpgsql';

select inline_0();
drop function inline_0();
