Index: openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-functions-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/sql/postgresql/Attic/project-manager-functions-create.sql,v
diff -u -r1.13 -r1.13.2.1
--- openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-functions-create.sql	12 Mar 2004 13:44:42 -0000	1.13
+++ openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-functions-create.sql	20 May 2004 17:30:02 -0000	1.13.2.1
@@ -19,9 +19,13 @@
 returns varchar as '
 declare
     p_pm_project_id      alias for $1;
-    v_pm_project_name    varchar;
+<<<<<<< project-manager-functions-create.sql
+    v_pm_project_name    pm_projects.project_name%TYPE;
+=======
+    v_pm_project_name    pm_projectsx.name%TYPE;
+>>>>>>> 1.16
 begin
-        select project_name || ''_'' || p_pm_project_id into v_pm_project_name
+        select name || ''_'' || p_pm_project_id into v_pm_project_name
                 from pm_projectsx
                 where item_id = p_pm_project_id;
     return v_pm_project_name;
@@ -33,7 +37,7 @@
 
 select define_function_args('pm_project__new_root_folder', 'package_id');
 
-create function pm_project__new_root_folder (integer)
+create or replace function pm_project__new_root_folder (integer)
 returns integer as '
 declare
         p_package_id            alias for $1;
@@ -51,7 +55,7 @@
             v_folder_name,                              -- name
             ''Projects'',                               -- label
             ''Project Repository'',                     -- description
-            null                                        -- parent_id
+            p_package_id                                -- parent_id
         );
 
         -- Register the standard content types
@@ -80,7 +84,7 @@
 
 select define_function_args('pm_project__get_root_folder', 'package_id,create_if_not_present_p');
 
-create function pm_project__get_root_folder (integer, boolean)
+create or replace function pm_project__get_root_folder (integer, boolean)
 returns integer as '
 declare
         p_package_id            alias for $1;
@@ -130,14 +134,15 @@
 -- is null.  Otherwise a project folder will be created as a sub-folder
 -- of an existing project folder.
 
-select define_function_args('pm_project__new_project_item', 'project_name, project_code, parent_id, goal, description, planned_start_date, planned_end_date, actual_start_date, actual_end_date, logger_project, ongoing_p, status_id, customer_id, creation_date, creation_user, creation_ip, package_id');
+select define_function_args('pm_project__new_project_item', 'project_name, project_code, parent_id, goal, description, mime_type, planned_start_date, planned_end_date, actual_start_date, actual_end_date, logger_project, ongoing_p, status_id, customer_id, creation_date, creation_user, creation_ip, package_id');
 
 create or replace function pm_project__new_project_item (
         varchar,        -- project_name
         varchar,        -- project_code
         integer,        -- parent_id
         varchar,        -- goal
         varchar,        -- description
+        varchar,        -- mime_type
         timestamptz,    -- planned_start_date
         timestamptz,    -- planned_end_date
         timestamptz,    -- actual_start_date
@@ -158,18 +163,19 @@
         p_parent_id                             alias for $3;
         p_goal                                  alias for $4;
         p_description                           alias for $5;
-        p_planned_start_date                    alias for $6;
-        p_planned_end_date                      alias for $7;
-        p_actual_start_date                     alias for $8;
-        p_actual_end_date                       alias for $9;
-        p_logger_project                        alias for $10;
-        p_ongoing_p                             alias for $11;
-        p_status_id                             alias for $12;
-        p_customer_id                           alias for $13;
-        p_creation_date                         alias for $14;
-        p_creation_user                         alias for $15;
-        p_creation_ip                           alias for $16;
-        p_package_id                            alias for $17;
+        p_mime_type                             alias for $6;
+        p_planned_start_date                    alias for $7;
+        p_planned_end_date                      alias for $8;
+        p_actual_start_date                     alias for $9;
+        p_actual_end_date                       alias for $10;
+        p_logger_project                        alias for $11;
+        p_ongoing_p                             alias for $12;
+        p_status_id                             alias for $13;
+        p_customer_id                           alias for $14;
+        p_creation_date                         alias for $15;
+        p_creation_user                         alias for $16;
+        p_creation_ip                           alias for $17;
+        p_package_id                            alias for $18;
 
         v_item_id               cr_items.item_id%TYPE;
         v_revision_id           cr_revisions.revision_id%TYPE;
@@ -202,7 +208,7 @@
                 ''pm_project'',         -- content_type
                 p_project_name,         -- title
                 p_description,          -- description
-                ''text/plain'',         -- mime_type
+                p_mime_type,            -- mime_type
                 null,                   -- nls_language
                 null                    -- data
         );
@@ -211,7 +217,7 @@
                 p_project_name,         -- title
                 p_description,          -- description
                 now(),                  -- publish_date
-                ''text/plain'',         -- mime_type
+                p_mime_type,            -- mime_type
                 NULL,                   -- nls_language
                 NULL,                   -- data
                 v_item_id,              -- item_id
@@ -283,7 +289,7 @@
 
 select define_function_args('pm_project__new_project_revision', 'item_id, project_name, project_code, parent_id, goal, description, planned_start_date, planned_end_date, actual_start_date, actual_end_date, logger_project, ongoing_p, status_id, organization_id, creation_date, creation_user, creation_ip, package_id');
 
