Index: openacs-4/packages/forums/sql/postgresql/forums-forums-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/postgresql/forums-forums-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/forums/sql/postgresql/forums-forums-create.sql	1 Jun 2002 19:02:29 -0000	1.1
+++ openacs-4/packages/forums/sql/postgresql/forums-forums-create.sql	12 Jun 2002 15:24:02 -0000	1.2
@@ -10,90 +10,109 @@
 --
 
 -- privileges
+create function inline_0 ()
+returns integer as '
 begin
-   -- moderate and post are new privileges
-   -- the rest are obvious inheritance
-   -- forum creation on a package allows a user to create forums
-   -- forum creation on a forum allows a user to create new threads
-   select acs_privilege__create_privilege('forum_create',null,null);
-   select acs_privilege__create_privilege('forum_write',null,null);
-   select acs_privilege__create_privilege('forum_delete',null,null);
-   select acs_privilege__create_privilege('forum_read',null,null);
-   select acs_privilege__create_privilege('forum_post',null,null);
-   select acs_privilege__create_privilege('forum_moderate',null,null);
 
-   -- temporarily drop this trigger to avoid a data-change violation 
-   -- on acs_privilege_hierarchy_index while updating the child privileges.
+    -- moderate and post are new privileges
+    -- the rest are obvious inheritance
+    -- forum creation on a package allows a user to create forums
+    -- forum creation on a forum allows a user to create new threads
+    perform acs_privilege__create_privilege(''forum_create'',null,null);
+    perform acs_privilege__create_privilege(''forum_write'',null,null);
+    perform acs_privilege__create_privilege(''forum_delete'',null,null);
+    perform acs_privilege__create_privilege(''forum_read'',null,null);
+    perform acs_privilege__create_privilege(''forum_post'',null,null);
+    perform acs_privilege__create_privilege(''forum_moderate'',null,null);
 
-   drop trigger acs_priv_hier_ins_del_tr on acs_privilege_hierarchy;
+    -- temporarily drop this trigger to avoid a data-change violation 
+    -- on acs_privilege_hierarchy_index while updating the child privileges.
 
-   -- add children
-   select acs_privilege__add_child('create','forum_create');
-   select acs_privilege__add_child('write','forum_write');
-   select acs_privilege__add_child('delete','forum_delete');
-   select acs_privilege__add_child('admin','forum_moderate');
-   select acs_privilege__add_child('forum_moderate','forum_read');
-   select acs_privilege__add_child('forum_moderate','forum_post');
-   select acs_privilege__add_child('forum_write','forum_read');
-   select acs_privilege__add_child('forum_write','forum_post');
-   
-   -- re-enable the trigger before the last insert to force the 
-   -- acs_privilege_hierarchy_index table to be updated.
+    drop trigger acs_priv_hier_ins_del_tr on acs_privilege_hierarchy;
 
-   create trigger acs_priv_hier_ins_del_tr after insert or delete
-   on acs_privilege_hierarchy for each row
-   execute procedure acs_priv_hier_ins_del_tr ();
+    -- add children
+    perform acs_privilege__add_child(''create'',''forum_create'');
+    perform acs_privilege__add_child(''write'',''forum_write'');
+    perform acs_privilege__add_child(''delete'',''forum_delete'');
+    perform acs_privilege__add_child(''admin'',''forum_moderate'');
+    perform acs_privilege__add_child(''forum_moderate'',''forum_read'');
+    perform acs_privilege__add_child(''forum_moderate'',''forum_post'');
+    perform acs_privilege__add_child(''forum_write'',''forum_read'');
+    perform acs_privilege__add_child(''forum_write'',''forum_post'');
+    
+    -- re-enable the trigger before the last insert to force the 
+    -- acs_privilege_hierarchy_index table to be updated.
 
-   -- the last one that will cause all the updates
-   select acs_privilege__add_child('read','forum_read');
-end;
+    create trigger acs_priv_hier_ins_del_tr after insert or delete
+    on acs_privilege_hierarchy for each row
+    execute procedure acs_priv_hier_ins_del_tr ();
 
+    -- the last one that will cause all the updates
+    perform acs_privilege__add_child(''read'',''forum_read'');
 
---
--- The Data Model
---
+    return null;
+end;' language 'plpgsql';
 
+select inline_0();
+drop function inline_0 ();
+
 create table forums_forums (
-       forum_id                 integer not null
-                                constraint forums_forum_id_fk
-                                references acs_objects(object_id)
-                                constraint forums_forum_id_pk
-                                primary key,
-       name                     varchar(200) constraint forum_name_nn not null,
-       charter                  varchar(2000),
-       presentation_type        varchar(100) 
-                                constraint forum_type_nn not null
-                                constraint forum_type_ch
-                                check (presentation_type in ('flat','threaded')),
-       posting_policy           varchar(100)
-                                constraint forum_policy_nn not null
-                                constraint forum_policy_ch
-                                check (posting_policy in ('open','moderated','closed')),
-       max_child_sortkey        varbit,
-       enabled_p                char(1) default 't' not null
-                                constraint forum_enabled_p_ch check
-                                (enabled_p in ('t','f')),
-       package_id               integer constraint forum_package_id_nn not null
+    forum_id                        integer
+                                    constraint forums_forum_id_fk
+                                    references acs_objects(object_id)
+                                    constraint forums_forum_id_pk
+                                    primary key,
+    name                            varchar(200)
+                                    constraint forum_name_nn
+                                    not null,
+    charter                         varchar(2000),
+    presentation_type               varchar(100) 
+                                    constraint forum_type_nn
+                                    not null
+                                    constraint forum_type_ck
+                                    check (presentation_type in ('flat','threaded')),
+    posting_policy                  varchar(100)
+                                    constraint forum_policy_nn
+                                    not null
+                                    constraint forum_policy_ck
+                                    check (posting_policy in ('open','moderated','closed')),
+    max_child_sortkey               varbit,
+    enabled_p                       char(1) default 't'
+                                    constraint forum_enabled_p_nn
+                                    not null
+                                    constraint forum_enabled_p_ck
+                                    check (enabled_p in ('t', 'f')),
+    package_id                      integer
+                                    constraint forum_package_id_fk
+                                    references apm_packages (package_id)
+                                    constraint forum_package_id_nn
+                                    not null
 );
 
 create view forums_forums_enabled
-as select * from forums_forums where enabled_p='t';
+as
+    select *
+    from forums_forums
+    where enabled_p = 't';
 
---
--- Object Type
---
-
+create function inline_0 ()
+returns integer as'
 begin
-        select acs_object_type__create_type (
-            'forums_forum',
-            'Forums Forum',
-            'Forums Forums',
-            'acs_object',
-            'forums_forums',
-            'forum_id',
-            'forums_forum',
-	    'f',
-	    NULL,
-	    'forums_forum__name'
-        );
-end;
+    perform acs_object_type__create_type(
+        ''forums_forum'',
+        ''Forums Forum'',
+        ''Forums Forums'',
+        ''acs_object'',
+        ''forums_forums'',
+        ''forum_id'',
+        ''forums_forum'',
+        ''f'',
+        null,
+        ''forums_forum__name''
+    );
+
+    return null;
+end;' language 'plpgsql';
+
+select inline_0();
+drop function inline_0();
