Index: openacs-4/contrib/packages/simulation/lib/messages.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/messages.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/contrib/packages/simulation/lib/messages.tcl 5 Jan 2004 11:44:33 -0000 1.5 +++ openacs-4/contrib/packages/simulation/lib/messages.tcl 5 Jan 2004 15:29:50 -0000 1.6 @@ -19,6 +19,9 @@ from { label "From" } + to { + label "To" + } subject { link_url_col message_url @@ -31,50 +34,56 @@ label "Attachments" html { align center } } - sim_name { - label "Simulation" - hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} - } case_label { label "Case" hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} } + sim_name { + label "Simulation" + hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} + } } template::list::create \ -name messages \ -multirow messages \ -no_data "You don't have any messages." \ + -actions [list "Send new message" [export_vars -base message { case_id }] {}] \ -elements $elements -# TODO: make case_name be a combo of simulation name and case # db_multirow -extend { message_url creation_date_pretty } messages select_messages " select distinct sm.message_id, + cr.item_id, sm.title as subject, sc.label as case_label, w.pretty_name as sim_name, to_char(creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date_ansi, - (select p.first_names || ' ' || p.last_name - from persons p - where p.person_id = creation_user) as from, + (select fr.pretty_name + from workflow_roles fr + where fr.role_id = sm.from_role_id) as from, + (select tr.pretty_name + from workflow_roles tr + where tr.role_id = sm.to_role_id) as to, (select count(*) from cr_item_rels where item_id = item_id and relation_tag = 'attachment') as attachment_count - from sim_messagesx sm, + from sim_messagesx sm, + cr_revisions cr, workflow_case_role_party_map wcrmp, party_approved_member_map pamm, workflows w, workflow_cases wc, sim_cases sc - where pamm.member_id = :user_id - and wcrmp.party_id = pamm.party_id - and wcrmp.case_id = sm.case_id - and wc.case_id = sm.case_id - and sc.sim_case_id = wc.object_id - and w.workflow_id = wc.workflow_id - [ad_decode [exists_and_not_null case_id] 1 "and sm.case_id = :case_id" ""] + where cr.revision_id = sm.message_id + and pamm.member_id = :user_id + and wcrmp.party_id = pamm.party_id + and wcrmp.case_id = sm.case_id + and wc.case_id = sm.case_id + and sc.sim_case_id = wc.object_id + and w.workflow_id = wc.workflow_id + [ad_decode [exists_and_not_null case_id] 1 "and sm.case_id = :case_id" ""] " { - set message_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message" { message_id case_id }] + set message_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message" { item_id case_id }] set creation_date_pretty [lc_time_fmt $creation_date_ansi "%x %X"] } Index: openacs-4/contrib/packages/simulation/lib/tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/tasks.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/simulation/lib/tasks.tcl 5 Jan 2004 11:44:33 -0000 1.6 +++ openacs-4/contrib/packages/simulation/lib/tasks.tcl 5 Jan 2004 15:29:50 -0000 1.7 @@ -24,14 +24,14 @@ link_url_col task_url label "Task" } - sim_name { - label "Simulation" - hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} - } case_label { label "Case" hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} } + sim_name { + label "Simulation" + hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} + } } template::list::create \ Index: openacs-4/contrib/packages/simulation/tcl/message-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/message-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/tcl/message-procs.tcl 5 Jan 2004 15:29:51 -0000 1.1 @@ -0,0 +1,64 @@ +ad_library { + Procs to handle sim_messages +} + +namespace eval simulation {} +namespace eval simulation::message {} + + +ad_proc -public simulation::message::new { + -from_role_id:required + -to_role_id:required + -case_id:required + -subject:required + {-body {}} + {-body_mime_type "text/plain"} + {-item_id {}} + {-parent_id {}} + {-content_type "sim_message"} + {-item_name ""} +} { + Create new simulation message. + + @return item_id of the new message +} { + db_transaction { + + if { [empty_string_p $parent_id] } { + set parent_id [bcms::folder::get_id_by_package_id -parent_id 0] + } + + if { [empty_string_p $item_id] } { + set item_id [db_nextval "acs_object_id_seq"] + } + + if { [empty_string_p $item_name] } { + set item_name "message_$item_id" + } + + set item_id [bcms::item::create_item \ + -item_id $item_id \ + -item_name $item_name \ + -parent_id $parent_id \ + -content_type $content_type] + + set attributes [list \ + [list from_role_id $from_role_id] \ + [list to_role_id $to_role_id] \ + [list case_id $case_id]] + + set revision_id [bcms::revision::add_revision \ + -item_id $item_id \ + -title $subject \ + -content_type "sim_message" \ + -mime_type $body_mime_type \ + -content $body \ + -additional_properties $attributes] + + bcms::revision::set_revision_status \ + -revision_id $revision_id \ + -status "live" + } + + return $item_id +} Index: openacs-4/contrib/packages/simulation/www/simplay/document-upload.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/document-upload.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/simplay/document-upload.tcl 5 Jan 2004 12:33:41 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/simplay/document-upload.tcl 5 Jan 2004 15:29:51 -0000 1.3 @@ -12,9 +12,6 @@ set workflow_id [workflow::case::get_element -case_id $case_id -element workflow_id] -# TODO: Only pick from roles the current user is playing in this case -# TODO: If only one role, hide the role select widget - set role_options [list] foreach role_id [workflow::case::get_user_roles -case_id $case_id] { lappend role_options [list [workflow::role::get_element -role_id $role_id -element pretty_name] $role_id] Index: openacs-4/contrib/packages/simulation/www/simplay/message.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/message.adp,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/simplay/message.adp 18 Dec 2003 15:39:03 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/simplay/message.adp 5 Jan 2004 15:29:51 -0000 1.2 @@ -1,20 +1,15 @@ @page_title;noquote@ @context;noquote@ + @focus;noquote@ -

