Index: openacs-4/packages/new-portal/sql/postgresql/api-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/sql/postgresql/api-create.sql,v
diff -u -N -r1.19 -r1.20
--- openacs-4/packages/new-portal/sql/postgresql/api-create.sql	7 Aug 2017 23:48:12 -0000	1.19
+++ openacs-4/packages/new-portal/sql/postgresql/api-create.sql	14 Sep 2018 14:11:06 -0000	1.20
@@ -24,69 +24,67 @@
 --
 
 select define_function_args('portal_page__new','page_id,pretty_name,accesskey,portal_id,layout_id,hidden_p,object_type;portal_page,creation_date,creation_user,creation_ip,context_id');
-
-
-
 --
 -- procedure portal_page__new/11
 --
-CREATE OR REPLACE FUNCTION portal_page__new(
-   p_page_id integer,
-   p_pretty_name varchar,
-   p_accesskey varchar,
-   p_portal_id integer,
-   p_layout_id integer,
-   p_hidden_p boolean,
-   p_object_type varchar, -- default 'portal_page'
-   p_creation_date timestamptz,
-   p_creation_user integer,
-   p_creation_ip varchar,
-   p_context_id integer
+    CREATE OR REPLACE FUNCTION portal_page__new(
+       p_page_id integer,
+       p_pretty_name varchar,
+       p_accesskey varchar,
+       p_portal_id integer,
+       p_layout_id integer,
+       p_hidden_p boolean,
+       p_object_type varchar, -- default 'portal_page'
+       p_creation_date timestamptz,
+       p_creation_user integer,
+       p_creation_ip varchar,
+       p_context_id integer
+    
+    ) RETURNS integer AS $$
+    DECLARE
+        v_page_id                       portal_pages.page_id%TYPE;
+        v_layout_id                     portal_pages.layout_id%TYPE;
+        v_sort_key                      portal_pages.sort_key%TYPE;
+    BEGIN
+    
+        v_page_id := acs_object__new(
+            null,               -- object_id 
+            p_object_type,      -- object_type 
+            p_creation_date,    -- creation_date 
+            p_creation_user,    -- creation_user 
+            p_creation_ip,      -- creation_ip 
+            p_context_id,       -- context_id 
+            true,               -- security_inherit_p 
+            p_pretty_name,      -- title 
+            null                -- package_id
+        );        
+        
+        if p_layout_id is null then
+            select min(layout_id)
+            into v_layout_id
+            from portal_layouts;
+        else
+            v_layout_id := p_layout_id;
+        end if;
+    
+        select coalesce(max(sort_key) + 1, 0)
+        into v_sort_key
+        from portal_pages
+        where portal_id = p_portal_id;
+    
+        insert into portal_pages
+        (page_id, pretty_name, accesskey, portal_id, layout_id, sort_key, hidden_p)
+        values
+        (v_page_id, p_pretty_name, p_accesskey, p_portal_id, v_layout_id, v_sort_key, p_hidden_p);
+    
+        return v_page_id;
+    
+    END;
+    $$ LANGUAGE plpgsql;
 
-) RETURNS integer AS $$
-DECLARE
-    v_page_id                       portal_pages.page_id%TYPE;
-    v_layout_id                     portal_pages.layout_id%TYPE;
-    v_sort_key                      portal_pages.sort_key%TYPE;
-BEGIN
 
-    v_page_id := acs_object__new(
-        null,
-        p_object_type,
-        p_creation_date,
-        p_creation_user,
-        p_creation_ip,
-        p_context_id,
-        't'
-    );
 
-    if p_layout_id is null then
-        select min(layout_id)
-        into v_layout_id
-        from portal_layouts;
-    else
-        v_layout_id := p_layout_id;
-    end if;
-
-    select coalesce(max(sort_key) + 1, 0)
-    into v_sort_key
-    from portal_pages
-    where portal_id = p_portal_id;
-
-    insert into portal_pages
-    (page_id, pretty_name, accesskey, portal_id, layout_id, sort_key, hidden_p)
-    values
-    (v_page_id, p_pretty_name, p_accesskey, p_portal_id, v_layout_id, v_sort_key, p_hidden_p);
-
-    return v_page_id;
-
-END;
-$$ LANGUAGE plpgsql;
-
 select define_function_args('portal_page__delete','page_id');
-
-
-
 --
 -- procedure portal_page__delete/1
 --
