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.16 -r1.16.2.1 --- openacs-4/contrib/packages/simulation/lib/messages.tcl 12 Mar 2004 15:34:55 -0000 1.16 +++ openacs-4/contrib/packages/simulation/lib/messages.tcl 17 Mar 2004 08:31:41 -0000 1.16.2.1 @@ -115,8 +115,34 @@ workflow_cases wc, sim_cases sc where cr.revision_id = sm.message_id - and sm.entry_id is null and wc.case_id = sm.case_id + [ad_decode $role_id "" "" "and (sm.entry_id is null or not ( + -- The whole expression in the not parenthesis is true if there is an assigned action + -- responding to the message in which case the message shouldnt show up in the message list + + -- message is associated with an action that put us in the current state + sm.entry_id in (select max(wcl.entry_id) + from workflow_case_log wcl, + workflow_fsm_actions wfa, + workflow_case_fsm wcf, + sim_messagesx sm2 + where wcl.case_id = sm.case_id + and wcl.action_id = wfa.action_id + and wcf.case_id = wcl.case_id + and wfa.new_state = wcf.current_state + and sm2.entry_id = wcl.entry_id + and sm2.to_role_id = :role_id + ) + and + -- There is an assigned action with a recipient being sender of the message + exists (select 1 + from workflow_case_assigned_actions wcaa, + sim_task_recipients str + where wcaa.case_id = sm.case_id + and wcaa.role_id = :role_id + and str.task_id = wcaa.action_id + and str.recipient = sm.from_role_id) + ))"] [ad_decode $role_id "" "" "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 Index: openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/sim-template-tasks.tcl,v diff -u -r1.39.2.1 -r1.39.2.2 --- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 16 Mar 2004 16:16:18 -0000 1.39.2.1 +++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 17 Mar 2004 08:31:41 -0000 1.39.2.2 @@ -17,14 +17,6 @@ set package_id [ad_conn package_id] -switch $display_mode { - display {} - - edit { - set add_task_url [export_vars -base "[apm_package_url_from_id $package_id]jsimbuild/task-edit" { workflow_id } ] - } -} - ############################################################## # # tasks @@ -38,7 +30,7 @@ #------------------------------------------------------------- if { $display_mode == "edit"} { - set list_actions [list "Add a Task" [export_vars -base task-edit { workflow_id parent_action_id {return_url [ad_return_url] } }] {}] + set list_actions [list "Add a Task" [export_vars -base task-edit { workflow_id parent_action_id {return_url "[ad_return_url]\#tasks" } }] {}] } else { set list_actions [list] } @@ -76,14 +68,6 @@ } } -lappend elements copy { - hide_p {[ad_decode $display_mode edit 0 1]} - sub_class narrow - link_url_col copy_url - display_template { - Copy - } -} lappend elements name { label "
Name" @@ -103,6 +87,15 @@ link_url_col assigned_role_edit_url } +lappend elements copy { + hide_p {[ad_decode $display_mode edit 0 1]} + sub_class narrow + link_url_col copy_url + display_template { + Copy + } +} + lappend elements delete { sub_class narrow hide_p {[ad_decode $display_mode edit 0 1]} @@ -228,8 +221,8 @@ order by wa.sort_order " { incr counter - set edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id {return_url [ad_return_url]} }] - set view_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id {return_url [ad_return_url]}}] + set edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" -anchor tasks { action_id {return_url "[ad_return_url]\#tasks"} }] + set view_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" -anchor tasks { action_id {return_url "[ad_return_url]\#tasks"}}] set delete_url \ [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url "[ad_return_url]\#tasks"} }] set copy_url [export_vars -base task-copy { action_id {return_url "[ad_return_url]\#tasks"} }] Index: openacs-4/contrib/packages/simulation/tcl/template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/template-procs.tcl,v diff -u -r1.66.2.1 -r1.66.2.2 --- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 16 Mar 2004 16:16:18 -0000 1.66.2.1 +++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 17 Mar 2004 08:31:48 -0000 1.66.2.2 @@ -474,12 +474,13 @@ } } -ad_proc -public simulation::template::enroll_user { +ad_proc -public simulation::template::enroll_user { {-workflow_id:required} {-user_id:required} {-simulation_array ""} {-email ""} {-user_name ""} + {-admin:boolean} } { Enroll a user in a simulation. Sends out an email to the user for casting type open and group. Creates a SimPlay message notification for the user. @@ -525,22 +526,33 @@ -subject $subject\ -body $body } + + if { $admin_p } { + # Notify admin of all activity in the workflow. In particular this includes timed out tasks. + notification::request::new \ + -type_id [notification::type::get_type_id -short_name "workflow"] \ + -user_id $user_id \ + -object_id [ad_conn package_id] \ + -interval_id [notification::get_interval_id -name "instant"] \ + -delivery_method_id [notification::get_delivery_method_id -name "email"] + + } else { + # Sign up the user for email notification of received messages + notification::request::new \ + -type_id [notification::type::get_type_id -short_name [simulation::notification::message::type_short_name]] \ + -user_id $user_id \ + -object_id [ad_conn package_id] \ + -interval_id [notification::get_interval_id -name "instant"] \ + -delivery_method_id [notification::get_delivery_method_id -name "email"] - # Sign the user up for email notification of received messages - notification::request::new \ - -type_id [notification::type::get_type_id -short_name [simulation::notification::message::type_short_name]] \ - -user_id $user_id \ - -object_id [ad_conn package_id] \ - -interval_id [notification::get_interval_id -name "instant"] \ - -delivery_method_id [notification::get_delivery_method_id -name "email"] - - # Sign up the user for email notification of assigned tasks - notification::request::new \ - -type_id [notification::type::get_type_id -short_name "workflow_assignee"] \ - -user_id $user_id \ - -object_id [ad_conn package_id] \ - -interval_id [notification::get_interval_id -name "instant"] \ - -delivery_method_id [notification::get_delivery_method_id -name "email"] + # Sign up the user for email notification of assigned tasks + notification::request::new \ + -type_id [notification::type::get_type_id -short_name "workflow_assignee"] \ + -user_id $user_id \ + -object_id [ad_conn package_id] \ + -interval_id [notification::get_interval_id -name "instant"] \ + -delivery_method_id [notification::get_delivery_method_id -name "email"] + } } ad_proc -public simulation::template::enroll_and_invite_users { @@ -580,7 +592,13 @@ # Always enroll the admin creating the simulation set admin_user_id [ad_conn user_id] acs_user::get -user_id $admin_user_id -array admin_user - lappend enroll_user_list [list $admin_user_id $admin_user(email) $admin_user(name)] + simulation::template::enroll_user \ + -admin \ + -workflow_id $workflow_id \ + -user_id $admin_user_id \ + -simulation_array sim_template \ + -user_name $admin_user(name) \ + -email $admin_user(email) # Enroll users foreach user $enroll_user_list { @@ -982,8 +1000,6 @@ set row($role_short_name($role_id)) $assignees } - ns_log Notice "pm debug row = [array get row]" - # Do all the user-role assignments in the case workflow::case::role::assign \ -case_id $case_id \ Index: openacs-4/contrib/packages/simulation/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/index.adp,v diff -u -r1.30 -r1.30.2.1 --- openacs-4/contrib/packages/simulation/www/index.adp 15 Jan 2004 14:56:26 -0000 1.30 +++ openacs-4/contrib/packages/simulation/www/index.adp 17 Mar 2004 08:31:49 -0000 1.30.2.1 @@ -32,7 +32,7 @@ - Log in to see your active cases. + Log in to see your active cases.

