--
-- forums_forum__new/11
--
create or replace function forums_forum__new(
  p_forum_id integer,
  p_object_type character varying,
  p_name character varying,
  p_charter character varying,
  p_presentation_type character varying,
  p_posting_policy character varying,
  p_package_id integer,
  p_creation_date timestamp with time zone,
  p_creation_user integer,
  p_creation_ip character varying,
  p_context_id integer
) returns int4 as $$

DECLARE
    v_forum_id                      integer;
BEGIN
    v_forum_id:= acs_object__new(
        p_forum_id,
        p_object_type,
        p_creation_date,
        p_creation_user,
        p_creation_ip,
        coalesce(p_context_id, p_package_id),
        't',
        p_name,
        p_package_id
    );

    insert into forums_forums
    (forum_id, name, charter, presentation_type, posting_policy, package_id)
    values
    (v_forum_id, p_name, p_charter, p_presentation_type, p_posting_policy, p_package_id);

    return v_forum_id;
END;

$$ language plpgsql;