TODO: this page is for composing new messages and for reading messages. + + +

Form:

- \ No newline at end of file + Index: openacs-4/contrib/packages/simulation/www/simplay/message.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/message.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/simulation/www/simplay/message.tcl 5 Jan 2004 12:33:41 -0000 1.4 +++ openacs-4/contrib/packages/simulation/www/simplay/message.tcl 5 Jan 2004 15:29:51 -0000 1.5 @@ -1,13 +1,143 @@ ad_page_contract { Create or edit a message. } { + item_id:optional case_id:optional - recipient_id:optional + sender_role_id:optional + recipient_role_id:optional + subject:optional + body_text:optional + body_mime_type:optional } -# TODO: task recipient_id as an optional input parameter - set page_title "Message" set context [list [list "." "SimPlay"] [list $page_title] ] set package_id [ad_conn package_id] +set workflow_id [workflow::case::get_element -case_id $case_id -element workflow_id] + +set from_role_options [list] +foreach role_id [workflow::case::get_user_roles -case_id $case_id] { + lappend from_role_options [list [workflow::role::get_element -role_id $role_id -element pretty_name] $role_id] +} + +set to_role_options [list] +foreach role_id [workflow::role::get_ids -workflow_id $workflow_id] { + lappend to_role_options [list [workflow::role::get_element -role_id $role_id -element pretty_name] $role_id] +} + +set action [form::get_action message] + +if { [string equal $action "reply"] } { + + item::get_content \ + -item_id $item_id \ + -array content + + set recipient_role_id $content(from_role_id) + set sender_role_id $content(to_role_id) + set subject "Re: $content(title)" + set body_text " + + +-----Original Message----- +From: [workflow::role::get_element -role_id $content(from_role_id) -element pretty_name] +Sent: [lc_time_fmt $content(creation_date) "%x %X"] +To: [workflow::role::get_element -role_id $content(to_role_id) -element pretty_name] +Subject: $content(title) + +[ad_html_text_convert -from $content(mime_type) -to "text/plain" $content(text)]" + set body_mime_type "text/plain" + + ad_returnredirect [export_vars -base [ad_conn url] { case_id sender_role_id recipient_role_id subject body_text body_mime_type }] +} + +ad_form \ + -name message \ + -edit_buttons { { Send ok } } \ + -actions { { Reply reply } } \ + -export { case_id } \ + -mode [ad_decode [ad_form_new_p -key item_id] 1 "edit" "display"] \ + -form { + {item_id:key} + {sender_role_id:text(select) + {label "From"} + {options $from_role_options} + } + } + +if { [llength $from_role_options] > 1 } { + set focus "message.sender_role_id" +} else { + set sender_role_id [lindex [lindex $from_role_options 0] 1] + set focus "message.recipient_role_id" +} + + +ad_form -extend -name message -form { + {recipient_role_id:integer(checkbox),multiple + {label "To"} + {options $to_role_options} + } + {subject:text + {label "Subject"} + {html {size 80}} + } + {body:richtext + {label "Body"} + {html {cols 60 rows 20}} + } + {attachments:text(inform) + {label "Attachments"} + {value "TODO"} + } +} -on_request { + if { [llength $from_role_options] == 1 } { + set sender_role_id [lindex [lindex $from_role_options 0] 1] + element set_properties message mode display + } +} -new_request { + if { [info exists body_text] } { + if { ![info exists body_mime_type] } { + set body_mime_type "text/enhanced" + } + set body [template::util::richtext::create $body_text $body_mime_type] + set focus "message.body" + } +} -edit_request { + + item::get_content \ + -item_id $item_id \ + -array content + + # Don't show checkboxes, just show the current role + element set_properties message recipient_role_id -widget select + + set sender_role_id $content(from_role_id) + set recipient_role_id $content(to_role_id) + set subject $content(title) + set body [template::util::richtext::create $content(text) $content(mime_type)] +} -on_submit { + + set body_text [template::util::richtext::get_property "contents" $body] + set body_mime_type [template::util::richtext::get_property "format" $body] + + db_transaction { + + set parent_id [bcms::folder::get_id_by_package_id -parent_id 0] + + foreach to_role_id $recipient_role_id { + simulation::message::new \ + -item_id $item_id \ + -from_role_id $sender_role_id \ + -to_role_id $to_role_id \ + -case_id $case_id \ + -subject $subject \ + -body $body_text \ + -body_mime_type $body_mime_type + } + } + + ad_returnredirect [export_vars -base case { case_id }] + ad_script_abort +} Index: openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/task-detail.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl 19 Dec 2003 14:52:21 -0000 1.6 +++ openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl 5 Jan 2004 15:29:51 -0000 1.7 @@ -4,8 +4,6 @@ enabled_action_id:integer } -# TODO: Get case_id from action - workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action set case_id $enabled_action(case_id) @@ -86,33 +84,14 @@ -comment $body_text \ -comment_mime_type $body_mime_type - # Send message - - set to_role_id $action(recipient) - set from_role_id $action(assigned_role_id) - - set parent_id [bcms::folder::get_id_by_package_id -parent_id 0] - - set item_id [db_nextval "acs_object_id_seq"] - - set item_id [bcms::item::create_item \ - -item_id $item_id \ - -item_name "message_$item_id" \ - -parent_id $parent_id \ - -content_type "sim_message"] - - set attributes [list \ - [list from_role_id $from_role_id] \ - [list to_role_id $to_role_id] \ - [list case_id $case_id]] - - set revision_id [bcms::revision::add_revision \ - -item_id $item_id \ - -title $subject \ - -content_type "sim_message" \ - -mime_type $body_mime_type \ - -content $body_text \ - -additional_properties $attributes] + simulation::message::new \ + -item_id $item_id \ + -from_role_id $action(assigned_role_id) \ + -to_role_id $action(recipient) \ + -case_id $case_id \ + -subject $subject \ + -body $body_text \ + -body_mime_type $body_mime_type } ad_returnredirect [export_vars -base tasks { case_id }] Index: openacs-4/packages/simulation/lib/messages.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/messages.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/simulation/lib/messages.tcl 5 Jan 2004 11:44:33 -0000 1.5 +++ openacs-4/packages/simulation/lib/messages.tcl 5 Jan 2004 15:29:50 -0000 1.6 @@ -19,6 +19,9 @@ from { label "From" } + to { + label "To" + } subject { link_url_col message_url @@ -31,50 +34,56 @@ label "Attachments" html { align center } } - sim_name { - label "Simulation" - hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} - } case_label { label "Case" hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} } + sim_name { + label "Simulation" + hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} + } } template::list::create \ -name messages \ -multirow messages \ -no_data "You don't have any messages." \ + -actions [list "Send new message" [export_vars -base message { case_id }] {}] \ -elements $elements -# TODO: make case_name be a combo of simulation name and case # db_multirow -extend { message_url creation_date_pretty } messages select_messages " select distinct sm.message_id, + cr.item_id, sm.title as subject, sc.label as case_label, w.pretty_name as sim_name, to_char(creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date_ansi, - (select p.first_names || ' ' || p.last_name - from persons p - where p.person_id = creation_user) as from, + (select fr.pretty_name + from workflow_roles fr + where fr.role_id = sm.from_role_id) as from, + (select tr.pretty_name + from workflow_roles tr + where tr.role_id = sm.to_role_id) as to, (select count(*) from cr_item_rels where item_id = item_id and relation_tag = 'attachment') as attachment_count - from sim_messagesx sm, + from sim_messagesx sm, + cr_revisions cr, workflow_case_role_party_map wcrmp, party_approved_member_map pamm, workflows w, workflow_cases wc, sim_cases sc - where pamm.member_id = :user_id - and wcrmp.party_id = pamm.party_id - and wcrmp.case_id = sm.case_id - and wc.case_id = sm.case_id - and sc.sim_case_id = wc.object_id - and w.workflow_id = wc.workflow_id - [ad_decode [exists_and_not_null case_id] 1 "and sm.case_id = :case_id" ""] + where cr.revision_id = sm.message_id + and pamm.member_id = :user_id + and wcrmp.party_id = pamm.party_id + and wcrmp.case_id = sm.case_id + and wc.case_id = sm.case_id + and sc.sim_case_id = wc.object_id + and w.workflow_id = wc.workflow_id + [ad_decode [exists_and_not_null case_id] 1 "and sm.case_id = :case_id" ""] " { - set message_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message" { message_id case_id }] + set message_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message" { item_id case_id }] set creation_date_pretty [lc_time_fmt $creation_date_ansi "%x %X"] } Index: openacs-4/packages/simulation/lib/tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/tasks.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/simulation/lib/tasks.tcl 5 Jan 2004 11:44:33 -0000 1.6 +++ openacs-4/packages/simulation/lib/tasks.tcl 5 Jan 2004 15:29:50 -0000 1.7 @@ -24,14 +24,14 @@ link_url_col task_url label "Task" } - sim_name { - label "Simulation" - hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} - } case_label { label "Case" hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} } + sim_name { + label "Simulation" + hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} + } } template::list::create \ Index: openacs-4/packages/simulation/tcl/message-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/message-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/tcl/message-procs.tcl 5 Jan 2004 15:29:51 -0000 1.1 @@ -0,0 +1,64 @@ +ad_library { + Procs to handle sim_messages +} + +namespace eval simulation {} +namespace eval simulation::message {} + + +ad_proc -public simulation::message::new { + -from_role_id:required + -to_role_id:required + -case_id:required + -subject:required + {-body {}} + {-body_mime_type "text/plain"} + {-item_id {}} + {-parent_id {}} + {-content_type "sim_message"} + {-item_name ""} +} { + Create new simulation message. + + @return item_id of the new message +} { + db_transaction { + + if { [empty_string_p $parent_id] } { + set parent_id [bcms::folder::get_id_by_package_id -parent_id 0] + } + + if { [empty_string_p $item_id] } { + set item_id [db_nextval "acs_object_id_seq"] + } + + if { [empty_string_p $item_name] } { + set item_name "message_$item_id" + } + + set item_id [bcms::item::create_item \ + -item_id $item_id \ + -item_name $item_name \ + -parent_id $parent_id \ + -content_type $content_type] + + set attributes [list \ + [list from_role_id $from_role_id] \ + [list to_role_id $to_role_id] \ + [list case_id $case_id]] + + set revision_id [bcms::revision::add_revision \ + -item_id $item_id \ + -title $subject \ + -content_type "sim_message" \ + -mime_type $body_mime_type \ + -content $body \ + -additional_properties $attributes] + + bcms::revision::set_revision_status \ + -revision_id $revision_id \ + -status "live" + } + + return $item_id +} Index: openacs-4/packages/simulation/www/simplay/document-upload.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/document-upload.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/www/simplay/document-upload.tcl 5 Jan 2004 12:33:41 -0000 1.2 +++ openacs-4/packages/simulation/www/simplay/document-upload.tcl 5 Jan 2004 15:29:51 -0000 1.3 @@ -12,9 +12,6 @@ set workflow_id [workflow::case::get_element -case_id $case_id -element workflow_id] -# TODO: Only pick from roles the current user is playing in this case -# TODO: If only one role, hide the role select widget - set role_options [list] foreach role_id [workflow::case::get_user_roles -case_id $case_id] { lappend role_options [list [workflow::role::get_element -role_id $role_id -element pretty_name] $role_id] Index: openacs-4/packages/simulation/www/simplay/message.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/message.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/www/simplay/message.adp 18 Dec 2003 15:39:03 -0000 1.1 +++ openacs-4/packages/simulation/www/simplay/message.adp 5 Jan 2004 15:29:51 -0000 1.2 @@ -1,20 +1,15 @@ @page_title;noquote@ @context;noquote@ + @focus;noquote@ -

