Index: openacs-4/packages/simulation/lib/messages.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/messages.tcl,v diff -u -N -r1.19 -r1.20 --- openacs-4/packages/simulation/lib/messages.tcl 29 Jun 2004 10:17:34 -0000 1.19 +++ openacs-4/packages/simulation/lib/messages.tcl 30 Nov 2004 21:09:00 -0000 1.20 @@ -75,7 +75,18 @@ lappend extend body } -if { [exists_and_not_null case_id] && [exists_and_not_null 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 + }] + set complete_p [expr $num_enabled_actions == 0] +} else { + set complete_p 0 +} + +if { [string match $complete_p "0"] && [exists_and_not_null role_id] } { set actions [list [_ simulation.Send_new_message] [export_vars -base message { case_id role_id }] {}] } else { set actions [list] @@ -96,19 +107,23 @@ w.pretty_name as sim_name, sm.creation_date, to_char(sm.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date_ansi, - (select scx.title + (select wr.pretty_name || ' (' || scx.title || ')' as from from sim_roles fr, sim_charactersx scx, - cr_items ci + cr_items ci, + workflow_roles wr where fr.role_id = sm.from_role_id + and fr.role_id = wr.role_id and scx.item_id = fr.character_id and ci.item_id = scx.item_id and ci.live_revision = scx.object_id) as from, - (select scx.title + (select wr.pretty_name || ' (' || scx.title || ')' as to from sim_roles tr, sim_charactersx scx, - cr_items ci + cr_items ci, + workflow_roles wr where tr.role_id = sm.to_role_id + and tr.role_id = wr.role_id and scx.item_id = tr.character_id and ci.item_id = scx.item_id and ci.live_revision = scx.object_id) as to, @@ -126,33 +141,6 @@ sim_cases sc where cr.revision_id = sm.message_id 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 @@ -172,4 +160,4 @@ if { $show_body_p } { set body [ad_html_text_convert -from $mime_type -to "text/plain" $content] } -} +} \ No newline at end of file