Join a Simulation

Index: openacs-4/contrib/packages/simulation/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/index.tcl,v diff -u -r1.14 -r1.14.2.1 --- openacs-4/contrib/packages/simulation/www/index.tcl 12 Mar 2004 12:07:20 -0000 1.14 +++ openacs-4/contrib/packages/simulation/www/index.tcl 17 Mar 2004 08:31:49 -0000 1.14.2.1 @@ -11,6 +11,8 @@ set context "" set user_id [auth::get_user_id] +set login_url [ad_get_login_url -return] + set citybuild_p [permission::permission_p -object_id $package_id -privilege sim_object_create] set simbuild_p [permission::permission_p -object_id $package_id -privilege sim_template_read] set siminst_p [permission::permission_p -object_id $package_id -privilege sim_inst] Index: openacs-4/packages/simulation/lib/messages.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/messages.tcl,v diff -u -r1.16 -r1.16.2.1 --- openacs-4/packages/simulation/lib/messages.tcl 12 Mar 2004 15:34:55 -0000 1.16 +++ openacs-4/packages/simulation/lib/messages.tcl 17 Mar 2004 08:31:41 -0000 1.16.2.1 @@ -115,8 +115,34 @@ workflow_cases wc, sim_cases sc where cr.revision_id = sm.message_id - and sm.entry_id is null and wc.case_id = sm.case_id + [ad_decode $role_id "" "" "and (sm.entry_id is null or not ( + -- The whole expression in the not parenthesis is true if there is an assigned action + -- responding to the message in which case the message shouldnt show up in the message list + + -- message is associated with an action that put us in the current state + sm.entry_id in (select max(wcl.entry_id) + from workflow_case_log wcl, + workflow_fsm_actions wfa, + workflow_case_fsm wcf, + sim_messagesx sm2 + where wcl.case_id = sm.case_id + and wcl.action_id = wfa.action_id + and wcf.case_id = wcl.case_id + and wfa.new_state = wcf.current_state + and sm2.entry_id = wcl.entry_id + and sm2.to_role_id = :role_id + ) + and + -- There is an assigned action with a recipient being sender of the message + exists (select 1 + from workflow_case_assigned_actions wcaa, + sim_task_recipients str + where wcaa.case_id = sm.case_id + and wcaa.role_id = :role_id + and str.task_id = wcaa.action_id + and str.recipient = sm.from_role_id) + ))"] [ad_decode $role_id "" "" "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 Index: openacs-4/packages/simulation/lib/sim-template-tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/sim-template-tasks.tcl,v diff -u -r1.39.2.1 -r1.39.2.2 --- openacs-4/packages/simulation/lib/sim-template-tasks.tcl 16 Mar 2004 16:16:18 -0000 1.39.2.1 +++ openacs-4/packages/simulation/lib/sim-template-tasks.tcl 17 Mar 2004 08:31:41 -0000 1.39.2.2 @@ -17,14 +17,6 @@ set package_id [ad_conn package_id] -switch $display_mode { - display {} - - edit { - set add_task_url [export_vars -base "[apm_package_url_from_id $package_id]jsimbuild/task-edit" { workflow_id } ] - } -} - ############################################################## # # tasks @@ -38,7 +30,7 @@ #------------------------------------------------------------- if { $display_mode == "edit"} { - set list_actions [list "Add a Task" [export_vars -base task-edit { workflow_id parent_action_id {return_url [ad_return_url] } }] {}] + set list_actions [list "Add a Task" [export_vars -base task-edit { workflow_id parent_action_id {return_url "[ad_return_url]\#tasks" } }] {}] } else { set list_actions [list] } @@ -76,14 +68,6 @@ } } -lappend elements copy { - hide_p {[ad_decode $display_mode edit 0 1]} - sub_class narrow - link_url_col copy_url - display_template { - Copy - } -} lappend elements name { label "
Name" @@ -103,6 +87,15 @@ link_url_col assigned_role_edit_url } +lappend elements copy { + hide_p {[ad_decode $display_mode edit 0 1]} + sub_class narrow + link_url_col copy_url + display_template { + Copy + } +} + lappend elements delete { sub_class narrow hide_p {[ad_decode $display_mode edit 0 1]} @@ -228,8 +221,8 @@ order by wa.sort_order " { incr counter - set edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id {return_url [ad_return_url]} }] - set view_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" { action_id {return_url [ad_return_url]}}] + set edit_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" -anchor tasks { action_id {return_url "[ad_return_url]\#tasks"} }] + set view_url [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-edit" -anchor tasks { action_id {return_url "[ad_return_url]\#tasks"}}] set delete_url \ [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url "[ad_return_url]\#tasks"} }] set copy_url [export_vars -base task-copy { action_id {return_url "[ad_return_url]\#tasks"} }] Index: openacs-4/packages/simulation/tcl/template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/template-procs.tcl,v diff -u -r1.66.2.1 -r1.66.2.2 --- openacs-4/packages/simulation/tcl/template-procs.tcl 16 Mar 2004 16:16:18 -0000 1.66.2.1 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 17 Mar 2004 08:31:48 -0000 1.66.2.2 @@ -474,12 +474,13 @@ } } -ad_proc -public simulation::template::enroll_user { +ad_proc -public simulation::template::enroll_user { {-workflow_id:required} {-user_id:required} {-simulation_array ""} {-email ""} {-user_name ""} + {-admin:boolean} } { Enroll a user in a simulation. Sends out an email to the user for casting type open and group. Creates a SimPlay message notification for the user. @@ -525,22 +526,33 @@ -subject $subject\ -body $body } + + if { $admin_p } { + # Notify admin of all activity in the workflow. In particular this includes timed out tasks. + notification::request::new \ + -type_id [notification::type::get_type_id -short_name "workflow"] \ + -user_id $user_id \ + -object_id [ad_conn package_id] \ + -interval_id [notification::get_interval_id -name "instant"] \ + -delivery_method_id [notification::get_delivery_method_id -name "email"] + + } else { + # Sign up the user for email notification of received messages + notification::request::new \ + -type_id [notification::type::get_type_id -short_name [simulation::notification::message::type_short_name]] \ + -user_id $user_id \ + -object_id [ad_conn package_id] \ + -interval_id [notification::get_interval_id -name "instant"] \ + -delivery_method_id [notification::get_delivery_method_id -name "email"] - # Sign the user up for email notification of received messages - notification::request::new \ - -type_id [notification::type::get_type_id -short_name [simulation::notification::message::type_short_name]] \ - -user_id $user_id \ - -object_id [ad_conn package_id] \ - -interval_id [notification::get_interval_id -name "instant"] \ - -delivery_method_id [notification::get_delivery_method_id -name "email"] - - # Sign up the user for email notification of assigned tasks - notification::request::new \ - -type_id [notification::type::get_type_id -short_name "workflow_assignee"] \ - -user_id $user_id \ - -object_id [ad_conn package_id] \ - -interval_id [notification::get_interval_id -name "instant"] \ - -delivery_method_id [notification::get_delivery_method_id -name "email"] + # Sign up the user for email notification of assigned tasks + notification::request::new \ + -type_id [notification::type::get_type_id -short_name "workflow_assignee"] \ + -user_id $user_id \ + -object_id [ad_conn package_id] \ + -interval_id [notification::get_interval_id -name "instant"] \ + -delivery_method_id [notification::get_delivery_method_id -name "email"] + } } ad_proc -public simulation::template::enroll_and_invite_users { @@ -580,7 +592,13 @@ # Always enroll the admin creating the simulation set admin_user_id [ad_conn user_id] acs_user::get -user_id $admin_user_id -array admin_user - lappend enroll_user_list [list $admin_user_id $admin_user(email) $admin_user(name)] + simulation::template::enroll_user \ + -admin \ + -workflow_id $workflow_id \ + -user_id $admin_user_id \ + -simulation_array sim_template \ + -user_name $admin_user(name) \ + -email $admin_user(email) # Enroll users foreach user $enroll_user_list { @@ -982,8 +1000,6 @@ set row($role_short_name($role_id)) $assignees } - ns_log Notice "pm debug row = [array get row]" - # Do all the user-role assignments in the case workflow::case::role::assign \ -case_id $case_id \ Index: openacs-4/packages/simulation/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/index.adp,v diff -u -r1.30 -r1.30.2.1 --- openacs-4/packages/simulation/www/index.adp 15 Jan 2004 14:56:26 -0000 1.30 +++ openacs-4/packages/simulation/www/index.adp 17 Mar 2004 08:31:49 -0000 1.30.2.1 @@ -32,7 +32,7 @@ - Log in to see your active cases. + Log in to see your active cases.

Join a Simulation

Index: openacs-4/packages/simulation/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/index.tcl,v diff -u -r1.14 -r1.14.2.1 --- openacs-4/packages/simulation/www/index.tcl 12 Mar 2004 12:07:20 -0000 1.14 +++ openacs-4/packages/simulation/www/index.tcl 17 Mar 2004 08:31:49 -0000 1.14.2.1 @@ -11,6 +11,8 @@ set context "" set user_id [auth::get_user_id] +set login_url [ad_get_login_url -return] + set citybuild_p [permission::permission_p -object_id $package_id -privilege sim_object_create] set simbuild_p [permission::permission_p -object_id $package_id -privilege sim_template_read] set siminst_p [permission::permission_p -object_id $package_id -privilege sim_inst]