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.12 -r1.13 --- openacs-4/contrib/packages/simulation/lib/messages.tcl 12 Jan 2004 13:43:14 -0000 1.12 +++ openacs-4/contrib/packages/simulation/lib/messages.tcl 12 Jan 2004 15:14:36 -0000 1.13 @@ -11,21 +11,25 @@ case_id { required_p 0 } + role_id { + required_p 0 + } limit { default_value {} } } -# TODO: finish. if case id is nil, check that adminplayer_p is true. if not, fail. -# if admin is true, ... - set package_id [ad_conn package_id] set adminplayer_p [permission::permission_p -object_id $package_id -privilege sim_adminplayer] -if { [exists_and_not_null case_id] } { - set user_roles [workflow::case::get_user_roles -case_id $case_id] +if { ![exists_and_not_null case_id] || ![exists_and_not_null role_id] } { + if { !$adminplayer_p } { + error "You must supply both case_id and role_id" + } else { + set mode "admin" + } } else { - set user_roles [list] + set mode "user" } set elements { @@ -34,11 +38,9 @@ } to { label "To" - hide_p {[ad_decode [llength $user_roles] 1 1 0]} } subject { - link_url_col - message_url + link_url_col message_url label "Subject" } creation_date { @@ -59,15 +61,21 @@ } } +if { [exists_and_not_null case_id] } { + set actions [list "Send new message" [export_vars -base message { case_id role_id }] {}] +} else { + set actions [list] +} + 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 }] {}] \ + -actions $actions \ -elements $elements db_multirow -extend { message_url creation_date_pretty } messages select_messages " - select distinct sm.message_id, + select sm.message_id, cr.item_id, sm.title as subject, sc.label as case_label, @@ -82,27 +90,30 @@ 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 + where item_id = sm.item_id + and relation_tag = 'attachment') as attachment_count, + sm.to_role_id, + sm.case_id as msg_case_id 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 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 wcrmp.role_id = sm.to_role_id and wc.case_id = sm.case_id + [ad_decode $mode "user" "and (sm.to_role_id = :role_id or sm.from_role_id = :role_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" ""] + [ad_decode $mode "user" "and wc.case_id = :case_id" "and exists (select 1 from workflow_case_role_user_map where case_id = wc.case_id and (sm.to_role_id = role_id or sm.from_role_id = role_id) and user_id = :user_id)"] order by sm.creation_date desc [ad_decode $limit "" "" "limit $limit"] " { - set message_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message" { item_id case_id }] + + if { [string equal $mode "admin"] } { + set message_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message" { item_id { case_id $msg_case_id } { role_id $to_role_id } }] + } else { + set message_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message" { item_id case_id role_id }] + } set creation_date_pretty [lc_time_fmt $creation_date_ansi "%x %X"] } Index: openacs-4/contrib/packages/simulation/lib/portfolio.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/portfolio.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/simulation/lib/portfolio.tcl 8 Jan 2004 16:02:34 -0000 1.4 +++ openacs-4/contrib/packages/simulation/lib/portfolio.tcl 12 Jan 2004 15:14:36 -0000 1.5 @@ -6,9 +6,10 @@ @cvs-id $Id$ } { case_id {} + role_id {} } -set upload_url [export_vars -base document-upload { case_id }] +set upload_url [export_vars -base document-upload { case_id role_id }] if { [exists_and_not_null case_id] } { set user_roles [workflow::case::get_user_roles -case_id $case_id] 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.8 -r1.9 --- openacs-4/contrib/packages/simulation/lib/tasks.tcl 6 Jan 2004 09:51:25 -0000 1.8 +++ openacs-4/contrib/packages/simulation/lib/tasks.tcl 12 Jan 2004 15:14:36 -0000 1.9 @@ -1,4 +1,4 @@ -simulation::include_contract { + simulation::include_contract { Displays a list of tasks for a given user_id @author Joel Aufrecht @@ -11,39 +11,44 @@ case_id { default_value "" } + role_id { + default_value "" + } } if { [empty_string_p $case_id] } { unset case_id } +set package_id [ad_conn package_id] +set adminplayer_p [permission::permission_p -object_id $package_id -privilege sim_adminplayer] + +if { !$adminplayer_p } { + if { ![exists_and_not_null case_id] || ![exists_and_not_null role_id] } { + error "You must supply both case_id and role_id" + } +} + if { [exists_and_not_null case_id] } { - set num_enabled_actions [db_string select_num_enabled_actions { select count(*) from workflow_case_enabled_actions where case_id = :case_id and enabled_state = 'enabled' }] - set complete_p [expr $num_enabled_actions == 0] - - set user_roles [workflow::case::get_user_roles -case_id $case_id] } else { - set user_roles [list] set complete_p 0 } -set package_id [ad_conn package_id] - set elements { name { link_url_col task_url label "Task" } role { label "Role" - hide_p {[ad_decode [llength $user_roles] 1 1 0]} + hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} } case_label { label "Case" @@ -59,40 +64,33 @@ -name tasks \ -multirow tasks \ -no_data "You don't have any tasks." \ - -elements $elements \ - -filters { - case_id { - where_clause "wc.case_id = :case_id" - } - } + -elements $elements +# TODO: Honor role_id db_multirow -extend { task_url } tasks select_tasks " select wcea.enabled_action_id, wa.pretty_name as name, wcea.case_id, sc.label as case_label, w.pretty_name as sim_name, - wr.pretty_name as role + wr.pretty_name as role, + wr.role_id as role_id from workflow_case_enabled_actions wcea, - workflow_case_role_party_map wcrmp, workflow_actions wa, - party_approved_member_map pamm, workflow_cases wc, sim_cases sc, workflows w, workflow_roles wr where wcea.enabled_state = 'enabled' - and pamm.member_id = :user_id - and wcrmp.party_id = pamm.party_id - and wcrmp.case_id = wcea.case_id - and wcrmp.role_id = wa.assigned_role and wa.action_id = wcea.action_id + and wr.role_id = wa.assigned_role and wc.case_id = wcea.case_id and sc.sim_case_id = wc.object_id and w.workflow_id = wc.workflow_id - and wr.role_id = wa.assigned_role - [template::list::filter_where_clauses -and -name "tasks"] + [ad_decode [exists_and_not_null role_id] 1 "and wr.role_id = :role_id" ""] + [ad_decode [exists_and_not_null case_id] 1 "and wcea.case_id = :case_id" "and exists (select 1 from workflow_case_role_user_map where case_id = wc.case_id and wa.assigned_role = role_id and user_id = :user_id)"] + order by wa.sort_order " { - set task_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/task-detail" { enabled_action_id }] + set task_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/task-detail" { enabled_action_id case_id role_id }] } Index: openacs-4/contrib/packages/simulation/www/simplay/case-admin.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/case-admin.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/simplay/case-admin.tcl 12 Jan 2004 13:43:14 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/simplay/case-admin.tcl 12 Jan 2004 15:14:36 -0000 1.3 @@ -2,11 +2,10 @@ This page allows users to choose which group to join. It is only relevant for simulations with casting type of group. } { case_id:integer - role_id:integer } set title "Administer" -set context [list [list . "SimPlay"] [list [export_vars -base case { case_id role_id }] "Case CASENAME"] $title] +set context [list [list . "SimPlay"] $title] set user_id [ad_conn user_id] set package_id [ad_conn package_id] set section_uri [apm_package_url_from_id $package_id]simplay/ Index: openacs-4/contrib/packages/simulation/www/simplay/case.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/case.adp,v diff -u -r1.9 -r1.10 --- openacs-4/contrib/packages/simulation/www/simplay/case.adp 12 Jan 2004 13:43:14 -0000 1.9 +++ openacs-4/contrib/packages/simulation/www/simplay/case.adp 12 Jan 2004 15:14:36 -0000 1.10 @@ -4,16 +4,16 @@

