Index: openacs-4/contrib/packages/simulation/lib/simulations-task-count.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/simulations-task-count.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/lib/simulations-task-count.adp 4 Mar 2004 12:09:43 -0000 1.1
@@ -0,0 +1 @@
+
+
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.24 -r1.25 --- openacs-4/contrib/packages/simulation/www/simplay/message.tcl 30 Jan 2004 11:23:25 -0000 1.24 +++ openacs-4/contrib/packages/simulation/www/simplay/message.tcl 4 Mar 2004 12:09:44 -0000 1.25 @@ -26,10 +26,7 @@ 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 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 $role_id] 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.9 -r1.10 --- openacs-4/contrib/packages/simulation/www/simplay/task-detail.adp 30 Jan 2004 10:57:08 -0000 1.9 +++ openacs-4/contrib/packages/simulation/www/simplay/task-detail.adp 4 Mar 2004 12:09:44 -0000 1.10 @@ -1,9 +1,28 @@ -+ You are doing a bulk response to @common_actions_count@ tasks. +
+ ++ Note: Ignoring @ignored_actions_count@ tasks that don't have the task + name "@action.pretty_name@". Please back up your browser if you + want to change the selection of tasks. +
+@action.description@
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.19 -r1.20 --- openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl 30 Jan 2004 11:23:25 -0000 1.19 +++ openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl 4 Mar 2004 12:09:44 -0000 1.20 @@ -2,31 +2,102 @@ Details for a task. If there is a recipient_role a message is created. If there is not recipient role we upload a document instead. } { - case_id:integer - role_id:integer - enabled_action_id:integer + {enabled_action_id:integer,multiple ""} + {enabled_action_ids ""} item_id:optional + {bulk_p 0} + {return_url ""} } -simulation::case::assert_user_may_play_role -case_id $case_id -role_id $role_id +# FIXME: I am exporting the enabled_action_id list as the string variable enabled_action_ids in +# the forms as I can't export multiples. Here I'm recreating the list again. This is convoluted. +if { ![empty_string_p $enabled_action_ids] } { + set enabled_action_id [split $enabled_action_ids] +} -workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action -set action_id $enabled_action(action_id) -simulation::action::get -action_id $action_id -array action +if { [llength $enabled_action_id] > 1 } { + set bulk_p 1 +} +if { !$bulk_p } { + workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action + + set action_id $enabled_action(action_id) + set case_id $enabled_action(case_id) + simulation::action::get -action_id $action_id -array action + set role_id $action(assigned_role_id) + + simulation::case::assert_user_may_play_role -case_id $case_id -role_id $action(assigned_role_id) + + set common_enabled_action_ids [list [list $enabled_action_id $case_id]] + + if { [empty_string_p $return_url] } { + set return_url [export_vars -base tasks { case_id role_id }] + } + +} else { + # Only admin users can neglect to provide case_id and role_id + permission::require_permission -object_id [ad_conn package_id] -privilege sim_adminplayer + + # If we are taking action on more than one task, extract the subset of the tasks that + # have the same action_id + set common_action_id "" + set common_enabled_action_ids [list] + set ignored_enabled_action_ids [list] + set task_list [db_list_of_lists select_tasks " + select wcea.enabled_action_id, + wcea.action_id, + wcea.case_id + from workflow_case_enabled_actions wcea + where wcea.enabled_action_id in ('[join $enabled_action_id "', '"]') + "] + foreach task $task_list { + set one_enabled_action_id [lindex $task 0] + set one_action_id [lindex $task 1] + set one_case_id [lindex $task 2] + + if { [empty_string_p $common_action_id] } { + set common_action_id $one_action_id + set case_id $one_case_id + } + + if { [string equal $common_action_id $one_action_id] } { + lappend common_enabled_action_ids [list $one_enabled_action_id $one_case_id] + } else { + lappend ignored_enabled_action_ids $one_enabled_action_id + } + } + + set common_actions_count [llength $common_enabled_action_ids] + set ignored_actions_count [llength $ignored_enabled_action_ids] + + set action_id $common_action_id + + simulation::action::get -action_id $action_id -array action + + if { [empty_string_p $return_url] } { + set return_url [export_vars -base tasks-bulk { {workflow_id $action(workflow_id)} }] + } +} + set page_title $action(pretty_name) set context [list [list . "SimPlay"] [list [export_vars -base case { case_id role_id }] "Case"] [list [export_vars -base tasks { case_id role_id }] "Tasks"] $page_title] +set documents_pre_form "" if { ![empty_string_p $action(recipients)] } { # We have recipient roles - use message form - if { ![empty_string_p $action(assigned_role_id)] } { - set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $action(assigned_role_id)] + if { !$bulk_p } { + if { ![empty_string_p $action(assigned_role_id)] } { + set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $action(assigned_role_id)] + } + } else { + set attachment_options {} } set form_id action - ad_form -name $form_id -edit_buttons { { Send ok } } -export { case_id role_id enabled_action_id } \ + ad_form -name $form_id -edit_buttons { { Send ok } } -export { case_id role_id {enabled_action_ids $enabled_action_id} bulk_p} \ -form { {pretty_name:text(inform) {label "Task"} @@ -77,27 +148,32 @@ set body_text [template::util::richtext::get_property "contents" $body] set body_mime_type [template::util::richtext::get_property "format" $body] - + db_transaction { - set entry_id [workflow::case::action::execute \ + foreach one_action $common_enabled_action_ids { + set enabled_action_id [lindex $one_action 0] + set case_id [lindex $one_action 1] + + set entry_id [workflow::case::action::execute \ -enabled_action_id $enabled_action_id \ -comment $body_text \ -comment_mime_type $body_mime_type] - foreach recipient_id $action(recipients) { - simulation::message::new \ - -from_role_id $action(assigned_role_id) \ - -to_role_id $recipient_id \ - -case_id $case_id \ - -subject $subject \ - -body $body_text \ - -body_mime_type $body_mime_type \ - -attachments $attachments \ - -entry_id $entry_id - } + foreach recipient_id $action(recipients) { + simulation::message::new \ + -from_role_id $action(assigned_role_id) \ + -to_role_id $recipient_id \ + -case_id $case_id \ + -subject $subject \ + -body $body_text \ + -body_mime_type $body_mime_type \ + -attachments $attachments \ + -entry_id $entry_id + } + } } - ad_returnredirect [export_vars -base tasks { case_id role_id }] + ad_returnredirect $return_url ad_script_abort } @@ -109,7 +185,7 @@ set form_id document - ad_form -name $form_id -export { case_id role_id workflow_id enabled_action_id } -html {enctype multipart/form-data} \ + ad_form -name $form_id -export { case_id role_id workflow_id {enabled_action_ids $enabled_action_id} bulk_p} -html {enctype multipart/form-data} \ -form [concat {{pretty_name:text(inform) {label "Task"}}} [simulation::ui::forms::document_upload::form_block]] \ -on_request { set pretty_name $action(pretty_name) @@ -118,19 +194,23 @@ } -on_submit { db_transaction { - set entry_id [workflow::case::action::execute \ + foreach one_action $common_enabled_action_ids { + set case_id [lindex $one_action 1] + + set entry_id [workflow::case::action::execute \ -case_id $case_id \ -action_id $action_id \ -comment "Document [lindex $document_file 0] uploaded" \ -comment_mime_type "text/plain"] - simulation::ui::forms::document_upload::insert_document \ - $case_id $role_id $item_id $document_file $title $entry_id + simulation::ui::forms::document_upload::insert_document \ + $case_id $action(assigned_role_id) $item_id $document_file $title $entry_id + } } - ad_returnredirect [export_vars -base tasks { case_id role_id }] + ad_returnredirect $return_url + ad_script_abort } set focus "document.document_file" } - Index: openacs-4/contrib/packages/simulation/www/simplay/tasks-bulk.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/tasks-bulk.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/simplay/tasks-bulk.adp 4 Mar 2004 12:09:44 -0000 1.1 @@ -0,0 +1,10 @@ ++ If you are using the respond button to respond to multiple tasks + then all checked tasks must share the same task name. +
\ No newline at end of file Index: openacs-4/contrib/packages/simulation/www/simplay/tasks-bulk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/tasks-bulk.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/simplay/tasks-bulk.tcl 4 Mar 2004 12:09:44 -0000 1.1 @@ -0,0 +1,16 @@ +ad_page_contract { + This page shows all tasks that an admin has in a certain simulation and + allows the admin to take action on the tasks in bulk. + + @author Peter Marklund +} { + workflow_id:integer + role_id:optional +} + +permission::require_permission -object_id [ad_conn package_id] -privilege sim_adminplayer + +simulation::template::get -workflow_id $workflow_id -array simulation + +set page_title "Your Tasks in Simulation $simulation(pretty_name)" +set context [list [list . "SimPlay"] $page_title] Index: openacs-4/packages/simulation/lib/simulations-task-count.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/simulations-task-count.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/lib/simulations-task-count.adp 4 Mar 2004 12:09:43 -0000 1.1 @@ -0,0 +1 @@ ++
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.24 -r1.25 --- openacs-4/packages/simulation/www/simplay/message.tcl 30 Jan 2004 11:23:25 -0000 1.24 +++ openacs-4/packages/simulation/www/simplay/message.tcl 4 Mar 2004 12:09:44 -0000 1.25 @@ -26,10 +26,7 @@ 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 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 $role_id] 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.9 -r1.10 --- openacs-4/packages/simulation/www/simplay/task-detail.adp 30 Jan 2004 10:57:08 -0000 1.9 +++ openacs-4/packages/simulation/www/simplay/task-detail.adp 4 Mar 2004 12:09:44 -0000 1.10 @@ -1,9 +1,28 @@ -+ You are doing a bulk response to @common_actions_count@ tasks. +
+ ++ Note: Ignoring @ignored_actions_count@ tasks that don't have the task + name "@action.pretty_name@". Please back up your browser if you + want to change the selection of tasks. +
+@action.description@
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.19 -r1.20 --- openacs-4/packages/simulation/www/simplay/task-detail.tcl 30 Jan 2004 11:23:25 -0000 1.19 +++ openacs-4/packages/simulation/www/simplay/task-detail.tcl 4 Mar 2004 12:09:44 -0000 1.20 @@ -2,31 +2,102 @@ Details for a task. If there is a recipient_role a message is created. If there is not recipient role we upload a document instead. } { - case_id:integer - role_id:integer - enabled_action_id:integer + {enabled_action_id:integer,multiple ""} + {enabled_action_ids ""} item_id:optional + {bulk_p 0} + {return_url ""} } -simulation::case::assert_user_may_play_role -case_id $case_id -role_id $role_id +# FIXME: I am exporting the enabled_action_id list as the string variable enabled_action_ids in +# the forms as I can't export multiples. Here I'm recreating the list again. This is convoluted. +if { ![empty_string_p $enabled_action_ids] } { + set enabled_action_id [split $enabled_action_ids] +} -workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action -set action_id $enabled_action(action_id) -simulation::action::get -action_id $action_id -array action +if { [llength $enabled_action_id] > 1 } { + set bulk_p 1 +} +if { !$bulk_p } { + workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action + + set action_id $enabled_action(action_id) + set case_id $enabled_action(case_id) + simulation::action::get -action_id $action_id -array action + set role_id $action(assigned_role_id) + + simulation::case::assert_user_may_play_role -case_id $case_id -role_id $action(assigned_role_id) + + set common_enabled_action_ids [list [list $enabled_action_id $case_id]] + + if { [empty_string_p $return_url] } { + set return_url [export_vars -base tasks { case_id role_id }] + } + +} else { + # Only admin users can neglect to provide case_id and role_id + permission::require_permission -object_id [ad_conn package_id] -privilege sim_adminplayer + + # If we are taking action on more than one task, extract the subset of the tasks that + # have the same action_id + set common_action_id "" + set common_enabled_action_ids [list] + set ignored_enabled_action_ids [list] + set task_list [db_list_of_lists select_tasks " + select wcea.enabled_action_id, + wcea.action_id, + wcea.case_id + from workflow_case_enabled_actions wcea + where wcea.enabled_action_id in ('[join $enabled_action_id "', '"]') + "] + foreach task $task_list { + set one_enabled_action_id [lindex $task 0] + set one_action_id [lindex $task 1] + set one_case_id [lindex $task 2] + + if { [empty_string_p $common_action_id] } { + set common_action_id $one_action_id + set case_id $one_case_id + } + + if { [string equal $common_action_id $one_action_id] } { + lappend common_enabled_action_ids [list $one_enabled_action_id $one_case_id] + } else { + lappend ignored_enabled_action_ids $one_enabled_action_id + } + } + + set common_actions_count [llength $common_enabled_action_ids] + set ignored_actions_count [llength $ignored_enabled_action_ids] + + set action_id $common_action_id + + simulation::action::get -action_id $action_id -array action + + if { [empty_string_p $return_url] } { + set return_url [export_vars -base tasks-bulk { {workflow_id $action(workflow_id)} }] + } +} + set page_title $action(pretty_name) set context [list [list . "SimPlay"] [list [export_vars -base case { case_id role_id }] "Case"] [list [export_vars -base tasks { case_id role_id }] "Tasks"] $page_title] +set documents_pre_form "" if { ![empty_string_p $action(recipients)] } { # We have recipient roles - use message form - if { ![empty_string_p $action(assigned_role_id)] } { - set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $action(assigned_role_id)] + if { !$bulk_p } { + if { ![empty_string_p $action(assigned_role_id)] } { + set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $action(assigned_role_id)] + } + } else { + set attachment_options {} } set form_id action - ad_form -name $form_id -edit_buttons { { Send ok } } -export { case_id role_id enabled_action_id } \ + ad_form -name $form_id -edit_buttons { { Send ok } } -export { case_id role_id {enabled_action_ids $enabled_action_id} bulk_p} \ -form { {pretty_name:text(inform) {label "Task"} @@ -77,27 +148,32 @@ set body_text [template::util::richtext::get_property "contents" $body] set body_mime_type [template::util::richtext::get_property "format" $body] - + db_transaction { - set entry_id [workflow::case::action::execute \ + foreach one_action $common_enabled_action_ids { + set enabled_action_id [lindex $one_action 0] + set case_id [lindex $one_action 1] + + set entry_id [workflow::case::action::execute \ -enabled_action_id $enabled_action_id \ -comment $body_text \ -comment_mime_type $body_mime_type] - foreach recipient_id $action(recipients) { - simulation::message::new \ - -from_role_id $action(assigned_role_id) \ - -to_role_id $recipient_id \ - -case_id $case_id \ - -subject $subject \ - -body $body_text \ - -body_mime_type $body_mime_type \ - -attachments $attachments \ - -entry_id $entry_id - } + foreach recipient_id $action(recipients) { + simulation::message::new \ + -from_role_id $action(assigned_role_id) \ + -to_role_id $recipient_id \ + -case_id $case_id \ + -subject $subject \ + -body $body_text \ + -body_mime_type $body_mime_type \ + -attachments $attachments \ + -entry_id $entry_id + } + } } - ad_returnredirect [export_vars -base tasks { case_id role_id }] + ad_returnredirect $return_url ad_script_abort } @@ -109,7 +185,7 @@ set form_id document - ad_form -name $form_id -export { case_id role_id workflow_id enabled_action_id } -html {enctype multipart/form-data} \ + ad_form -name $form_id -export { case_id role_id workflow_id {enabled_action_ids $enabled_action_id} bulk_p} -html {enctype multipart/form-data} \ -form [concat {{pretty_name:text(inform) {label "Task"}}} [simulation::ui::forms::document_upload::form_block]] \ -on_request { set pretty_name $action(pretty_name) @@ -118,19 +194,23 @@ } -on_submit { db_transaction { - set entry_id [workflow::case::action::execute \ + foreach one_action $common_enabled_action_ids { + set case_id [lindex $one_action 1] + + set entry_id [workflow::case::action::execute \ -case_id $case_id \ -action_id $action_id \ -comment "Document [lindex $document_file 0] uploaded" \ -comment_mime_type "text/plain"] - simulation::ui::forms::document_upload::insert_document \ - $case_id $role_id $item_id $document_file $title $entry_id + simulation::ui::forms::document_upload::insert_document \ + $case_id $action(assigned_role_id) $item_id $document_file $title $entry_id + } } - ad_returnredirect [export_vars -base tasks { case_id role_id }] + ad_returnredirect $return_url + ad_script_abort } set focus "document.document_file" } - Index: openacs-4/packages/simulation/www/simplay/tasks-bulk.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/tasks-bulk.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/simplay/tasks-bulk.adp 4 Mar 2004 12:09:44 -0000 1.1 @@ -0,0 +1,10 @@ ++ If you are using the respond button to respond to multiple tasks + then all checked tasks must share the same task name. +
\ No newline at end of file Index: openacs-4/packages/simulation/www/simplay/tasks-bulk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/tasks-bulk.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/simplay/tasks-bulk.tcl 4 Mar 2004 12:09:44 -0000 1.1 @@ -0,0 +1,16 @@ +ad_page_contract { + This page shows all tasks that an admin has in a certain simulation and + allows the admin to take action on the tasks in bulk. + + @author Peter Marklund +} { + workflow_id:integer + role_id:optional +} + +permission::require_permission -object_id [ad_conn package_id] -privilege sim_adminplayer + +simulation::template::get -workflow_id $workflow_id -array simulation + +set page_title "Your Tasks in Simulation $simulation(pretty_name)" +set context [list [list . "SimPlay"] $page_title]