TODO: this page is for composing new messages and for reading messages. + + +

Form:

- \ No newline at end of file + Index: openacs-4/packages/simulation/www/simplay/message.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/message.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/simulation/www/simplay/message.tcl 5 Jan 2004 12:33:41 -0000 1.4 +++ openacs-4/packages/simulation/www/simplay/message.tcl 5 Jan 2004 15:29:51 -0000 1.5 @@ -1,13 +1,143 @@ ad_page_contract { Create or edit a message. } { + item_id:optional case_id:optional - recipient_id:optional + sender_role_id:optional + recipient_role_id:optional + subject:optional + body_text:optional + body_mime_type:optional } -# TODO: task recipient_id as an optional input parameter - set page_title "Message" set context [list [list "." "SimPlay"] [list $page_title] ] set package_id [ad_conn package_id] +set workflow_id [workflow::case::get_element -case_id $case_id -element workflow_id] + +set from_role_options [list] +foreach role_id [workflow::case::get_user_roles -case_id $case_id] { + lappend from_role_options [list [workflow::role::get_element -role_id $role_id -element pretty_name] $role_id] +} + +set to_role_options [list] +foreach role_id [workflow::role::get_ids -workflow_id $workflow_id] { + lappend to_role_options [list [workflow::role::get_element -role_id $role_id -element pretty_name] $role_id] +} + +set action [form::get_action message] + +if { [string equal $action "reply"] } { + + item::get_content \ + -item_id $item_id \ + -array content + + set recipient_role_id $content(from_role_id) + set sender_role_id $content(to_role_id) + set subject "Re: $content(title)" + set body_text " + + +-----Original Message----- +From: [workflow::role::get_element -role_id $content(from_role_id) -element pretty_name] +Sent: [lc_time_fmt $content(creation_date) "%x %X"] +To: [workflow::role::get_element -role_id $content(to_role_id) -element pretty_name] +Subject: $content(title) + +[ad_html_text_convert -from $content(mime_type) -to "text/plain" $content(text)]" + set body_mime_type "text/plain" + + ad_returnredirect [export_vars -base [ad_conn url] { case_id sender_role_id recipient_role_id subject body_text body_mime_type }] +} + +ad_form \ + -name message \ + -edit_buttons { { Send ok } } \ + -actions { { Reply reply } } \ + -export { case_id } \ + -mode [ad_decode [ad_form_new_p -key item_id] 1 "edit" "display"] \ + -form { + {item_id:key} + {sender_role_id:text(select) + {label "From"} + {options $from_role_options} + } + } + +if { [llength $from_role_options] > 1 } { + set focus "message.sender_role_id" +} else { + set sender_role_id [lindex [lindex $from_role_options 0] 1] + set focus "message.recipient_role_id" +} + + +ad_form -extend -name message -form { + {recipient_role_id:integer(checkbox),multiple + {label "To"} + {options $to_role_options} + } + {subject:text + {label "Subject"} + {html {size 80}} + } + {body:richtext + {label "Body"} + {html {cols 60 rows 20}} + } + {attachments:text(inform) + {label "Attachments"} + {value "TODO"} + } +} -on_request { + if { [llength $from_role_options] == 1 } { + set sender_role_id [lindex [lindex $from_role_options 0] 1] + element set_properties message mode display + } +} -new_request { + if { [info exists body_text] } { + if { ![info exists body_mime_type] } { + set body_mime_type "text/enhanced" + } + set body [template::util::richtext::create $body_text $body_mime_type] + set focus "message.body" + } +} -edit_request { + + item::get_content \ + -item_id $item_id \ + -array content + + # Don't show checkboxes, just show the current role + element set_properties message recipient_role_id -widget select + + set sender_role_id $content(from_role_id) + set recipient_role_id $content(to_role_id) + set subject $content(title) + set body [template::util::richtext::create $content(text) $content(mime_type)] +} -on_submit { + + set body_text [template::util::richtext::get_property "contents" $body] + set body_mime_type [template::util::richtext::get_property "format" $body] + + db_transaction { + + set parent_id [bcms::folder::get_id_by_package_id -parent_id 0] + + foreach to_role_id $recipient_role_id { + simulation::message::new \ + -item_id $item_id \ + -from_role_id $sender_role_id \ + -to_role_id $to_role_id \ + -case_id $case_id \ + -subject $subject \ + -body $body_text \ + -body_mime_type $body_mime_type + } + } + + ad_returnredirect [export_vars -base case { case_id }] + ad_script_abort +} Index: openacs-4/packages/simulation/www/simplay/task-detail.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/task-detail.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/simulation/www/simplay/task-detail.tcl 19 Dec 2003 14:52:21 -0000 1.6 +++ openacs-4/packages/simulation/www/simplay/task-detail.tcl 5 Jan 2004 15:29:51 -0000 1.7 @@ -4,8 +4,6 @@ enabled_action_id:integer } -# TODO: Get case_id from action - workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action set case_id $enabled_action(case_id) @@ -86,33 +84,14 @@ -comment $body_text \ -comment_mime_type $body_mime_type - # Send message - - set to_role_id $action(recipient) - set from_role_id $action(assigned_role_id) - - set parent_id [bcms::folder::get_id_by_package_id -parent_id 0] - - set item_id [db_nextval "acs_object_id_seq"] - - set item_id [bcms::item::create_item \ - -item_id $item_id \ - -item_name "message_$item_id" \ - -parent_id $parent_id \ - -content_type "sim_message"] - - set attributes [list \ - [list from_role_id $from_role_id] \ - [list to_role_id $to_role_id] \ - [list case_id $case_id]] - - set revision_id [bcms::revision::add_revision \ - -item_id $item_id \ - -title $subject \ - -content_type "sim_message" \ - -mime_type $body_mime_type \ - -content $body_text \ - -additional_properties $attributes] + simulation::message::new \ + -item_id $item_id \ + -from_role_id $action(assigned_role_id) \ + -to_role_id $action(recipient) \ + -case_id $case_id \ + -subject $subject \ + -body $body_text \ + -body_mime_type $body_mime_type } ad_returnredirect [export_vars -base tasks { case_id }]