Recent Messages

- +

All messages...

Tasks

- +

Document Portfolio

- + Index: openacs-4/contrib/packages/simulation/www/simplay/control-bar.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/control-bar.adp,v diff -u -r1.11 -r1.12 --- openacs-4/contrib/packages/simulation/www/simplay/control-bar.adp 12 Jan 2004 13:43:14 -0000 1.11 +++ openacs-4/contrib/packages/simulation/www/simplay/control-bar.adp 12 Jan 2004 15:14:36 -0000 1.12 @@ -8,8 +8,8 @@

Your Options

Index: openacs-4/contrib/packages/simulation/www/simplay/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/index.adp,v diff -u -r1.19 -r1.20 --- openacs-4/contrib/packages/simulation/www/simplay/index.adp 12 Jan 2004 13:43:14 -0000 1.19 +++ openacs-4/contrib/packages/simulation/www/simplay/index.adp 12 Jan 2004 15:14:36 -0000 1.20 @@ -14,14 +14,12 @@

All Messages

- +

All Tasks

- +

- -

TODO (1h): all of simplay should require 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.7 -r1.8 --- openacs-4/contrib/packages/simulation/www/simplay/message.adp 9 Jan 2004 14:40:03 -0000 1.7 +++ openacs-4/contrib/packages/simulation/www/simplay/message.adp 12 Jan 2004 15:14:36 -0000 1.8 @@ -4,15 +4,5 @@ @focus;noquote@ -

