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.8 -r1.9 --- openacs-4/contrib/packages/simulation/lib/messages.tcl 5 Jan 2004 16:31:59 -0000 1.8 +++ openacs-4/contrib/packages/simulation/lib/messages.tcl 5 Jan 2004 17:05:07 -0000 1.9 @@ -15,7 +15,11 @@ set package_id [ad_conn package_id] -set user_roles [workflow::case::get_user_roles -case_id $case_id] +if { [exists_and_not_null case_id] } { + set user_roles [workflow::case::get_user_roles -case_id $case_id] +} else { + set user_roles [list] +} set elements { from { 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 -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/tcl/message-procs.tcl 5 Jan 2004 15:29:51 -0000 1.1 +++ openacs-4/contrib/packages/simulation/tcl/message-procs.tcl 5 Jan 2004 17:05:07 -0000 1.2 @@ -17,6 +17,7 @@ {-parent_id {}} {-content_type "sim_message"} {-item_name ""} + {-attachments ""} } { Create new simulation message. @@ -58,6 +59,15 @@ bcms::revision::set_revision_status \ -revision_id $revision_id \ -status "live" + + + foreach attachment_id $attachments { + bcms::item::relate_item \ + -relation_tag "attachment" \ + -item_id $item_id \ + -related_object_id $attachment_id + } + } return $item_id Index: openacs-4/contrib/packages/simulation/test/demo-data-setup.test =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/test/Attic/demo-data-setup.test,v diff -u -r1.10 -r1.11 --- openacs-4/contrib/packages/simulation/test/demo-data-setup.test 5 Jan 2004 12:17:13 -0000 1.10 +++ openacs-4/contrib/packages/simulation/test/demo-data-setup.test 5 Jan 2004 17:05:07 -0000 1.11 @@ -128,7 +128,7 @@ ::twt::log_section "Create simulation template" do_request /simulation/simbuild/template-edit set template_name "Elementary Private Law" - field fill $template_name ~n name + field fill $template_name ~n pretty_name field find ~n template_ready_p field fill t form submit 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.3 -r1.4 --- openacs-4/contrib/packages/simulation/www/simplay/message.adp 5 Jan 2004 15:35:40 -0000 1.3 +++ openacs-4/contrib/packages/simulation/www/simplay/message.adp 5 Jan 2004 17:05:07 -0000 1.4 @@ -2,15 +2,17 @@ @page_title;noquote@ @context;noquote@ @focus;noquote@ + + + - - -

Form: -

- -TODO: On-refresh on "From" field; changes the "To" field to exclude the "From" role (you can't send to yourself), and changes the list of possible attachments (see above note) 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.8 -r1.9 --- openacs-4/contrib/packages/simulation/www/simplay/message.tcl 5 Jan 2004 16:10:37 -0000 1.8 +++ openacs-4/contrib/packages/simulation/www/simplay/message.tcl 5 Jan 2004 17:05:07 -0000 1.9 @@ -4,7 +4,7 @@ item_id:optional case_id:optional sender_role_id:optional - recipient_role_id:optional + recipient_role_id:optional,multiple subject:optional body_text:optional body_mime_type:optional @@ -20,6 +20,10 @@ 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] } +# First sender role selected by default +if { ![exists_and_not_null sender_role_id] } { + set sender_role_id [lindex [lindex $from_role_options 0] 1] +} set all_role_options [list] foreach role_id [workflow::role::get_ids -workflow_id $workflow_id] { @@ -28,9 +32,25 @@ 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] + # A role cannot send message to himself + if { ![exists_and_equal sender_role_id $role_id] } { + lappend to_role_options [list [workflow::role::get_element -role_id $role_id -element pretty_name] $role_id] + } } +set attachment_options [db_list_of_lists attachment_for_role { + select cr.title as document_title, + scrom.object_id as document_id + from sim_case_role_object_map scrom, + cr_items ci, + cr_revisions cr + where scrom.case_id = :case_id + and scrom.role_id = :sender_role_id + and scrom.object_id = ci.item_id + and ci.live_revision = cr.revision_id + order by scrom.order_n +}] + set action [form::get_action message] @@ -65,9 +85,9 @@ -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"} + {html {onChange "javascript:FormRefresh('message');"}} {options $all_role_options} } } @@ -93,9 +113,9 @@ {label "Body"} {html {cols 60 rows 20}} } - {attachments:text(inform) + {attachments:integer(checkbox),multiple,optional {label "Attachments"} - {value "TODO"} + {options $attachment_options} } } -new_request { if { [info exists body_text] } { @@ -136,17 +156,16 @@ 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 + -body_mime_type $body_mime_type \ + -attachments $attachments } } ad_returnredirect [export_vars -base case { case_id }] ad_script_abort } - Index: openacs-4/contrib/packages/simulation/www/simplay/play-master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/play-master.adp,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/simulation/www/simplay/play-master.adp 5 Jan 2004 12:33:41 -0000 1.4 +++ openacs-4/contrib/packages/simulation/www/simplay/play-master.adp 5 Jan 2004 17:05:07 -0000 1.5 @@ -1,6 +1,7 @@ @title;noquote@ @context;noquote@ + @header_stuff;noquote@ @focus;noquote@ Index: openacs-4/contrib/packages/simulation/www/simplay/play-master.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/play-master.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/simplay/play-master.tcl 19 Dec 2003 14:22:53 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/simplay/play-master.tcl 5 Jan 2004 17:05:07 -0000 1.3 @@ -4,3 +4,7 @@ if { ![exists_and_not_null case_id] } { set case_id [ns_queryget case_id] } + +if { [template::util::is_nil header_stuff] } { + set header_stuff "" +} Index: openacs-4/packages/simulation/lib/messages.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/messages.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/simulation/lib/messages.tcl 5 Jan 2004 16:31:59 -0000 1.8 +++ openacs-4/packages/simulation/lib/messages.tcl 5 Jan 2004 17:05:07 -0000 1.9 @@ -15,7 +15,11 @@ set package_id [ad_conn package_id] -set user_roles [workflow::case::get_user_roles -case_id $case_id] +if { [exists_and_not_null case_id] } { + set user_roles [workflow::case::get_user_roles -case_id $case_id] +} else { + set user_roles [list] +} set elements { from { 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 -r1.1 -r1.2 --- openacs-4/packages/simulation/tcl/message-procs.tcl 5 Jan 2004 15:29:51 -0000 1.1 +++ openacs-4/packages/simulation/tcl/message-procs.tcl 5 Jan 2004 17:05:07 -0000 1.2 @@ -17,6 +17,7 @@ {-parent_id {}} {-content_type "sim_message"} {-item_name ""} + {-attachments ""} } { Create new simulation message. @@ -58,6 +59,15 @@ bcms::revision::set_revision_status \ -revision_id $revision_id \ -status "live" + + + foreach attachment_id $attachments { + bcms::item::relate_item \ + -relation_tag "attachment" \ + -item_id $item_id \ + -related_object_id $attachment_id + } + } return $item_id Index: openacs-4/packages/simulation/test/demo-data-setup.test =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/test/demo-data-setup.test,v diff -u -r1.10 -r1.11 --- openacs-4/packages/simulation/test/demo-data-setup.test 5 Jan 2004 12:17:13 -0000 1.10 +++ openacs-4/packages/simulation/test/demo-data-setup.test 5 Jan 2004 17:05:07 -0000 1.11 @@ -128,7 +128,7 @@ ::twt::log_section "Create simulation template" do_request /simulation/simbuild/template-edit set template_name "Elementary Private Law" - field fill $template_name ~n name + field fill $template_name ~n pretty_name field find ~n template_ready_p field fill t form submit 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.3 -r1.4 --- openacs-4/packages/simulation/www/simplay/message.adp 5 Jan 2004 15:35:40 -0000 1.3 +++ openacs-4/packages/simulation/www/simplay/message.adp 5 Jan 2004 17:05:07 -0000 1.4 @@ -2,15 +2,17 @@ @page_title;noquote@@context;noquote@@focus;noquote@ + + + - - -

Form: -

- -TODO: On-refresh on "From" field; changes the "To" field to exclude the "From" role (you can't send to yourself), and changes the list of possible attachments (see above note) 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.8 -r1.9 --- openacs-4/packages/simulation/www/simplay/message.tcl 5 Jan 2004 16:10:37 -0000 1.8 +++ openacs-4/packages/simulation/www/simplay/message.tcl 5 Jan 2004 17:05:07 -0000 1.9 @@ -4,7 +4,7 @@ item_id:optional case_id:optional sender_role_id:optional - recipient_role_id:optional + recipient_role_id:optional,multiple subject:optional body_text:optional body_mime_type:optional @@ -20,6 +20,10 @@ 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] } +# First sender role selected by default +if { ![exists_and_not_null sender_role_id] } { + set sender_role_id [lindex [lindex $from_role_options 0] 1] +} set all_role_options [list] foreach role_id [workflow::role::get_ids -workflow_id $workflow_id] { @@ -28,9 +32,25 @@ 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] + # A role cannot send message to himself + if { ![exists_and_equal sender_role_id $role_id] } { + lappend to_role_options [list [workflow::role::get_element -role_id $role_id -element pretty_name] $role_id] + } } +set attachment_options [db_list_of_lists attachment_for_role { + select cr.title as document_title, + scrom.object_id as document_id + from sim_case_role_object_map scrom, + cr_items ci, + cr_revisions cr + where scrom.case_id = :case_id + and scrom.role_id = :sender_role_id + and scrom.object_id = ci.item_id + and ci.live_revision = cr.revision_id + order by scrom.order_n +}] + set action [form::get_action message] @@ -65,9 +85,9 @@ -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"} + {html {onChange "javascript:FormRefresh('message');"}} {options $all_role_options} } } @@ -93,9 +113,9 @@ {label "Body"} {html {cols 60 rows 20}} } - {attachments:text(inform) + {attachments:integer(checkbox),multiple,optional {label "Attachments"} - {value "TODO"} + {options $attachment_options} } } -new_request { if { [info exists body_text] } { @@ -136,17 +156,16 @@ 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 + -body_mime_type $body_mime_type \ + -attachments $attachments } } ad_returnredirect [export_vars -base case { case_id }] ad_script_abort } - Index: openacs-4/packages/simulation/www/simplay/play-master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/play-master.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/simulation/www/simplay/play-master.adp 5 Jan 2004 12:33:41 -0000 1.4 +++ openacs-4/packages/simulation/www/simplay/play-master.adp 5 Jan 2004 17:05:07 -0000 1.5 @@ -1,6 +1,7 @@ @title;noquote@ @context;noquote@ + @header_stuff;noquote@ @focus;noquote@
Index: openacs-4/packages/simulation/www/simplay/play-master.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/play-master.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/www/simplay/play-master.tcl 19 Dec 2003 14:22:53 -0000 1.2 +++ openacs-4/packages/simulation/www/simplay/play-master.tcl 5 Jan 2004 17:05:07 -0000 1.3 @@ -4,3 +4,7 @@ if { ![exists_and_not_null case_id] } { set case_id [ns_queryget case_id] } + +if { [template::util::is_nil header_stuff] } { + set header_stuff "" +}