Index: openacs-4/packages/contacts/tcl/contact-message-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-message-procs.tcl,v diff -u -r1.20 -r1.21 --- openacs-4/packages/contacts/tcl/contact-message-procs.tcl 31 Jan 2006 12:21:28 -0000 1.20 +++ openacs-4/packages/contacts/tcl/contact-message-procs.tcl 15 Feb 2006 10:06:36 -0000 1.21 @@ -48,13 +48,18 @@ {-locale ""} {-banner ""} {-ps ""} + {-package_id ""} } { save a contact message } { if { ![db_0or1row item_exists_p { select '1' from contact_message_items where item_id = :item_id }] } { if { [db_0or1row item_exists_p { select '1' from acs_objects where object_id = :item_id }] } { error "The item_id specified is not a contact_message_item but already exists as an acs_object. This is not a valid item_id." } + if { ![exists_and_not_null package_id] } { + set package_id [ad_conn package_id] + } + # we need to create the content item content::item::new \ -name "message.${item_id}" \ @@ -63,14 +68,23 @@ -creation_user [ad_conn user_id] \ -creation_ip [ad_conn peeraddr] \ -content_type "content_revision" \ - -storage_type "text" + -storage_type "text" \ + -package_id $package_id db_dml insert_into_message_items { insert into contact_message_items ( item_id, owner_id, message_type, locale, banner, ps ) values ( :item_id, :owner_id, :message_type, :locale, :banner, :ps ) } + # contact item new does not set the package_id in acs_object so + # we do it here + db_dml update_package_id { + update acs_objects + set package_id = :package_id + where object_id = :item_id + } + } else { db_dml update_message_item { update contact_message_items set owner_id = :owner_id, message_type = :message_type, locale = :locale, banner = :banner, ps = :ps where item_id = :item_id