Index: openacs-4/packages/workflow/sql/postgresql/workflow-procedural-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/sql/postgresql/workflow-procedural-create.sql,v
diff -u -N -r1.11 -r1.12
--- openacs-4/packages/workflow/sql/postgresql/workflow-procedural-create.sql	23 Jan 2004 11:02:27 -0000	1.11
+++ openacs-4/packages/workflow/sql/postgresql/workflow-procedural-create.sql	29 Jun 2004 10:11:53 -0000	1.12
@@ -118,7 +118,7 @@
 end;
 ' language 'plpgsql';
 
-select define_function_args ('workflow_case_log_entry__new','entry_id,content_type;workflow_case_log_entry,case_id,action_id,comment,comment_mime_type,creation_user,creation_ip');
+select define_function_args ('workflow_case_log_entry__new','entry_id,content_type;workflow_case_log_entry,case_id,action_id,comment,comment_mime_type,creation_user,creation_ip,package_id');
 
 create or replace function workflow_case_log_entry__new (
     integer,                  -- entry_id
@@ -128,7 +128,8 @@
     varchar,                  -- comment
     varchar,                  -- comment_mime_type
     integer,                  -- creation_user
-    varchar                   -- creation_ip
+    varchar,                  -- creation_ip
+    integer                   -- package_id
 ) returns integer as '
 declare
     p_item_id           alias for $1;
@@ -139,13 +140,15 @@
     p_comment_mime_type alias for $6;
     p_creation_user     alias for $7;
     p_creation_ip       alias for $8;
+    p_package_id        alias for $9;
         
     v_name                        varchar;
     v_action_short_name           varchar;
     v_action_pretty_past_tense    varchar;
     v_case_object_id              integer;
     v_item_id                     integer;
     v_revision_id                 integer;
+    v_package_id                  integer;
 begin
     select short_name, pretty_past_tense
     into   v_action_short_name, v_action_pretty_past_tense
@@ -168,6 +171,15 @@
     end if;
     v_name := v_action_short_name || '' '' || v_item_id;
 
+    -- get the package_id
+    if p_package_id is not null then
+        v_package_id := p_package_id;
+    else
+        -- this will return null if the app stores the package_id
+        -- in a package-specific table instead of acs_objects
+        v_package_id := acs_object__package_id(v_case_object_id);
+    end if;
+
     v_item_id := content_item__new (
         v_item_id,                   -- item_id
         v_name,                      -- name
@@ -184,7 +196,8 @@
         ''t'',                       -- security_inherit_p
         ''CR_FILES'',                -- storage_area_key
         ''content_item'',            -- item_subtype
-        p_content_type               -- content_type
+        p_content_type,              -- content_type
+        v_package_id                 -- package_id
     );
 
     -- insert the row into the single-column entry revision table