TODO: From should always be read-only and show the current role. -

TODO: Task should be part of heading -

TODO: description and "document" -link should be inline before the message form instead of being part of -the form -

TODO: B: If there's only one possible recipient, don't show the -checkbox -

TODO: fix problem that To: is blank in view mode -

TODO: make attachments be read-only links in display mode, instead -of showing checkboxes -

TODO: fix bug that you can't add an attachment +

TODO: add "select all" javascript checkbox for To field 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.17 -r1.18 --- openacs-4/contrib/packages/simulation/www/simplay/message.tcl 12 Jan 2004 13:43:14 -0000 1.17 +++ openacs-4/contrib/packages/simulation/www/simplay/message.tcl 12 Jan 2004 15:14:36 -0000 1.18 @@ -4,7 +4,6 @@ item_id:integer,optional case_id:integer role_id:integer - sender_role_id:integer,optional recipient_role_id:integer,optional,multiple subject:optional body_text:optional @@ -19,30 +18,21 @@ set workflow_id [workflow::case::get_element -case_id $case_id -element workflow_id] -set from_role_options [list] -foreach one_role_id [workflow::case::get_user_roles -case_id $case_id] { - lappend from_role_options [list [workflow::role::get_element -role_id $one_role_id -element pretty_name] $one_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 one_role_id [workflow::role::get_ids -workflow_id $workflow_id] { - lappend all_role_options [list [workflow::role::get_element -role_id $one_role_id -element pretty_name] $one_role_id] + set pretty_name [workflow::role::get_element -role_id $one_role_id -element pretty_name] + lappend all_role_options [list $pretty_name $one_role_id] } set to_role_options [list] foreach one_role_id [workflow::role::get_ids -workflow_id $workflow_id] { # A role cannot send message to himself - if { ![exists_and_equal sender_role_id $one_role_id] } { + if { ![exists_and_equal role_id $one_role_id] } { lappend to_role_options [list [workflow::role::get_element -role_id $one_role_id -element pretty_name] $one_role_id] } } -set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $sender_role_id] +set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $role_id] set action [form::get_action message] @@ -54,7 +44,6 @@ -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 " @@ -68,38 +57,63 @@ [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_returnredirect [export_vars -base [ad_conn url] { case_id role_id recipient_role_id subject body_text body_mime_type }] } set form_mode [ad_decode [ad_form_new_p -key item_id] 1 "edit" "display"] +set focus "message.recipient_role_id" + +set sender_role_id $role_id + ad_form \ -name message \ -edit_buttons { { Send ok } } \ -actions { { Reply reply } } \ - -export { case_id } \ + -export { case_id role_id } \ -mode $form_mode \ -form { + {item_id:key} {sender_role_id:text(select) {label "From"} - {html {onChange "javascript:acs_FormRefresh('message');"}} + {mode display} {options $all_role_options} } } -if { [llength $from_role_options] > 1 } { - set focus "message.sender_role_id" +if { [ad_form_new_p -key item_id] } { + if { [llength $to_role_options] == 1 } { + set recipient_role_id [lindex [lindex $to_role_options 0] 1] + + ad_form -extend -name message -form { + {recipient_role_id_inform:text(inform) + {label "To"} + {value {[lindex [lindex $to_role_options 0] 0]}} + } + {recipient_role_id:integer(hidden) + {value {[lindex [lindex $to_role_options 0] 1]}} + } + } + } else { + ad_form -extend -name message -form { + {recipient_role_id:integer(checkbox),multiple + {label "To"} + {options $to_role_options} + } + } + } } 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} + } + } } + + ad_form -extend -name message -form { - {item_id:key} - {recipient_role_id:integer(checkbox),multiple - {label "To"} - {options $to_role_options} - } {subject:text {label "Subject"} {html {size 80}} @@ -142,13 +156,6 @@ set body [template::util::richtext::create $body_text $body_mime_type] set focus "message.body" } - - if { [llength $from_role_options] == 1 } { - set sender_role_id [lindex [lindex $from_role_options 0] 1] - element set_properties message sender_role_id -mode display - } else { - element set_properties message sender_role_id -options $from_role_options - } } -edit_request { item::get_content \ @@ -182,7 +189,10 @@ set object_url [simulation::object::url -name [ns_set get $attachment_set name]] set object_title [ns_set get $attachment_set title] append attachments "$object_title
" - } + } + if { [llength $attachments_set_list] == 0 } { + element set_properties message attachments -widget hidden + } } } -on_submit { @@ -209,3 +219,8 @@ ad_returnredirect [export_vars -base case { case_id role_id }] ad_script_abort } + +if { ![ad_form_new_p -key item_id] } { + element set_properties message recipient_role_id -options $all_role_options +} + Index: openacs-4/contrib/packages/simulation/www/simplay/messages.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/messages.adp,v diff -u -r1.10 -r1.11 --- openacs-4/contrib/packages/simulation/www/simplay/messages.adp 12 Jan 2004 13:43:14 -0000 1.10 +++ openacs-4/contrib/packages/simulation/www/simplay/messages.adp 12 Jan 2004 15:14:36 -0000 1.11 @@ -2,7 +2,7 @@ @title;noquote@ @context;noquote@ - +

TODO: show sent messages as well Index: openacs-4/contrib/packages/simulation/www/simplay/portfolio.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/portfolio.adp,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/simulation/www/simplay/portfolio.adp 7 Jan 2004 14:46:04 -0000 1.3 +++ openacs-4/contrib/packages/simulation/www/simplay/portfolio.adp 12 Jan 2004 15:14:36 -0000 1.4 @@ -2,7 +2,7 @@ @title;noquote@ @context;noquote@ - +

TODO: since simplay/case provides a list of portfolio items, this page is probably the detail page for a single item, or for adding an Index: openacs-4/contrib/packages/simulation/www/simplay/task-detail.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/task-detail.adp,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/simulation/www/simplay/task-detail.adp 19 Dec 2003 14:22:53 -0000 1.4 +++ openacs-4/contrib/packages/simulation/www/simplay/task-detail.adp 12 Jan 2004 15:14:36 -0000 1.5 @@ -5,3 +5,10 @@ @case_id@ + +

TODO: Task should be part of heading + +

TODO: description and "document" +link should be inline before the message form instead of being part of +the form + Index: openacs-4/contrib/packages/simulation/www/simplay/tasks.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/tasks.adp,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/simulation/www/simplay/tasks.adp 8 Jan 2004 16:02:34 -0000 1.6 +++ openacs-4/contrib/packages/simulation/www/simplay/tasks.adp 12 Jan 2004 15:14:36 -0000 1.7 @@ -2,7 +2,7 @@ @title;noquote@ @context;noquote@ - + TODO: make sure to show all completed tasks (one reason is that this is the only way to see documents that are part of tasks) Index: openacs-4/packages/simulation/lib/messages.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/messages.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/simulation/lib/messages.tcl 12 Jan 2004 13:43:14 -0000 1.12 +++ openacs-4/packages/simulation/lib/messages.tcl 12 Jan 2004 15:14:36 -0000 1.13 @@ -11,21 +11,25 @@ case_id { required_p 0 } + role_id { + required_p 0 + } limit { default_value {} } } -# TODO: finish. if case id is nil, check that adminplayer_p is true. if not, fail. -# if admin is true, ... - set package_id [ad_conn package_id] set adminplayer_p [permission::permission_p -object_id $package_id -privilege sim_adminplayer] -if { [exists_and_not_null case_id] } { - set user_roles [workflow::case::get_user_roles -case_id $case_id] +if { ![exists_and_not_null case_id] || ![exists_and_not_null role_id] } { + if { !$adminplayer_p } { + error "You must supply both case_id and role_id" + } else { + set mode "admin" + } } else { - set user_roles [list] + set mode "user" } set elements { @@ -34,11 +38,9 @@ } to { label "To" - hide_p {[ad_decode [llength $user_roles] 1 1 0]} } subject { - link_url_col - message_url + link_url_col message_url label "Subject" } creation_date { @@ -59,15 +61,21 @@ } } +if { [exists_and_not_null case_id] } { + set actions [list "Send new message" [export_vars -base message { case_id role_id }] {}] +} else { + set actions [list] +} + 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 }] {}] \ + -actions $actions \ -elements $elements db_multirow -extend { message_url creation_date_pretty } messages select_messages " - select distinct sm.message_id, + select sm.message_id, cr.item_id, sm.title as subject, sc.label as case_label, @@ -82,27 +90,30 @@ 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 + where item_id = sm.item_id + and relation_tag = 'attachment') as attachment_count, + sm.to_role_id, + sm.case_id as msg_case_id 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 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 wcrmp.role_id = sm.to_role_id and wc.case_id = sm.case_id + [ad_decode $mode "user" "and (sm.to_role_id = :role_id or sm.from_role_id = :role_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" ""] + [ad_decode $mode "user" "and wc.case_id = :case_id" "and exists (select 1 from workflow_case_role_user_map where case_id = wc.case_id and (sm.to_role_id = role_id or sm.from_role_id = role_id) and user_id = :user_id)"] order by sm.creation_date desc [ad_decode $limit "" "" "limit $limit"] " { - set message_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message" { item_id case_id }] + + if { [string equal $mode "admin"] } { + set message_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message" { item_id { case_id $msg_case_id } { role_id $to_role_id } }] + } else { + set message_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message" { item_id case_id role_id }] + } set creation_date_pretty [lc_time_fmt $creation_date_ansi "%x %X"] } Index: openacs-4/packages/simulation/lib/portfolio.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/portfolio.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/simulation/lib/portfolio.tcl 8 Jan 2004 16:02:34 -0000 1.4 +++ openacs-4/packages/simulation/lib/portfolio.tcl 12 Jan 2004 15:14:36 -0000 1.5 @@ -6,9 +6,10 @@ @cvs-id $Id$ } { case_id {} + role_id {} } -set upload_url [export_vars -base document-upload { case_id }] +set upload_url [export_vars -base document-upload { case_id role_id }] if { [exists_and_not_null case_id] } { set user_roles [workflow::case::get_user_roles -case_id $case_id] Index: openacs-4/packages/simulation/lib/tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/tasks.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/simulation/lib/tasks.tcl 6 Jan 2004 09:51:25 -0000 1.8 +++ openacs-4/packages/simulation/lib/tasks.tcl 12 Jan 2004 15:14:36 -0000 1.9 @@ -1,4 +1,4 @@ -simulation::include_contract { + simulation::include_contract { Displays a list of tasks for a given user_id @author Joel Aufrecht @@ -11,39 +11,44 @@ case_id { default_value "" } + role_id { + default_value "" + } } if { [empty_string_p $case_id] } { unset case_id } +set package_id [ad_conn package_id] +set adminplayer_p [permission::permission_p -object_id $package_id -privilege sim_adminplayer] + +if { !$adminplayer_p } { + if { ![exists_and_not_null case_id] || ![exists_and_not_null role_id] } { + error "You must supply both case_id and role_id" + } +} + if { [exists_and_not_null case_id] } { - set num_enabled_actions [db_string select_num_enabled_actions { select count(*) from workflow_case_enabled_actions where case_id = :case_id and enabled_state = 'enabled' }] - set complete_p [expr $num_enabled_actions == 0] - - set user_roles [workflow::case::get_user_roles -case_id $case_id] } else { - set user_roles [list] set complete_p 0 } -set package_id [ad_conn package_id] - set elements { name { link_url_col task_url label "Task" } role { label "Role" - hide_p {[ad_decode [llength $user_roles] 1 1 0]} + hide_p {[ad_decode [exists_and_not_null case_id] 1 1 0]} } case_label { label "Case" @@ -59,40 +64,33 @@ -name tasks \ -multirow tasks \ -no_data "You don't have any tasks." \ - -elements $elements \ - -filters { - case_id { - where_clause "wc.case_id = :case_id" - } - } + -elements $elements +# TODO: Honor role_id db_multirow -extend { task_url } tasks select_tasks " select wcea.enabled_action_id, wa.pretty_name as name, wcea.case_id, sc.label as case_label, w.pretty_name as sim_name, - wr.pretty_name as role + wr.pretty_name as role, + wr.role_id as role_id from workflow_case_enabled_actions wcea, - workflow_case_role_party_map wcrmp, workflow_actions wa, - party_approved_member_map pamm, workflow_cases wc, sim_cases sc, workflows w, workflow_roles wr where wcea.enabled_state = 'enabled' - and pamm.member_id = :user_id - and wcrmp.party_id = pamm.party_id - and wcrmp.case_id = wcea.case_id - and wcrmp.role_id = wa.assigned_role and wa.action_id = wcea.action_id + and wr.role_id = wa.assigned_role and wc.case_id = wcea.case_id and sc.sim_case_id = wc.object_id and w.workflow_id = wc.workflow_id - and wr.role_id = wa.assigned_role - [template::list::filter_where_clauses -and -name "tasks"] + [ad_decode [exists_and_not_null role_id] 1 "and wr.role_id = :role_id" ""] + [ad_decode [exists_and_not_null case_id] 1 "and wcea.case_id = :case_id" "and exists (select 1 from workflow_case_role_user_map where case_id = wc.case_id and wa.assigned_role = role_id and user_id = :user_id)"] + order by wa.sort_order " { - set task_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/task-detail" { enabled_action_id }] + set task_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/task-detail" { enabled_action_id case_id role_id }] } Index: openacs-4/packages/simulation/www/simplay/case-admin.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/case-admin.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/www/simplay/case-admin.tcl 12 Jan 2004 13:43:14 -0000 1.2 +++ openacs-4/packages/simulation/www/simplay/case-admin.tcl 12 Jan 2004 15:14:36 -0000 1.3 @@ -2,11 +2,10 @@ This page allows users to choose which group to join. It is only relevant for simulations with casting type of group. } { case_id:integer - role_id:integer } set title "Administer" -set context [list [list . "SimPlay"] [list [export_vars -base case { case_id role_id }] "Case CASENAME"] $title] +set context [list [list . "SimPlay"] $title] set user_id [ad_conn user_id] set package_id [ad_conn package_id] set section_uri [apm_package_url_from_id $package_id]simplay/ Index: openacs-4/packages/simulation/www/simplay/case.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/case.adp,v diff -u -r1.9 -r1.10 --- openacs-4/packages/simulation/www/simplay/case.adp 12 Jan 2004 13:43:14 -0000 1.9 +++ openacs-4/packages/simulation/www/simplay/case.adp 12 Jan 2004 15:14:36 -0000 1.10 @@ -4,16 +4,16 @@

Recent Messages

- +

All messages...

Tasks

- +

Document Portfolio

- + Index: openacs-4/packages/simulation/www/simplay/control-bar.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/control-bar.adp,v diff -u -r1.11 -r1.12 --- openacs-4/packages/simulation/www/simplay/control-bar.adp 12 Jan 2004 13:43:14 -0000 1.11 +++ openacs-4/packages/simulation/www/simplay/control-bar.adp 12 Jan 2004 15:14:36 -0000 1.12 @@ -8,8 +8,8 @@

Your Options

Index: openacs-4/packages/simulation/www/simplay/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/index.adp,v diff -u -r1.19 -r1.20 --- openacs-4/packages/simulation/www/simplay/index.adp 12 Jan 2004 13:43:14 -0000 1.19 +++ openacs-4/packages/simulation/www/simplay/index.adp 12 Jan 2004 15:14:36 -0000 1.20 @@ -14,14 +14,12 @@

All Messages

- +

All Tasks

- +

- -

TODO (1h): all of simplay should require 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.7 -r1.8 --- openacs-4/packages/simulation/www/simplay/message.adp 9 Jan 2004 14:40:03 -0000 1.7 +++ openacs-4/packages/simulation/www/simplay/message.adp 12 Jan 2004 15:14:36 -0000 1.8 @@ -4,15 +4,5 @@ @focus;noquote@ -

TODO: From should always be read-only and show the current role. -

TODO: Task should be part of heading -

TODO: description and "document" -link should be inline before the message form instead of being part of -the form -

TODO: B: If there's only one possible recipient, don't show the -checkbox -

TODO: fix problem that To: is blank in view mode -

TODO: make attachments be read-only links in display mode, instead -of showing checkboxes -

TODO: fix bug that you can't add an attachment +

TODO: add "select all" javascript checkbox for To field 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.17 -r1.18 --- openacs-4/packages/simulation/www/simplay/message.tcl 12 Jan 2004 13:43:14 -0000 1.17 +++ openacs-4/packages/simulation/www/simplay/message.tcl 12 Jan 2004 15:14:36 -0000 1.18 @@ -4,7 +4,6 @@ item_id:integer,optional case_id:integer role_id:integer - sender_role_id:integer,optional recipient_role_id:integer,optional,multiple subject:optional body_text:optional @@ -19,30 +18,21 @@ set workflow_id [workflow::case::get_element -case_id $case_id -element workflow_id] -set from_role_options [list] -foreach one_role_id [workflow::case::get_user_roles -case_id $case_id] { - lappend from_role_options [list [workflow::role::get_element -role_id $one_role_id -element pretty_name] $one_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 one_role_id [workflow::role::get_ids -workflow_id $workflow_id] { - lappend all_role_options [list [workflow::role::get_element -role_id $one_role_id -element pretty_name] $one_role_id] + set pretty_name [workflow::role::get_element -role_id $one_role_id -element pretty_name] + lappend all_role_options [list $pretty_name $one_role_id] } set to_role_options [list] foreach one_role_id [workflow::role::get_ids -workflow_id $workflow_id] { # A role cannot send message to himself - if { ![exists_and_equal sender_role_id $one_role_id] } { + if { ![exists_and_equal role_id $one_role_id] } { lappend to_role_options [list [workflow::role::get_element -role_id $one_role_id -element pretty_name] $one_role_id] } } -set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $sender_role_id] +set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $role_id] set action [form::get_action message] @@ -54,7 +44,6 @@ -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 " @@ -68,38 +57,63 @@ [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_returnredirect [export_vars -base [ad_conn url] { case_id role_id recipient_role_id subject body_text body_mime_type }] } set form_mode [ad_decode [ad_form_new_p -key item_id] 1 "edit" "display"] +set focus "message.recipient_role_id" + +set sender_role_id $role_id + ad_form \ -name message \ -edit_buttons { { Send ok } } \ -actions { { Reply reply } } \ - -export { case_id } \ + -export { case_id role_id } \ -mode $form_mode \ -form { + {item_id:key} {sender_role_id:text(select) {label "From"} - {html {onChange "javascript:acs_FormRefresh('message');"}} + {mode display} {options $all_role_options} } } -if { [llength $from_role_options] > 1 } { - set focus "message.sender_role_id" +if { [ad_form_new_p -key item_id] } { + if { [llength $to_role_options] == 1 } { + set recipient_role_id [lindex [lindex $to_role_options 0] 1] + + ad_form -extend -name message -form { + {recipient_role_id_inform:text(inform) + {label "To"} + {value {[lindex [lindex $to_role_options 0] 0]}} + } + {recipient_role_id:integer(hidden) + {value {[lindex [lindex $to_role_options 0] 1]}} + } + } + } else { + ad_form -extend -name message -form { + {recipient_role_id:integer(checkbox),multiple + {label "To"} + {options $to_role_options} + } + } + } } 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} + } + } } + + ad_form -extend -name message -form { - {item_id:key} - {recipient_role_id:integer(checkbox),multiple - {label "To"} - {options $to_role_options} - } {subject:text {label "Subject"} {html {size 80}} @@ -142,13 +156,6 @@ set body [template::util::richtext::create $body_text $body_mime_type] set focus "message.body" } - - if { [llength $from_role_options] == 1 } { - set sender_role_id [lindex [lindex $from_role_options 0] 1] - element set_properties message sender_role_id -mode display - } else { - element set_properties message sender_role_id -options $from_role_options - } } -edit_request { item::get_content \ @@ -182,7 +189,10 @@ set object_url [simulation::object::url -name [ns_set get $attachment_set name]] set object_title [ns_set get $attachment_set title] append attachments "$object_title
" - } + } + if { [llength $attachments_set_list] == 0 } { + element set_properties message attachments -widget hidden + } } } -on_submit { @@ -209,3 +219,8 @@ ad_returnredirect [export_vars -base case { case_id role_id }] ad_script_abort } + +if { ![ad_form_new_p -key item_id] } { + element set_properties message recipient_role_id -options $all_role_options +} + Index: openacs-4/packages/simulation/www/simplay/messages.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/messages.adp,v diff -u -r1.10 -r1.11 --- openacs-4/packages/simulation/www/simplay/messages.adp 12 Jan 2004 13:43:14 -0000 1.10 +++ openacs-4/packages/simulation/www/simplay/messages.adp 12 Jan 2004 15:14:36 -0000 1.11 @@ -2,7 +2,7 @@ @title;noquote@ @context;noquote@ - +

TODO: show sent messages as well Index: openacs-4/packages/simulation/www/simplay/portfolio.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/portfolio.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/simulation/www/simplay/portfolio.adp 7 Jan 2004 14:46:04 -0000 1.3 +++ openacs-4/packages/simulation/www/simplay/portfolio.adp 12 Jan 2004 15:14:36 -0000 1.4 @@ -2,7 +2,7 @@ @title;noquote@ @context;noquote@ - +

TODO: since simplay/case provides a list of portfolio items, this page is probably the detail page for a single item, or for adding an Index: openacs-4/packages/simulation/www/simplay/task-detail.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/task-detail.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/simulation/www/simplay/task-detail.adp 19 Dec 2003 14:22:53 -0000 1.4 +++ openacs-4/packages/simulation/www/simplay/task-detail.adp 12 Jan 2004 15:14:36 -0000 1.5 @@ -5,3 +5,10 @@ @case_id@ + +

TODO: Task should be part of heading + +

TODO: description and "document" +link should be inline before the message form instead of being part of +the form + Index: openacs-4/packages/simulation/www/simplay/tasks.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/tasks.adp,v diff -u -r1.6 -r1.7 --- openacs-4/packages/simulation/www/simplay/tasks.adp 8 Jan 2004 16:02:34 -0000 1.6 +++ openacs-4/packages/simulation/www/simplay/tasks.adp 12 Jan 2004 15:14:36 -0000 1.7 @@ -2,7 +2,7 @@ @title;noquote@ @context;noquote@ - + TODO: make sure to show all completed tasks (one reason is that this is the only way to see documents that are part of tasks)