Index: openacs-4/contrib/packages/simulation/lib/cases.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/cases.tcl,v
diff -u -r1.12 -r1.13
--- openacs-4/contrib/packages/simulation/lib/cases.tcl 23 Jan 2004 11:11:28 -0000 1.12
+++ openacs-4/contrib/packages/simulation/lib/cases.tcl 23 Jan 2004 11:16:15 -0000 1.13
@@ -15,12 +15,10 @@
set elements {
pretty_name {
label "Simulation"
- orderby upper(w.pretty_name)
link_url_eval {[export_vars -base [ad_conn package_url]simplay/case { case_id role_id }]}
}
label {
label "Case"
- orderby upper(w.pretty_name)
}
role_pretty {
label "Role"
@@ -68,5 +66,5 @@
and wc.case_id = wcrpm.case_id
and sc.sim_case_id = wc.object_id
and w.workflow_id = wc.workflow_id
-[template::list::orderby_clause -orderby -name "cases"]
+ order by w.pretty_name, sc.label
"
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.31 -r1.32
--- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 13 Jan 2004 12:35:53 -0000 1.31
+++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl 23 Jan 2004 11:16:15 -0000 1.32
@@ -77,9 +77,9 @@
link_url_col assigned_role_edit_url
}
-lappend elements recipient_name {
- label "
Recipient"
- link_url_col recipient_role_edit_url
+lappend elements recipient_count {
+ label "
Number of recipients"
+ html { align center } \
}
lappend elements task_type {
@@ -89,7 +89,7 @@
@tasks.child_workflow_pretty@
- Message
+ Message
Document
}
@@ -162,7 +162,7 @@
#-------------------------------------------------------------
set extend [list]
-lappend extend edit_url view_url delete_url assigned_role_edit_url recipient_role_edit_url child_workflow_url up_url down_url
+lappend extend edit_url view_url delete_url assigned_role_edit_url child_workflow_url up_url down_url
foreach state_id $states {
lappend extend state_$state_id
@@ -193,13 +193,13 @@
select wa.action_id,
wa.pretty_name,
wa.assigned_role,
- st.recipient as recipient_role,
+ (select count(*)
+ from sim_task_recipients str
+ where str.task_id = wa.action_id
+ ) as recipient_count,
(select pretty_name
from workflow_roles
where role_id = wa.assigned_role) as assigned_name,
- (select pretty_name
- from workflow_roles
- where role_id = st.recipient) as recipient_name,
wa.sort_order,
wa.always_enabled_p,
wfa.new_state,
@@ -211,7 +211,6 @@
from workflows
where workflow_id = wa.child_workflow_id) as child_workflow_pretty
from workflow_actions wa left outer join
- sim_tasks st on (st.task_id = wa.action_id) left outer join
workflow_fsm_actions wfa on (wfa.action_id = wa.action_id)
where wa.workflow_id = :workflow_id
and not exists (select 1
@@ -228,8 +227,6 @@
set assigned_role_edit_url \
[export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { { role_id $assigned_role } }]
- set recipient_role_edit_url \
- [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { { role_id $recipient_role } }]
set child_workflow_url \
[export_vars -base "[apm_package_url_from_id $package_id]simbuild/template-edit" { { workflow_id $child_workflow_id } }]
Index: openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/sql/postgresql/Attic/simulation-tables-create.sql,v
diff -u -r1.22 -r1.23
--- openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-create.sql 19 Jan 2004 17:10:31 -0000 1.22
+++ openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-create.sql 23 Jan 2004 11:16:15 -0000 1.23
@@ -87,14 +87,24 @@
on delete cascade
constraint sim_tasks_pk
primary key,
- recipient integer constraint sim_tasks_recipient_fk
- references workflow_roles
- on delete cascade,
attachment_num integer default 0
);
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.';
+create table sim_task_recipients (
+ task_id integer constraint sim_task_recipients_tid_fk
+ references sim_tasks(task_id)
+ on delete cascade,
+ recipient integer constraint sim_task_recipients_rid_fk
+ references workflow_roles(role_id)
+ on delete cascade,
+ constraint sim_task_recipients_pk
+ primary key(task_id, recipient)
+);
+
+comment on table sim_task_recipients is 'Each record is a recipient for a task. This table allows each task to have 0 or more recipients';
+
create table sim_task_object_map (
task_id integer constraint stom_fk
references workflow_actions
Index: openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/sql/postgresql/Attic/simulation-tables-drop.sql,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-drop.sql 14 Jan 2004 10:18:10 -0000 1.2
+++ openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-drop.sql 23 Jan 2004 11:16:15 -0000 1.3
@@ -4,6 +4,7 @@
--drop independent tables
drop table sim_party_sim_map;
+drop table sim_task_recipients;
drop table sim_tasks;
drop table sim_role_party_map;
drop table sim_roles;
Index: openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/sim-action-procs.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl 13 Jan 2004 12:37:12 -0000 1.2
+++ openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl 23 Jan 2004 11:16:15 -0000 1.3
@@ -73,20 +73,24 @@
# Parse column values
switch $operation {
insert - update {
- # Special-case: array entry recipient_role (short_name) and recipient (state_id) -- DB column is recipient (state_id)
- if { [info exists row(recipient_role)] } {
- if { [info exists row(role)] } {
- error "You cannot supply both recipient_role (takes short_name) and recipient (takes state_id)"
+ # Special-case: array entry recipient_roles (short_name) and recipients (role_id)
+ if { [info exists row(recipient_roles)] } {
+ if { [info exists row(recipients)] } {
+ error "You cannot supply both recipient_roles (takes short_name) and recipient (takes role_id)"
}
- if { [empty_string_p $row(recipient_role)] } {
- set row(recipient) [db_null]
+ if { [empty_string_p $row(recipient_roles)] } {
+ set row(recipients) [db_null]
} else {
# Get role_id by short_name
- set row(recipient) [workflow::role::get_id \
- -workflow_id $workflow_id \
- -short_name $row(recipient_role)]
+ foreach recipient_short_name $row(recipient_roles) {
+ lappend row(recipients) [workflow::role::get_id \
+ -workflow_id $workflow_id \
+ -short_name $recipient_short_name]
+ }
}
- unset row(recipient_role)
+ set local_relation(recipients) $row(recipients)
+ unset row(recipient_roles)
+ unset row(recipients)
}
set update_clauses [list]
@@ -95,7 +99,7 @@
# Handle columns in the sim_tasks table
foreach attr {
- recipient attachment_num
+ attachment_num
} {
if { [info exists row($attr)] } {
set varname attr_$attr
@@ -154,6 +158,24 @@
# Handled through cascading delete
}
}
+
+ if {[string equal $operation "update"] || [string equal $operation "insert"]} {
+ if { [info exists local_relation(recipients)] } {
+ db_dml delete_old_recipients {
+ delete from sim_task_recipients
+ where task_id = :action_id
+ }
+
+ foreach recipient_id $local_relation(recipients) {
+ db_dml insert_recipient {
+ insert into sim_task_recipients
+ (task_id, recipient)
+ values
+ (:action_id, :recipient_id)
+ }
+ }
+ }
+ }
if { !$internal_p } {
workflow::definition_changed_handler -workflow_id $workflow_id
@@ -185,15 +207,25 @@
}
db_1row select_action {
- select recipient,
- (select short_name
- from workflow_roles
- where role_id = recipient) as recipient_role,
- attachment_num
+ select attachment_num
from sim_tasks
where task_id = :action_id
} -column_array local_row
+ set local_row(recipients) {}
+ set local_row(recipient_roles) {}
+ db_foreach recipient_roles {
+ select wr.role_id,
+ wr.short_name
+ from sim_task_recipients str,
+ workflow_roles wr
+ where str.task_id = :action_id
+ and str.recipient = wr.role_id
+ } {
+ lappend local_row(recipients) $role_id
+ lappend local_row(recipient_roles) $short_name
+ }
+
array set row [array get local_row]
}
@@ -228,7 +260,7 @@
# Get local spec, remove unwanted entries
get -action_id $action_id -array local_row -local_only
- array unset local_row recipient
+ array unset local_row recipients
# Copy local stuff in over the parent stuff
array set row [array get local_row]
Index: openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/sim-role-procs.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl 21 Jan 2004 15:55:36 -0000 1.5
+++ openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl 23 Jan 2004 11:16:15 -0000 1.6
@@ -77,7 +77,7 @@
set insert_names [list]
set insert_values [list]
- # Handle columns in the sim_tasks table
+ # Handle columns in the sim_roles table
foreach attr {
character_id users_per_case
} {
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.58 -r1.59
--- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 22 Jan 2004 12:49:45 -0000 1.58
+++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 23 Jan 2004 11:16:15 -0000 1.59
@@ -69,7 +69,7 @@
set insert_names [list]
set insert_values [list]
- # Handle columns in the sim_tasks table
+ # Handle columns in the sim_simulations table
foreach attr {
sim_type suggested_duration
enroll_type casting_type
@@ -146,7 +146,7 @@
-workflow_id $workflow_id \
-array row]
- # sim_tasks row
+ # sim_simulations row
switch $operation {
insert {
lappend insert_names simulation_id
Index: openacs-4/contrib/packages/simulation/www/simbuild/role-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/role-delete.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/contrib/packages/simulation/www/simbuild/role-delete.tcl 16 Dec 2003 18:34:00 -0000 1.3
+++ openacs-4/contrib/packages/simulation/www/simbuild/role-delete.tcl 23 Jan 2004 11:16:15 -0000 1.4
@@ -12,12 +12,9 @@
set package_id [ad_conn package_id]
set num_of_tasks [db_string task_count "
select count(*)
- from workflow_actions wa,
- sim_tasks st
- where st.task_id = wa.action_id
- and wa.assigned_role = :role_id
- or st.recipient = :role_id
- "
+ from workflow_actions wa
+ where wa.assigned_role = :role_id
+"
]
workflow::role::get -role_id $role_id -array role_array
set name $role_array(pretty_name)
Index: openacs-4/contrib/packages/simulation/www/simbuild/task-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/task-edit.tcl,v
diff -u -r1.25 -r1.26
--- openacs-4/contrib/packages/simulation/www/simbuild/task-edit.tcl 12 Jan 2004 10:58:37 -0000 1.25
+++ openacs-4/contrib/packages/simulation/www/simbuild/task-edit.tcl 23 Jan 2004 11:16:15 -0000 1.26
@@ -33,7 +33,7 @@
set task_type "workflow"
} else {
# Message tasks have a recipient; upload document tasks ("normal") have no recipient
- if { ![empty_string_p $task_array(recipient_role)] } {
+ if { ![empty_string_p $task_array(recipient_roles)] } {
set task_type "message"
} else {
set task_type "normal"
@@ -104,9 +104,9 @@
{label "Assignee"}
{options $role_options_with_null}
}
- {recipient_role:text(select),optional
- {label "Recipient"}
- {options $role_options_with_null}
+ {recipient_roles:text(checkbox),optional,multiple
+ {label "Recipients"}
+ {options $role_options}
}
{child_workflow_id:integer(select),optional
{label "Child workflow"}
@@ -177,27 +177,27 @@
foreach elm {
pretty_name pretty_past_tense new_state_id
- assigned_role recipient_role
+ assigned_role recipient_roles
attachment_num
child_workflow_id
} {
set $elm $task_array($elm)
}
-
+
switch $task_type {
message {
element set_properties task assigned_role -widget select
- element set_properties task recipient_role -widget select
+ element set_properties task recipient_roles -widget checkbox
element set_properties task child_workflow_id -widget hidden
}
normal {
element set_properties task assigned_role -widget select
- element set_properties task recipient_role -widget hidden
+ element set_properties task recipient_roles -widget hidden
element set_properties task child_workflow_id -widget hidden
}
workflow {
element set_properties task assigned_role -widget hidden
- element set_properties task recipient_role -widget hidden
+ element set_properties task recipient_roles -widget hidden
element set_properties task child_workflow_id -widget select
foreach { child_short_name elm } $task_array(child_role_map) {
@@ -212,28 +212,28 @@
set task_type "message"
element set_properties task child_workflow_id -widget hidden
-} -on_refresh {
+} -on_refresh {
switch $task_type {
message {
element set_properties task assigned_role -widget select
- element set_properties task recipient_role -widget select
+ element set_properties task recipient_roles -widget checkbox
element set_properties task child_workflow_id -widget hidden
}
normal {
element set_properties task assigned_role -widget select
- element set_properties task recipient_role -widget hidden
+ element set_properties task recipient_roles -widget hidden
element set_properties task child_workflow_id -widget hidden
}
workflow {
element set_properties task assigned_role -widget hidden
- element set_properties task recipient_role -widget hidden
+ element set_properties task recipient_roles -widget hidden
element set_properties task child_workflow_id -widget select
}
}
set focus {}
} -on_submit {
-
+
set description_mime_type [template::util::richtext::get_property format $description]
set description [template::util::richtext::get_property contents $description]
@@ -244,11 +244,11 @@
set child_workflow_id {}
}
normal {
- set recipient_role {}
+ set recipient_roles {}
set child_workflow_id {}
}
workflow {
- set recipient_role {}
+ set recipient_roles {}
# we have:
# element parent_role__asker = lawyer
@@ -270,7 +270,7 @@
foreach elm {
pretty_name pretty_past_tense assigned_role description description_mime_type
new_state_id
- recipient_role attachment_num
+ recipient_roles attachment_num
child_workflow_id child_role_map
} {
set row($elm) [set $elm]
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.13 -r1.14
--- openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl 22 Jan 2004 15:47:23 -0000 1.13
+++ openacs-4/contrib/packages/simulation/www/simplay/task-detail.tcl 23 Jan 2004 11:16:15 -0000 1.14
@@ -17,10 +17,10 @@
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 action(recipient_role) ""
+set action(recipients) [list 110 111]
-if { ![empty_string_p $action(recipient_role)] } {
- # We have a recipient role - use message 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)]
@@ -43,7 +43,7 @@
{sender_name:text(inform),optional
{label "From"}
}
- {recipient_name:text(inform),optional
+ {recipient_names:text(inform),optional
{label "To"}
}
{subject:text
@@ -80,9 +80,12 @@
append documents "$object_title
"
}
- if { ![empty_string_p $action(recipient)] } {
- set recipient_name [simulation::role::get_element -role_id $action(recipient) -element pretty_name]
+ set recipient_list [list]
+ foreach recipient_id $action(recipients) {
+ lappend recipient_list [simulation::role::get_element -role_id $recipient_id -element pretty_name]
}
+ set recipient_names [join $recipient_list ", "]
+
if { ![empty_string_p $action(assigned_role_id)] } {
simulation::role::get -role_id $action(assigned_role_id) -array sender_role
set sender_name $sender_role(pretty_name)
@@ -99,15 +102,17 @@
-action_id $action_id \
-comment $body_text \
-comment_mime_type $body_mime_type
-
- simulation::message::new \
- -from_role_id $action(assigned_role_id) \
- -to_role_id $action(recipient) \
- -case_id $case_id \
- -subject $subject \
- -body $body_text \
- -body_mime_type $body_mime_type \
- -attachments $attachments
+
+ 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
+ }
}
ad_returnredirect [export_vars -base tasks { case_id role_id }]
@@ -116,7 +121,7 @@
set focus "action.subject"
} else {
- # No recipient role - use upload document form
+ # No recipient roles - use upload document form
set workflow_id [workflow::case::get_element -case_id $case_id -element workflow_id]
Index: openacs-4/packages/simulation/lib/cases.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/cases.tcl,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/simulation/lib/cases.tcl 23 Jan 2004 11:11:28 -0000 1.12
+++ openacs-4/packages/simulation/lib/cases.tcl 23 Jan 2004 11:16:15 -0000 1.13
@@ -15,12 +15,10 @@
set elements {
pretty_name {
label "Simulation"
- orderby upper(w.pretty_name)
link_url_eval {[export_vars -base [ad_conn package_url]simplay/case { case_id role_id }]}
}
label {
label "Case"
- orderby upper(w.pretty_name)
}
role_pretty {
label "Role"
@@ -68,5 +66,5 @@
and wc.case_id = wcrpm.case_id
and sc.sim_case_id = wc.object_id
and w.workflow_id = wc.workflow_id
-[template::list::orderby_clause -orderby -name "cases"]
+ order by w.pretty_name, sc.label
"
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.31 -r1.32
--- openacs-4/packages/simulation/lib/sim-template-tasks.tcl 13 Jan 2004 12:35:53 -0000 1.31
+++ openacs-4/packages/simulation/lib/sim-template-tasks.tcl 23 Jan 2004 11:16:15 -0000 1.32
@@ -77,9 +77,9 @@
link_url_col assigned_role_edit_url
}
-lappend elements recipient_name {
- label "
Recipient"
- link_url_col recipient_role_edit_url
+lappend elements recipient_count {
+ label "
Number of recipients"
+ html { align center } \
}
lappend elements task_type {
@@ -89,7 +89,7 @@
@tasks.child_workflow_pretty@
- Message
+ Message
Document
}
@@ -162,7 +162,7 @@
#-------------------------------------------------------------
set extend [list]
-lappend extend edit_url view_url delete_url assigned_role_edit_url recipient_role_edit_url child_workflow_url up_url down_url
+lappend extend edit_url view_url delete_url assigned_role_edit_url child_workflow_url up_url down_url
foreach state_id $states {
lappend extend state_$state_id
@@ -193,13 +193,13 @@
select wa.action_id,
wa.pretty_name,
wa.assigned_role,
- st.recipient as recipient_role,
+ (select count(*)
+ from sim_task_recipients str
+ where str.task_id = wa.action_id
+ ) as recipient_count,
(select pretty_name
from workflow_roles
where role_id = wa.assigned_role) as assigned_name,
- (select pretty_name
- from workflow_roles
- where role_id = st.recipient) as recipient_name,
wa.sort_order,
wa.always_enabled_p,
wfa.new_state,
@@ -211,7 +211,6 @@
from workflows
where workflow_id = wa.child_workflow_id) as child_workflow_pretty
from workflow_actions wa left outer join
- sim_tasks st on (st.task_id = wa.action_id) left outer join
workflow_fsm_actions wfa on (wfa.action_id = wa.action_id)
where wa.workflow_id = :workflow_id
and not exists (select 1
@@ -228,8 +227,6 @@
set assigned_role_edit_url \
[export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { { role_id $assigned_role } }]
- set recipient_role_edit_url \
- [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { { role_id $recipient_role } }]
set child_workflow_url \
[export_vars -base "[apm_package_url_from_id $package_id]simbuild/template-edit" { { workflow_id $child_workflow_id } }]
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.22 -r1.23
--- openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql 19 Jan 2004 17:10:31 -0000 1.22
+++ openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql 23 Jan 2004 11:16:15 -0000 1.23
@@ -87,14 +87,24 @@
on delete cascade
constraint sim_tasks_pk
primary key,
- recipient integer constraint sim_tasks_recipient_fk
- references workflow_roles
- on delete cascade,
attachment_num integer default 0
);
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.';
+create table sim_task_recipients (
+ task_id integer constraint sim_task_recipients_tid_fk
+ references sim_tasks(task_id)
+ on delete cascade,
+ recipient integer constraint sim_task_recipients_rid_fk
+ references workflow_roles(role_id)
+ on delete cascade,
+ constraint sim_task_recipients_pk
+ primary key(task_id, recipient)
+);
+
+comment on table sim_task_recipients is 'Each record is a recipient for a task. This table allows each task to have 0 or more recipients';
+
create table sim_task_object_map (
task_id integer constraint stom_fk
references workflow_actions
Index: openacs-4/packages/simulation/sql/postgresql/simulation-tables-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/sql/postgresql/simulation-tables-drop.sql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/simulation/sql/postgresql/simulation-tables-drop.sql 14 Jan 2004 10:18:10 -0000 1.2
+++ openacs-4/packages/simulation/sql/postgresql/simulation-tables-drop.sql 23 Jan 2004 11:16:15 -0000 1.3
@@ -4,6 +4,7 @@
--drop independent tables
drop table sim_party_sim_map;
+drop table sim_task_recipients;
drop table sim_tasks;
drop table sim_role_party_map;
drop table sim_roles;
Index: openacs-4/packages/simulation/tcl/sim-action-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/sim-action-procs.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/simulation/tcl/sim-action-procs.tcl 13 Jan 2004 12:37:12 -0000 1.2
+++ openacs-4/packages/simulation/tcl/sim-action-procs.tcl 23 Jan 2004 11:16:15 -0000 1.3
@@ -73,20 +73,24 @@
# Parse column values
switch $operation {
insert - update {
- # Special-case: array entry recipient_role (short_name) and recipient (state_id) -- DB column is recipient (state_id)
- if { [info exists row(recipient_role)] } {
- if { [info exists row(role)] } {
- error "You cannot supply both recipient_role (takes short_name) and recipient (takes state_id)"
+ # Special-case: array entry recipient_roles (short_name) and recipients (role_id)
+ if { [info exists row(recipient_roles)] } {
+ if { [info exists row(recipients)] } {
+ error "You cannot supply both recipient_roles (takes short_name) and recipient (takes role_id)"
}
- if { [empty_string_p $row(recipient_role)] } {
- set row(recipient) [db_null]
+ if { [empty_string_p $row(recipient_roles)] } {
+ set row(recipients) [db_null]
} else {
# Get role_id by short_name
- set row(recipient) [workflow::role::get_id \
- -workflow_id $workflow_id \
- -short_name $row(recipient_role)]
+ foreach recipient_short_name $row(recipient_roles) {
+ lappend row(recipients) [workflow::role::get_id \
+ -workflow_id $workflow_id \
+ -short_name $recipient_short_name]
+ }
}
- unset row(recipient_role)
+ set local_relation(recipients) $row(recipients)
+ unset row(recipient_roles)
+ unset row(recipients)
}
set update_clauses [list]
@@ -95,7 +99,7 @@
# Handle columns in the sim_tasks table
foreach attr {
- recipient attachment_num
+ attachment_num
} {
if { [info exists row($attr)] } {
set varname attr_$attr
@@ -154,6 +158,24 @@
# Handled through cascading delete
}
}
+
+ if {[string equal $operation "update"] || [string equal $operation "insert"]} {
+ if { [info exists local_relation(recipients)] } {
+ db_dml delete_old_recipients {
+ delete from sim_task_recipients
+ where task_id = :action_id
+ }
+
+ foreach recipient_id $local_relation(recipients) {
+ db_dml insert_recipient {
+ insert into sim_task_recipients
+ (task_id, recipient)
+ values
+ (:action_id, :recipient_id)
+ }
+ }
+ }
+ }
if { !$internal_p } {
workflow::definition_changed_handler -workflow_id $workflow_id
@@ -185,15 +207,25 @@
}
db_1row select_action {
- select recipient,
- (select short_name
- from workflow_roles
- where role_id = recipient) as recipient_role,
- attachment_num
+ select attachment_num
from sim_tasks
where task_id = :action_id
} -column_array local_row
+ set local_row(recipients) {}
+ set local_row(recipient_roles) {}
+ db_foreach recipient_roles {
+ select wr.role_id,
+ wr.short_name
+ from sim_task_recipients str,
+ workflow_roles wr
+ where str.task_id = :action_id
+ and str.recipient = wr.role_id
+ } {
+ lappend local_row(recipients) $role_id
+ lappend local_row(recipient_roles) $short_name
+ }
+
array set row [array get local_row]
}
@@ -228,7 +260,7 @@
# Get local spec, remove unwanted entries
get -action_id $action_id -array local_row -local_only
- array unset local_row recipient
+ array unset local_row recipients
# Copy local stuff in over the parent stuff
array set row [array get local_row]
Index: openacs-4/packages/simulation/tcl/sim-role-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/sim-role-procs.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/simulation/tcl/sim-role-procs.tcl 21 Jan 2004 15:55:36 -0000 1.5
+++ openacs-4/packages/simulation/tcl/sim-role-procs.tcl 23 Jan 2004 11:16:15 -0000 1.6
@@ -77,7 +77,7 @@
set insert_names [list]
set insert_values [list]
- # Handle columns in the sim_tasks table
+ # Handle columns in the sim_roles table
foreach attr {
character_id users_per_case
} {
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.58 -r1.59
--- openacs-4/packages/simulation/tcl/template-procs.tcl 22 Jan 2004 12:49:45 -0000 1.58
+++ openacs-4/packages/simulation/tcl/template-procs.tcl 23 Jan 2004 11:16:15 -0000 1.59
@@ -69,7 +69,7 @@
set insert_names [list]
set insert_values [list]
- # Handle columns in the sim_tasks table
+ # Handle columns in the sim_simulations table
foreach attr {
sim_type suggested_duration
enroll_type casting_type
@@ -146,7 +146,7 @@
-workflow_id $workflow_id \
-array row]
- # sim_tasks row
+ # sim_simulations row
switch $operation {
insert {
lappend insert_names simulation_id
Index: openacs-4/packages/simulation/www/simbuild/role-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/role-delete.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/simulation/www/simbuild/role-delete.tcl 16 Dec 2003 18:34:00 -0000 1.3
+++ openacs-4/packages/simulation/www/simbuild/role-delete.tcl 23 Jan 2004 11:16:15 -0000 1.4
@@ -12,12 +12,9 @@
set package_id [ad_conn package_id]
set num_of_tasks [db_string task_count "
select count(*)
- from workflow_actions wa,
- sim_tasks st
- where st.task_id = wa.action_id
- and wa.assigned_role = :role_id
- or st.recipient = :role_id
- "
+ from workflow_actions wa
+ where wa.assigned_role = :role_id
+"
]
workflow::role::get -role_id $role_id -array role_array
set name $role_array(pretty_name)
Index: openacs-4/packages/simulation/www/simbuild/task-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/task-edit.tcl,v
diff -u -r1.25 -r1.26
--- openacs-4/packages/simulation/www/simbuild/task-edit.tcl 12 Jan 2004 10:58:37 -0000 1.25
+++ openacs-4/packages/simulation/www/simbuild/task-edit.tcl 23 Jan 2004 11:16:15 -0000 1.26
@@ -33,7 +33,7 @@
set task_type "workflow"
} else {
# Message tasks have a recipient; upload document tasks ("normal") have no recipient
- if { ![empty_string_p $task_array(recipient_role)] } {
+ if { ![empty_string_p $task_array(recipient_roles)] } {
set task_type "message"
} else {
set task_type "normal"
@@ -104,9 +104,9 @@
{label "Assignee"}
{options $role_options_with_null}
}
- {recipient_role:text(select),optional
- {label "Recipient"}
- {options $role_options_with_null}
+ {recipient_roles:text(checkbox),optional,multiple
+ {label "Recipients"}
+ {options $role_options}
}
{child_workflow_id:integer(select),optional
{label "Child workflow"}
@@ -177,27 +177,27 @@
foreach elm {
pretty_name pretty_past_tense new_state_id
- assigned_role recipient_role
+ assigned_role recipient_roles
attachment_num
child_workflow_id
} {
set $elm $task_array($elm)
}
-
+
switch $task_type {
message {
element set_properties task assigned_role -widget select
- element set_properties task recipient_role -widget select
+ element set_properties task recipient_roles -widget checkbox
element set_properties task child_workflow_id -widget hidden
}
normal {
element set_properties task assigned_role -widget select
- element set_properties task recipient_role -widget hidden
+ element set_properties task recipient_roles -widget hidden
element set_properties task child_workflow_id -widget hidden
}
workflow {
element set_properties task assigned_role -widget hidden
- element set_properties task recipient_role -widget hidden
+ element set_properties task recipient_roles -widget hidden
element set_properties task child_workflow_id -widget select
foreach { child_short_name elm } $task_array(child_role_map) {
@@ -212,28 +212,28 @@
set task_type "message"
element set_properties task child_workflow_id -widget hidden
-} -on_refresh {
+} -on_refresh {
switch $task_type {
message {
element set_properties task assigned_role -widget select
- element set_properties task recipient_role -widget select
+ element set_properties task recipient_roles -widget checkbox
element set_properties task child_workflow_id -widget hidden
}
normal {
element set_properties task assigned_role -widget select
- element set_properties task recipient_role -widget hidden
+ element set_properties task recipient_roles -widget hidden
element set_properties task child_workflow_id -widget hidden
}
workflow {
element set_properties task assigned_role -widget hidden
- element set_properties task recipient_role -widget hidden
+ element set_properties task recipient_roles -widget hidden
element set_properties task child_workflow_id -widget select
}
}
set focus {}
} -on_submit {
-
+
set description_mime_type [template::util::richtext::get_property format $description]
set description [template::util::richtext::get_property contents $description]
@@ -244,11 +244,11 @@
set child_workflow_id {}
}
normal {
- set recipient_role {}
+ set recipient_roles {}
set child_workflow_id {}
}
workflow {
- set recipient_role {}
+ set recipient_roles {}
# we have:
# element parent_role__asker = lawyer
@@ -270,7 +270,7 @@
foreach elm {
pretty_name pretty_past_tense assigned_role description description_mime_type
new_state_id
- recipient_role attachment_num
+ recipient_roles attachment_num
child_workflow_id child_role_map
} {
set row($elm) [set $elm]
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.13 -r1.14
--- openacs-4/packages/simulation/www/simplay/task-detail.tcl 22 Jan 2004 15:47:23 -0000 1.13
+++ openacs-4/packages/simulation/www/simplay/task-detail.tcl 23 Jan 2004 11:16:15 -0000 1.14
@@ -17,10 +17,10 @@
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 action(recipient_role) ""
+set action(recipients) [list 110 111]
-if { ![empty_string_p $action(recipient_role)] } {
- # We have a recipient role - use message 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)]
@@ -43,7 +43,7 @@
{sender_name:text(inform),optional
{label "From"}
}
- {recipient_name:text(inform),optional
+ {recipient_names:text(inform),optional
{label "To"}
}
{subject:text
@@ -80,9 +80,12 @@
append documents "$object_title
"
}
- if { ![empty_string_p $action(recipient)] } {
- set recipient_name [simulation::role::get_element -role_id $action(recipient) -element pretty_name]
+ set recipient_list [list]
+ foreach recipient_id $action(recipients) {
+ lappend recipient_list [simulation::role::get_element -role_id $recipient_id -element pretty_name]
}
+ set recipient_names [join $recipient_list ", "]
+
if { ![empty_string_p $action(assigned_role_id)] } {
simulation::role::get -role_id $action(assigned_role_id) -array sender_role
set sender_name $sender_role(pretty_name)
@@ -99,15 +102,17 @@
-action_id $action_id \
-comment $body_text \
-comment_mime_type $body_mime_type
-
- simulation::message::new \
- -from_role_id $action(assigned_role_id) \
- -to_role_id $action(recipient) \
- -case_id $case_id \
- -subject $subject \
- -body $body_text \
- -body_mime_type $body_mime_type \
- -attachments $attachments
+
+ 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
+ }
}
ad_returnredirect [export_vars -base tasks { case_id role_id }]
@@ -116,7 +121,7 @@
set focus "action.subject"
} else {
- # No recipient role - use upload document form
+ # No recipient roles - use upload document form
set workflow_id [workflow::case::get_element -case_id $case_id -element workflow_id]