@@ -125,12 +123,12 @@
             update portal_pages
             set sort_key = -1
             where sort_key = i
-	    and page_id = p_page_id;
+        and page_id = p_page_id;
 
             update portal_pages
             set sort_key = i - 1
             where sort_key = -1
-	    and page_id = p_page_id;
+        and page_id = p_page_id;
 
         end if;
 
@@ -143,10 +141,9 @@
 END;
 $$ LANGUAGE plpgsql;
 
-select define_function_args('portal__new','portal_id,name,theme_id,layout_id,template_id,default_page_name,default_accesskey,object_type;portal,creation_date,creation_user,creation_ip,context_id');
 
 
-
+select define_function_args('portal__new','portal_id,name,theme_id,layout_id,template_id,default_page_name,default_accesskey,object_type;portal,creation_date,creation_user,creation_ip,context_id');
 --
 -- procedure portal__new/12
 --
@@ -178,15 +175,18 @@
 BEGIN
 
     v_portal_id := acs_object__new(
-        p_portal_id,
-        p_object_type,
-        p_creation_date,
-        p_creation_user,
-        p_creation_ip,
-        p_context_id,
-        't'
-    );
-
+        p_portal_id,        -- object_id 
+        p_object_type,      -- object_type 
+        p_creation_date,    -- creation_date 
+        p_creation_user,    -- creation_user 
+        p_creation_ip,      -- creation_ip 
+        p_context_id,       -- context_id 
+        true,               -- security_inherit_p 
+        p_name,             -- title 
+        null                -- package_id
+    );    
+    
+    
     if p_template_id is null then
 
         if p_theme_id is null then
@@ -245,7 +245,7 @@
         for v_page in select *
                       from portal_pages
                       where portal_id = p_template_id
-		      order by sort_key
+              order by sort_key
         loop
 
             v_page_id := portal_page__new(
@@ -309,10 +309,9 @@
 END;
 $$ LANGUAGE plpgsql;
 
-select define_function_args('portal__delete','portal_id');
 
 
-
+select define_function_args('portal__delete','portal_id');
 --
 -- procedure portal__delete/1
 --
@@ -337,10 +336,9 @@
 END;
 $$ LANGUAGE plpgsql;
 
-select define_function_args('portal_element_theme__new','theme_id,name,description,filename,resource_dir,object_type;portal_element_theme,creation_date,creation_user,creation_ip,context_id');
 
 
-
+select define_function_args('portal_element_theme__new','theme_id,name,description,filename,resource_dir,object_type;portal_element_theme,creation_date,creation_user,creation_ip,context_id');
 --
 -- procedure portal_element_theme__new/10
 --
@@ -362,15 +360,18 @@
 BEGIN
 
     v_theme_id := acs_object__new(
-        p_theme_id,
-        p_object_type,
-        p_creation_date,
-        p_creation_user,
-        p_creation_ip,
-        p_context_id,
-        't'
-    );
-
+        p_theme_id,         -- object_id 
+        p_object_type,      -- object_type 
+        p_creation_date,    -- creation_date 
+        p_creation_user,    -- creation_user 
+        p_creation_ip,      -- creation_ip 
+        p_context_id,       -- context_id 
+        true,               -- security_inherit_p 
+        p_name,             -- title 
+        null                -- package_id
+    );   
+    
+    
     insert
     into portal_element_themes
     (theme_id, name, description, filename, resource_dir)
@@ -418,10 +419,9 @@
 END;
 $$ LANGUAGE plpgsql;
 
-select define_function_args('portal_element_theme__delete','theme_id');
 
 
-
+select define_function_args('portal_element_theme__delete','theme_id');
 --
 -- procedure portal_element_theme__delete/1
 --
@@ -436,10 +436,9 @@
 END;
 $$ LANGUAGE plpgsql;
 
-select define_function_args('portal_layout__new','layout_id,name,description,filename,resource_dir,object_type;portal_layout,creation_date,creation_user,creation_ip,context_id');
 
 
-
+select define_function_args('portal_layout__new','layout_id,name,description,filename,resource_dir,object_type;portal_layout,creation_date,creation_user,creation_ip,context_id');
 --
 -- procedure portal_layout__new/10
 --
