Index: openacs-4/packages/simulation/lib/messages.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/messages.tcl,v diff -u -r1.21.2.1 -r1.21.2.2 --- openacs-4/packages/simulation/lib/messages.tcl 31 Oct 2006 10:13:02 -0000 1.21.2.1 +++ openacs-4/packages/simulation/lib/messages.tcl 31 Oct 2006 21:10:13 -0000 1.21.2.2 @@ -20,6 +20,15 @@ show_body_p { default_value 0 } + show_actions_p { + default_value 1 + } + deleted_p { + default_value 0 + } + direction { + default_value "both" + } } set package_id [ad_conn package_id] @@ -75,6 +84,26 @@ lappend extend body } +if { $deleted_p } { + lappend elements undelete + lappend elements { + link_url_col undelete_url + label {[_ simulation.Undelete]} + } + + lappend extend undelete + lappend extend undelete_url +} else { + lappend elements delete + lappend elements { + link_url_col delete_url + label {[_ simulation.Delete]} + } + + lappend extend delete + lappend extend delete_url +} + if { [exists_and_not_null case_id] } { set num_enabled_actions [db_string select_num_enabled_actions { select count(*) @@ -86,7 +115,7 @@ set complete_p 0 } -if { [string match $complete_p "0"] && [exists_and_not_null role_id] } { +if { [string match $complete_p "0"] && [exists_and_not_null role_id] && $show_actions_p } { set actions [list [_ simulation.Send_new_message] [export_vars -base message { case_id role_id }] {}] } else { set actions [list] @@ -141,12 +170,22 @@ sim_cases sc where cr.revision_id = sm.message_id and wc.case_id = sm.case_id - [ad_decode $role_id "" "" "and (sm.to_role_id = :role_id or sm.from_role_id = :role_id)"] + [ad_decode $role_id "" "" "and ( + [ad_decode $direction "in" "sm.to_role_id = :role_id" \ + "out" "sm.from_role_id = :role_id" \ + "sm.to_role_id = :role_id or sm.from_role_id = :role_id"] + )"] + and [ad_decode $deleted_p 1 "" "not"] exists ( + select 1 from sim_trash st where st.message_id = sm.message_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 $case_id "" "" "and wc.case_id = :case_id"] - [ad_decode $user_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)"] + [ad_decode $user_id "" "" "and exists (select 1 from workflow_case_role_user_map where case_id = wc.case_id and ( + [ad_decode $direction "in" "sm.to_role_id = role_id" \ + "out" "sm.from_role_id = role_id" \ + "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"] " { @@ -155,6 +194,16 @@ } else { 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 } }] } + + if { $deleted_p } { + set undelete_p $deleted_p + set undelete [_ simulation.Undelete] + set undelete_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message-delete" { message_id case_id role_id undelete_p}] + } else { + set delete [_ simulation.Delete] + set delete_url [export_vars -base "[apm_package_url_from_id $package_id]simplay/message-delete" { message_id case_id role_id }] + } + set creation_date_pretty [lc_time_fmt $creation_date_ansi "%x %X"] if { $show_body_p } { Index: openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql,v diff -u -r1.29.2.1 -r1.29.2.2 --- openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql 31 Oct 2006 10:13:02 -0000 1.29.2.1 +++ openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql 31 Oct 2006 21:10:13 -0000 1.29.2.2 @@ -95,12 +95,14 @@ comment on table sim_role_party_map is 'Each record defines a group of users to be cast into a role'; create table sim_tasks ( - task_id integer constraint sim_tasks_fk - references workflow_actions - on delete cascade - constraint sim_tasks_pk - primary key, - attachment_num integer default 0 + task_id integer constraint sim_tasks_fk + references workflow_actions + on delete cascade + constraint sim_tasks_pk + primary key, + attachment_num integer default 0, + default_text text, + default_text_mime_type varchar(200) ); comment on table sim_tasks is 'A 1-1 extension of workflow_actions. Each record is a task that a role must perform, possibly upon another role.'; @@ -202,3 +204,16 @@ comment on table sim_cases is 'The object behind a simulation case.'; +create table sim_trash ( + message_id integer constraint sim_trash_id_nn + not null + constraint sim_trash_id_fk + references sim_messages, + role_id integer constraint sim_trash_role_nn + not null, + case_id integer constraint sim_trash_case_nn + not null, + PRIMARY KEY (message_id, role_id, case_id) +); + +comment on table sim_trash is 'For storing trashed messages per role per case.'; \ No newline at end of file Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/simulation/sql/postgresql/upgrade/upgrade-1.0.0b5-1.1.0b1.sql'. Fisheye: No comparison available. Pass `N' to diff? 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.6 -r1.6.2.1 --- openacs-4/packages/simulation/tcl/message-procs.tcl 20 Apr 2004 21:12:23 -0000 1.6 +++ openacs-4/packages/simulation/tcl/message-procs.tcl 31 Oct 2006 21:10:13 -0000 1.6.2.1 @@ -144,3 +144,52 @@ and str.recipient = sm.from_role_id) ))" } + +ad_proc -public simulation::message::delete { + -message_id:required + -role_id:required + -case_id:required +} { + Set the status of a message to deleted. + + @return item_id of the deleted message +} { + return [delete_or_undelete -action "delete" -message_id $message_id -role_id $role_id -case_id $case_id] +} + +ad_proc -public simulation::message::undelete { + -message_id:required + -role_id:required + -case_id:required +} { + Set the status of a message to normal. + + @return item_id of the undeleted message +} { + return [delete_or_undelete -action "undelete" -message_id $message_id -role_id $role_id -case_id $case_id] +} + +ad_proc -private simulation::message::delete_or_undelete { + -message_id:required + -role_id:required + -case_id:required + {-action "delete"} +} { + Set the status of a message to either deleted or not deleted. + + @return item_id of the deleted/undeleted message +} { + db_transaction { + if {[string equal $action "delete"]} { + db_dml delete "insert into sim_trash values (:message_id, :role_id, :case_id)" + } else { + db_dml undelete " + delete from sim_trash + where message_id = :message_id + and role_id = :role_id + and case_id = :case_id" + } + } + + return $message_id +} \ No newline at end of file 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.16.2.1 -r1.16.2.2 --- openacs-4/packages/simulation/www/simplay/case.adp 31 Oct 2006 10:13:04 -0000 1.16.2.1 +++ openacs-4/packages/simulation/www/simplay/case.adp 31 Oct 2006 21:10:13 -0000 1.16.2.2 @@ -6,7 +6,7 @@