-create function pm_project__new_project_revision (
+create or replace function pm_project__new_project_revision (
         integer,        -- item_id
         varchar,        -- project_name
         varchar,        -- project_code
@@ -373,7 +379,7 @@
 
 select define_function_args('pm_project__new_unique_name', 'package_id');
 
-create function pm_project__new_unique_name (integer)
+create or replace function pm_project__new_unique_name (integer)
 returns text as '
 declare
         p_package_id            alias for $1;
@@ -427,12 +433,13 @@
 -- If it is not associated with a project, then it is placed in the root
 -- project repository folder.
 
-select define_function_args('pm_task__new_task_item', 'project_id, title, description, end_date, percent_complete, estimated_hours_work, estimated_hours_work_min, estimated_hours_work_max, status_id, creation_date, creation_user, creation_ip, package_id');
+select define_function_args('pm_task__new_task_item', 'project_id, title, description, html_p, end_date, percent_complete, estimated_hours_work, estimated_hours_work_min, estimated_hours_work_max, status_id, creation_date, creation_user, creation_ip, package_id');
 
-create function pm_task__new_task_item (
+create or replace function pm_task__new_task_item (
         integer,        -- project_id
         varchar,        -- title
         varchar,        -- description
+        varchar,        -- html_p
         timestamptz,    -- end_date
         numeric,        -- percent_complete
         numeric,        -- estimated_hours_work
@@ -449,16 +456,17 @@
         p_project_id                            alias for $1;
         p_title                                 alias for $2;
         p_description                           alias for $3;
-        p_end_date                              alias for $4;
-        p_percent_complete                      alias for $5;
-        p_estimated_hours_work                  alias for $6;
-        p_estimated_hours_work_min              alias for $7;
-        p_estimated_hours_work_max              alias for $8;
-        p_status_id                             alias for $9;
-        p_creation_date                         alias for $10;
-        p_creation_user                         alias for $11;
-        p_creation_ip                           alias for $12;
-        p_package_id                            alias for $13;
+        p_mime_type                             alias for $4;
+        p_end_date                              alias for $5;
+        p_percent_complete                      alias for $6;
+        p_estimated_hours_work                  alias for $7;
+        p_estimated_hours_work_min              alias for $8;
+        p_estimated_hours_work_max              alias for $9;
+        p_status_id                             alias for $10;
+        p_creation_date                         alias for $11;
+        p_creation_user                         alias for $12;
+        p_creation_ip                           alias for $13;
+        p_package_id                            alias for $14;
 
         v_item_id               cr_items.item_id%TYPE;
         v_revision_id           cr_revisions.revision_id%TYPE;
@@ -484,7 +492,7 @@
                 ''pm_task'',            -- content_type
                 p_title,                -- title
                 p_description,          -- description
-                ''text/plain'',         -- mime_type
+                p_mime_type,            -- mime_type
                 null,                   -- nls_language
                 null                    -- data
         );
@@ -493,7 +501,7 @@
                 p_title,                -- title
                 p_description,          -- description
                 now(),                  -- publish_date
-                ''text/plain'',         -- mime_type
+                p_mime_type,            -- mime_type
                 NULL,                   -- nls_language
                 NULL,                   -- data
                 v_item_id,              -- item_id
@@ -525,13 +533,14 @@
 end;' language 'plpgsql';
 
 
-select define_function_args('pm_task__new_task_revision', 'task_id, project_id, title, description, end_date, percent_complete, estimated_hours_work, estimated_hours_work_min, estimated_hours_work_max, actual_hours_worked, creation_date, creation_user, creation_ip, package_id');
+select define_function_args('pm_task__new_task_revision', 'task_id, project_id, title, description, mime_type, end_date, percent_complete, estimated_hours_work, estimated_hours_work_min, estimated_hours_work_max, actual_hours_worked, creation_date, creation_user, creation_ip, package_id');
 
-create function pm_task__new_task_revision (
+create or replace function pm_task__new_task_revision (
         integer,        -- task_id (the item_id)
         integer,        -- project_id
         varchar,        -- title
         varchar,        -- description
+        varchar,        -- mime_type
         timestamptz,    -- end_date
         numeric,        -- percent_complete
         numeric,        -- estimated_hours_work
@@ -550,30 +559,31 @@
         p_project_id                            alias for $2;
         p_title                                 alias for $3;
         p_description                           alias for $4;
-        p_end_date                              alias for $5;
-        p_percent_complete                      alias for $6;
-        p_estimated_hours_work                  alias for $7;
-        p_estimated_hours_work_min              alias for $8;
-        p_estimated_hours_work_max              alias for $9;
-        p_actual_hours_worked                   alias for $10;
-        p_status_id                             alias for $11;
-        p_creation_date                         alias for $12;
-        p_creation_user                         alias for $13;
-        p_creation_ip                           alias for $14;
-        p_package_id                            alias for $15;
-
+        p_mime_type                             alias for $5;
+        p_end_date                              alias for $6;
+        p_percent_complete                      alias for $7;
+        p_estimated_hours_work                  alias for $8;
+        p_estimated_hours_work_min              alias for $9;
+        p_estimated_hours_work_max              alias for $10;
+        p_actual_hours_worked                   alias for $11;
+        p_status_id                             alias for $12;
+        p_creation_date                         alias for $13;
+        p_creation_user                         alias for $14;
+        p_creation_ip                           alias for $15;
+        p_package_id                            alias for $16;
         v_revision_id           cr_revisions.revision_id%TYPE;
         v_id                    cr_items.item_id%TYPE;
 begin
         select acs_object_id_seq.nextval into v_id from dual;
 
         -- We want to put the task under the project item
+        update cr_items set parent_id = p_project_id where item_id = p_task_id;
 
         v_revision_id := content_revision__new (
                 p_title,                -- title
                 p_description,          -- description
                 now(),                  -- publish_date
-                ''text/plain'',         -- mime_type
+                p_mime_type,            -- mime_type
                 NULL,                   -- nls_language
                 NULL,                   -- data
                 p_task_id,              -- item_id