@@ -461,15 +460,17 @@
 BEGIN
 
     v_layout_id := acs_object__new(
-        p_layout_id,
-        p_object_type,
-        p_creation_date,
-        p_creation_user,
-        p_creation_ip,
-        p_context_id,
-        't'
-    );
-
+        p_layout_id,        -- object_id 
+        p_object_type,      -- object_type 
+        p_creation_date,    -- creation_date 
+        p_creation_user,    -- creation_user 
+        p_creation_ip,      -- creation_ip 
+        p_context_id,       -- context_id 
+        true,               -- security_inherit_p 
+        p_name,             -- title 
+        null                -- package_id
+    );   
+    
     insert into portal_layouts
     (layout_id, name, description, filename, resource_dir)
     values
@@ -516,10 +517,9 @@
 END;
 $$ LANGUAGE plpgsql;
 
-select define_function_args('portal_layout__delete','layout_id');
 
 
-
+select define_function_args('portal_layout__delete','layout_id');
 --
 -- procedure portal_layout__delete/1
 --
@@ -533,10 +533,9 @@
 END;
 $$ LANGUAGE plpgsql;
 
-select define_function_args('portal_layout__add_region','layout_id,region,immutable_p;f');
 
 
-
+select define_function_args('portal_layout__add_region','layout_id,region,immutable_p;f');
 --
 -- procedure portal_layout__add_region/3
 --
@@ -561,7 +560,6 @@
 
 
 select define_function_args('portal_datasource__new','datasource_id;null,name;null,description;null,css_dir,object_type;portal_datasource,creation_date;now(),creation_user;null,creation_ip;null,context_id;null');
-
 --
 -- procedure portal_datasource__new/9
 --
@@ -582,15 +580,17 @@
 BEGIN
 
     v_datasource_id := acs_object__new(
-        p_datasource_id,
-        p_object_type,
-        p_creation_date,
-        p_creation_user,
-        p_creation_ip,
-        p_context_id,
-        't'
-    );
-
+        p_datasource_id,    -- object_id 
+        p_object_type,      -- object_type 
+        p_creation_date,    -- creation_date 
+        p_creation_user,    -- creation_user 
+        p_creation_ip,      -- creation_ip 
+        p_context_id,       -- context_id 
+        true,               -- security_inherit_p 
+        p_name,             -- title 
+        null                -- package_id
+    );       
+    
     insert into portal_datasources
     (datasource_id, name, description, css_dir)
     values
@@ -625,14 +625,14 @@
 BEGIN
 
     v_datasource_id := portal_datasource__new(null,
-				  p_name,
-				  p_description,
+                  p_name,
+                  p_description,
                                   null,
-				  p_object_type,
-				  p_creation_date,
-				  p_creation_user,
-				  p_creation_ip,
-				  p_context_id);
+                  p_object_type,
+                  p_creation_date,
+                  p_creation_user,
+                  p_creation_ip,
+                  p_context_id);
 
     return v_datasource_id;
 
@@ -658,14 +658,14 @@
 BEGIN
 
     v_datasource_id := portal_datasource__new(null,
-				  p_name,
-				  p_description,
+                  p_name,
+                  p_description,
                                   null,
-				  'portal_datasource',
-				  now(),
-				  null,
-				  null,
-				  null);
+                  'portal_datasource',
+                  now(),
+                  null,
+                  null,
+                  null);
 
     return v_datasource_id;
 
@@ -691,24 +691,23 @@
 BEGIN
 
     v_datasource_id := portal_datasource__new(null,
-				  p_name,
-				  p_description,
+                  p_name,
+                  p_description,
                                   p_css_dir,
-				  'portal_datasource',
-				  now(),
-				  null,
-				  null,
-				  null);
+                  'portal_datasource',
+                  now(),
+                  null,
+                  null,
+                  null);
 
     return v_datasource_id;
 
 END;
 $$ LANGUAGE plpgsql;
 
-select define_function_args('portal_datasource__delete','datasource_id');
 
 
-
+select define_function_args('portal_datasource__delete','datasource_id');
 --
 -- procedure portal_datasource__delete/1
 --
@@ -722,10 +721,9 @@
 END;
 $$ LANGUAGE plpgsql;
 
-select define_function_args('portal_datasource__set_def_param','datasource_id,config_required_p,configured_p,key,value');
 
 
-
+select define_function_args('portal_datasource__set_def_param','datasource_id,config_required_p,configured_p,key,value');
 --
 -- procedure portal_datasource__set_def_param/5
 --
