Index: openacs-4/contrib/packages/simulation/simulation.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/Attic/simulation.info,v
diff -u -r1.12 -r1.12.2.1
--- openacs-4/contrib/packages/simulation/simulation.info	4 Mar 2004 16:23:18 -0000	1.12
+++ openacs-4/contrib/packages/simulation/simulation.info	16 Mar 2004 16:16:17 -0000	1.12.2.1
@@ -8,7 +8,7 @@
     <singleton-p>f</singleton-p>
     <auto-mount>simulation</auto-mount>
 
-    <version name="1.0.0b1" url="http://openacs.org/repository/download/apm/simulation-1.0.0b1.apm">
+    <version name="1.0.0b2" url="http://openacs.org/repository/download/apm/simulation-1.0.0b2.apm">
         <owner url="mailto:team@collaboraid.biz">Collaboraid ApS</owner>
         <summary>Workflow-based task simulator.  Build scenario
         templates in which various roles must complete tasks such as
@@ -18,9 +18,9 @@
         www.rechtenonline.nl.</summary>
         <release-date>2004-01-30</release-date>
 
-        <provides url="simulation" version="1.0.0b1"/>
+        <provides url="simulation" version="1.0.0b2"/>
         <requires url="bcms" version="0.2"/>
-        <requires url="workflow" version="2.0.0b1"/>
+        <requires url="workflow" version="2.0.0b3"/>
         <requires url="acs-mail-lite" version="0.2a"/>
 
         <callbacks>
Index: openacs-4/contrib/packages/simulation/lib/case-history.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/case-history.tcl,v
diff -u -r1.2 -r1.2.2.1
--- openacs-4/contrib/packages/simulation/lib/case-history.tcl	12 Mar 2004 15:49:43 -0000	1.2
+++ openacs-4/contrib/packages/simulation/lib/case-history.tcl	16 Mar 2004 16:16:18 -0000	1.2.2.1
@@ -25,7 +25,7 @@
         }
         user_name {
             label "User"
-            link_url_eval {[acs_community_member_url -user_id $creation_user]}
+            link_url_eval {[ad_decode $creation_user "" "" [acs_community_member_url -user_id $creation_user]]}
         }
         action_pretty {
             label "Task"
@@ -56,13 +56,11 @@
     from   workflow_case_log l join 
            workflow_actions a using (action_id) join 
            cr_items i on (i.item_id = l.entry_id) join 
-           acs_objects io on (io.object_id = i.item_id) join 
-           cc_users iou on (iou.user_id = io.creation_user) join
-           cr_revisions r on (r.revision_id = i.live_revision),
-           workflow_roles role
+           acs_objects io on (io.object_id = i.item_id) left outer join 
+           acs_users_all iou on (iou.user_id = io.creation_user) join
+           cr_revisions r on (r.revision_id = i.live_revision) left outer join
+           workflow_roles role on (role.role_id = a.assigned_role)
     where  l.case_id = :case_id
-    and    role.role_id = a.assigned_role
-    and    a.trigger_type = 'user'
     order  by io.creation_date
 } {
     if { ![empty_string_p $message_item_id] } {
@@ -72,6 +70,10 @@
     } else {
         set action_url {}
     }
+
+    if { [empty_string_p $creation_user] } {
+        set user_name "Timeout"
+    }
 }
 
 template::list::create \
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 -r1.39.2.1
--- openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl	12 Mar 2004 11:07:06 -0000	1.39
+++ openacs-4/contrib/packages/simulation/lib/sim-template-tasks.tcl	16 Mar 2004 16:16:18 -0000	1.39.2.1
@@ -76,6 +76,14 @@
         </if>
     }
 }
+lappend elements copy {
+    hide_p {[ad_decode $display_mode edit 0 1]}
+    sub_class narrow
+    link_url_col copy_url
+    display_template {
+        <img src="/resources/acs-subsite/Copy16.gif" height="16" width="16" border="0" alt="Copy">
+    }
+}
 
 lappend elements name { 
     label "<br />Name"
@@ -167,7 +175,7 @@
 #-------------------------------------------------------------
 
 set extend [list]
-lappend extend edit_url view_url delete_url assigned_role_edit_url up_url down_url add_child_action_url
+lappend extend edit_url view_url delete_url assigned_role_edit_url up_url down_url add_child_action_url copy_url
 
 foreach state_id $states {
     lappend extend state_$state_id
@@ -223,7 +231,8 @@
     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 delete_url \
-        [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url [ad_return_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"} }]
 
     set assigned_role_edit_url \
         [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { { role_id $assigned_role } }]
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.7 -r1.7.2.1
--- openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl	27 Jan 2004 10:33:16 -0000	1.7
+++ openacs-4/contrib/packages/simulation/tcl/sim-action-procs.tcl	16 Mar 2004 16:16:18 -0000	1.7.2.1
@@ -250,7 +250,11 @@
 ad_proc -private simulation::action::generate_spec {
     {-action_id {}}
     {-one_id {}}
-    {-handlers {}}
+    {-handlers {
+        roles "simulation::role" 
+        actions "simulation::action"
+        states "workflow::state::fsm"
+    }}
 } {
     Generate the spec for an individual simulation task definition.
 
@@ -344,3 +348,36 @@
     get -action_id $action_id -array row
     return $row($element)
 }
+
+ad_proc -public simulation::action::clone {
+    {-action_id {}}
+} {
+    Create a copy of the action with given id. Does a shallow copy, i.e.
+    won't copy child roles, states, or actions.
+
+    @author Peter Marklund
+} {
+    simulation::action::get -action_id $action_id -array action
+
+    array set action_spec [simulation::action::generate_spec -action_id $action_id]
+
+    set action_spec(pretty_name) "Copy of $action_spec(pretty_name)"
+
+    foreach type { child_actions child_states child_roles } {
+        if { [info exists action_spec($type)] } {
+            unset action_spec($type)
+        }
+    }
+
+    set copy_action_id [simulation::action::edit \
+                            -operation "insert" \
+                            -workflow_id $action(workflow_id) \
+                            -array action_spec]
+
+    array set edit_array [list sort_order [expr $action(sort_order) + 1]]
+    simulation::action::edit \
+        -action_id $copy_action_id \
+        -array edit_array
+
+    return $copy_action_id
+}
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 -r1.66.2.1
--- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl	4 Mar 2004 12:09:43 -0000	1.66
+++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl	16 Mar 2004 16:16:18 -0000	1.66.2.1
@@ -1044,7 +1044,6 @@
         actions "simulation::action"
         states "workflow::state::fsm"
     }}
-    {-deep:boolean}
 } {
     Generate a spec for a workflow in array list style.
     
@@ -1057,8 +1056,7 @@
     set spec [workflow::generate_spec \
                   -workflow_id $workflow_id \
                   -workflow_handler $workflow_handler \
-                  -handlers $handlers \
-                  -deep=$deep_p]
+                  -handlers $handlers]
 
     simulation::template::get -workflow_id $workflow_id -array simulation
     
@@ -1107,7 +1105,6 @@
     {-package_key {}}
     {-object_id {}}
     {-array {}}
-    {-deep:boolean}
     {-workflow_handler "simulation::template"}
 } {
     Clones an existing simulation template. The clone must belong to either a package key or an object id.
@@ -1133,7 +1130,6 @@
     } 
     
     set workflow_id [workflow::clone \
-                         -deep=$deep_p \
                          -workflow_id $workflow_id \
                          -package_key $package_key \
                          -object_id $object_id \
Index: openacs-4/contrib/packages/simulation/www/simbuild/template-spec.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/template-spec.tcl,v
diff -u -r1.5 -r1.5.2.1
--- openacs-4/contrib/packages/simulation/www/simbuild/template-spec.tcl	27 Jan 2004 10:33:16 -0000	1.5
+++ openacs-4/contrib/packages/simulation/www/simbuild/template-spec.tcl	16 Mar 2004 16:16:18 -0000	1.5.2.1
@@ -5,7 +5,6 @@
     @creation-date 2003-12-10
 } {
     workflow_id:integer
-    {deep_p:boolean "f"}
 }
 
 set page_title "Export"
@@ -14,6 +13,6 @@
 
 set context [list [list "." "SimBuild"] [list [export_vars -base template-edit { workflow_id }] "Editing $sim_template_array(pretty_name)"] $page_title] 
 
-set spec [simulation::template::generate_spec -workflow_id $workflow_id -deep=[template::util::is_true $deep_p]]
+set spec [simulation::template::generate_spec -workflow_id $workflow_id]
 
 set spec [util::array_list_spec_pretty $spec]
Index: openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/map-create.tcl,v
diff -u -r1.9 -r1.9.2.1
--- openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl	13 Jan 2004 12:37:33 -0000	1.9
+++ openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl	16 Mar 2004 16:16:19 -0000	1.9.2.1
@@ -44,7 +44,6 @@
         set new_workflow_array(sim_type) "dev_sim"
         
         set workflow_id [simulation::template::clone \
-                             -deep \
                              -workflow_id $workflow_id \
                              -package_key "simulation" \
                              -object_id [ad_conn package_id] \
Index: openacs-4/contrib/packages/simulation/www/siminst/map-tasks.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/map-tasks.tcl,v
diff -u -r1.13 -r1.13.2.1
--- openacs-4/contrib/packages/simulation/www/siminst/map-tasks.tcl	23 Jan 2004 14:31:36 -0000	1.13
+++ openacs-4/contrib/packages/simulation/www/siminst/map-tasks.tcl	16 Mar 2004 16:16:19 -0000	1.13.2.1
@@ -51,7 +51,7 @@
     if { ![empty_string_p $row(assigned_role_pretty)] || ![empty_string_p $recipient_role_pretty] } {
         append section_name " ("
         if { ![empty_string_p $row(assigned_role_pretty)] } {
-            append section_name $row(assigned_role_pretty)
+            append section_name "$row(assigned_role_pretty))"
         }
         if { ![empty_string_p $recipient_role_pretty] } {
             append section_name "-> $recipient_role_pretty)"
Index: openacs-4/contrib/packages/simulation/www/simplay/document-upload.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/document-upload.tcl,v
diff -u -r1.8 -r1.8.2.1
--- openacs-4/contrib/packages/simulation/www/simplay/document-upload.tcl	30 Jan 2004 14:33:35 -0000	1.8
+++ openacs-4/contrib/packages/simulation/www/simplay/document-upload.tcl	16 Mar 2004 16:16:19 -0000	1.8.2.1
@@ -6,6 +6,7 @@
     case_id:integer
     role_id:integer
     item_id:optional
+    {return_url {[export_vars -base case { case_id role_id }]}}
 }
 
 simulation::case::assert_user_may_play_role -case_id $case_id -role_id $role_id
@@ -22,12 +23,12 @@
 
 set focus "document.document_file"
 
-ad_form -name document -export { case_id role_id workflow_id } -html {enctype multipart/form-data} \
+ad_form -name document -export { case_id role_id workflow_id return_url } -html {enctype multipart/form-data} \
     -form [simulation::ui::forms::document_upload::form_block] \
     -on_submit {
 
         simulation::ui::forms::document_upload::insert_document \
             $case_id $role_id $item_id $document_file $title
 
-        ad_returnredirect [export_vars -base case { case_id role_id }]
+        ad_returnredirect $return_url
     }
Index: openacs-4/contrib/packages/simulation/www/simplay/message.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/message.adp,v
diff -u -r1.10 -r1.10.2.1
--- openacs-4/contrib/packages/simulation/www/simplay/message.adp	22 Jan 2004 15:47:23 -0000	1.10
+++ openacs-4/contrib/packages/simulation/www/simplay/message.adp	16 Mar 2004 16:16:19 -0000	1.10.2.1
@@ -2,5 +2,14 @@
   <property name="title">@page_title;noquote@</property>
   <property name="context">@context;noquote@</property>
   <property name="focus">@focus;noquote@</property>
+
+<if @attachment_options@ nil>
+  <p>
+    <font color="red"><em>NOTE</em></font>: To attach a document to your message you need to <a
+    href="@document_upload_url@">upload a document</a> to your
+    portfolio before writing the message.
+  </p>
+</if>
   
 <formtemplate id="message"></formtemplate>
+
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.26 -r1.26.2.1
--- openacs-4/contrib/packages/simulation/www/simplay/message.tcl	11 Mar 2004 15:15:06 -0000	1.26
+++ openacs-4/contrib/packages/simulation/www/simplay/message.tcl	16 Mar 2004 16:16:19 -0000	1.26.2.1
@@ -31,6 +31,8 @@
 
 set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $role_id]
 
+set document_upload_url [export_vars -base document-upload {case_id role_id {return_url {[ad_return_url]}}}]
+
 set action [form::get_action message]
 
 
Index: openacs-4/packages/simulation/simulation.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/simulation.info,v
diff -u -r1.12 -r1.12.2.1
--- openacs-4/packages/simulation/simulation.info	4 Mar 2004 16:23:18 -0000	1.12
+++ openacs-4/packages/simulation/simulation.info	16 Mar 2004 16:16:17 -0000	1.12.2.1
@@ -8,7 +8,7 @@
     <singleton-p>f</singleton-p>
     <auto-mount>simulation</auto-mount>
 
-    <version name="1.0.0b1" url="http://openacs.org/repository/download/apm/simulation-1.0.0b1.apm">
+    <version name="1.0.0b2" url="http://openacs.org/repository/download/apm/simulation-1.0.0b2.apm">
         <owner url="mailto:team@collaboraid.biz">Collaboraid ApS</owner>
         <summary>Workflow-based task simulator.  Build scenario
         templates in which various roles must complete tasks such as
@@ -18,9 +18,9 @@
         www.rechtenonline.nl.</summary>
         <release-date>2004-01-30</release-date>
 
-        <provides url="simulation" version="1.0.0b1"/>
+        <provides url="simulation" version="1.0.0b2"/>
         <requires url="bcms" version="0.2"/>
-        <requires url="workflow" version="2.0.0b1"/>
+        <requires url="workflow" version="2.0.0b3"/>
         <requires url="acs-mail-lite" version="0.2a"/>
 
         <callbacks>
Index: openacs-4/packages/simulation/lib/case-history.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/case-history.tcl,v
diff -u -r1.2 -r1.2.2.1
--- openacs-4/packages/simulation/lib/case-history.tcl	12 Mar 2004 15:49:43 -0000	1.2
+++ openacs-4/packages/simulation/lib/case-history.tcl	16 Mar 2004 16:16:18 -0000	1.2.2.1
@@ -25,7 +25,7 @@
         }
         user_name {
             label "User"
-            link_url_eval {[acs_community_member_url -user_id $creation_user]}
+            link_url_eval {[ad_decode $creation_user "" "" [acs_community_member_url -user_id $creation_user]]}
         }
         action_pretty {
             label "Task"
@@ -56,13 +56,11 @@
     from   workflow_case_log l join 
            workflow_actions a using (action_id) join 
            cr_items i on (i.item_id = l.entry_id) join 
-           acs_objects io on (io.object_id = i.item_id) join 
-           cc_users iou on (iou.user_id = io.creation_user) join
-           cr_revisions r on (r.revision_id = i.live_revision),
-           workflow_roles role
+           acs_objects io on (io.object_id = i.item_id) left outer join 
+           acs_users_all iou on (iou.user_id = io.creation_user) join
+           cr_revisions r on (r.revision_id = i.live_revision) left outer join
+           workflow_roles role on (role.role_id = a.assigned_role)
     where  l.case_id = :case_id
-    and    role.role_id = a.assigned_role
-    and    a.trigger_type = 'user'
     order  by io.creation_date
 } {
     if { ![empty_string_p $message_item_id] } {
@@ -72,6 +70,10 @@
     } else {
         set action_url {}
     }
+
+    if { [empty_string_p $creation_user] } {
+        set user_name "Timeout"
+    }
 }
 
 template::list::create \
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 -r1.39.2.1
--- openacs-4/packages/simulation/lib/sim-template-tasks.tcl	12 Mar 2004 11:07:06 -0000	1.39
+++ openacs-4/packages/simulation/lib/sim-template-tasks.tcl	16 Mar 2004 16:16:18 -0000	1.39.2.1
@@ -76,6 +76,14 @@
         </if>
     }
 }
+lappend elements copy {
+    hide_p {[ad_decode $display_mode edit 0 1]}
+    sub_class narrow
+    link_url_col copy_url
+    display_template {
+        <img src="/resources/acs-subsite/Copy16.gif" height="16" width="16" border="0" alt="Copy">
+    }
+}
 
 lappend elements name { 
     label "<br />Name"
@@ -167,7 +175,7 @@
 #-------------------------------------------------------------
 
 set extend [list]
-lappend extend edit_url view_url delete_url assigned_role_edit_url up_url down_url add_child_action_url
+lappend extend edit_url view_url delete_url assigned_role_edit_url up_url down_url add_child_action_url copy_url
 
 foreach state_id $states {
     lappend extend state_$state_id
@@ -223,7 +231,8 @@
     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 delete_url \
-        [export_vars -base "[apm_package_url_from_id $package_id]simbuild/task-delete" { action_id {return_url [ad_return_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"} }]
 
     set assigned_role_edit_url \
         [export_vars -base "[apm_package_url_from_id $package_id]simbuild/role-edit" { { role_id $assigned_role } }]
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.7 -r1.7.2.1
--- openacs-4/packages/simulation/tcl/sim-action-procs.tcl	27 Jan 2004 10:33:16 -0000	1.7
+++ openacs-4/packages/simulation/tcl/sim-action-procs.tcl	16 Mar 2004 16:16:18 -0000	1.7.2.1
@@ -250,7 +250,11 @@
 ad_proc -private simulation::action::generate_spec {
     {-action_id {}}
     {-one_id {}}
-    {-handlers {}}
+    {-handlers {
+        roles "simulation::role" 
+        actions "simulation::action"
+        states "workflow::state::fsm"
+    }}
 } {
     Generate the spec for an individual simulation task definition.
 
@@ -344,3 +348,36 @@
     get -action_id $action_id -array row
     return $row($element)
 }
+
+ad_proc -public simulation::action::clone {
+    {-action_id {}}
+} {
+    Create a copy of the action with given id. Does a shallow copy, i.e.
+    won't copy child roles, states, or actions.
+
+    @author Peter Marklund
+} {
+    simulation::action::get -action_id $action_id -array action
+
+    array set action_spec [simulation::action::generate_spec -action_id $action_id]
+
+    set action_spec(pretty_name) "Copy of $action_spec(pretty_name)"
+
+    foreach type { child_actions child_states child_roles } {
+        if { [info exists action_spec($type)] } {
+            unset action_spec($type)
+        }
+    }
+
+    set copy_action_id [simulation::action::edit \
+                            -operation "insert" \
+                            -workflow_id $action(workflow_id) \
+                            -array action_spec]
+
+    array set edit_array [list sort_order [expr $action(sort_order) + 1]]
+    simulation::action::edit \
+        -action_id $copy_action_id \
+        -array edit_array
+
+    return $copy_action_id
+}
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 -r1.66.2.1
--- openacs-4/packages/simulation/tcl/template-procs.tcl	4 Mar 2004 12:09:43 -0000	1.66
+++ openacs-4/packages/simulation/tcl/template-procs.tcl	16 Mar 2004 16:16:18 -0000	1.66.2.1
@@ -1044,7 +1044,6 @@
         actions "simulation::action"
         states "workflow::state::fsm"
     }}
-    {-deep:boolean}
 } {
     Generate a spec for a workflow in array list style.
     
@@ -1057,8 +1056,7 @@
     set spec [workflow::generate_spec \
                   -workflow_id $workflow_id \
                   -workflow_handler $workflow_handler \
-                  -handlers $handlers \
-                  -deep=$deep_p]
+                  -handlers $handlers]
 
     simulation::template::get -workflow_id $workflow_id -array simulation
     
@@ -1107,7 +1105,6 @@
     {-package_key {}}
     {-object_id {}}
     {-array {}}
-    {-deep:boolean}
     {-workflow_handler "simulation::template"}
 } {
     Clones an existing simulation template. The clone must belong to either a package key or an object id.
@@ -1133,7 +1130,6 @@
     } 
     
     set workflow_id [workflow::clone \
-                         -deep=$deep_p \
                          -workflow_id $workflow_id \
                          -package_key $package_key \
                          -object_id $object_id \
Index: openacs-4/packages/simulation/www/simbuild/template-spec.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/template-spec.tcl,v
diff -u -r1.5 -r1.5.2.1
--- openacs-4/packages/simulation/www/simbuild/template-spec.tcl	27 Jan 2004 10:33:16 -0000	1.5
+++ openacs-4/packages/simulation/www/simbuild/template-spec.tcl	16 Mar 2004 16:16:18 -0000	1.5.2.1
@@ -5,7 +5,6 @@
     @creation-date 2003-12-10
 } {
     workflow_id:integer
-    {deep_p:boolean "f"}
 }
 
 set page_title "Export"
@@ -14,6 +13,6 @@
 
 set context [list [list "." "SimBuild"] [list [export_vars -base template-edit { workflow_id }] "Editing $sim_template_array(pretty_name)"] $page_title] 
 
-set spec [simulation::template::generate_spec -workflow_id $workflow_id -deep=[template::util::is_true $deep_p]]
+set spec [simulation::template::generate_spec -workflow_id $workflow_id]
 
 set spec [util::array_list_spec_pretty $spec]
Index: openacs-4/packages/simulation/www/siminst/map-create.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/map-create.tcl,v
diff -u -r1.9 -r1.9.2.1
--- openacs-4/packages/simulation/www/siminst/map-create.tcl	13 Jan 2004 12:37:33 -0000	1.9
+++ openacs-4/packages/simulation/www/siminst/map-create.tcl	16 Mar 2004 16:16:19 -0000	1.9.2.1
@@ -44,7 +44,6 @@
         set new_workflow_array(sim_type) "dev_sim"
         
         set workflow_id [simulation::template::clone \
-                             -deep \
                              -workflow_id $workflow_id \
                              -package_key "simulation" \
                              -object_id [ad_conn package_id] \
Index: openacs-4/packages/simulation/www/siminst/map-tasks.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/map-tasks.tcl,v
diff -u -r1.13 -r1.13.2.1
--- openacs-4/packages/simulation/www/siminst/map-tasks.tcl	23 Jan 2004 14:31:36 -0000	1.13
+++ openacs-4/packages/simulation/www/siminst/map-tasks.tcl	16 Mar 2004 16:16:19 -0000	1.13.2.1
@@ -51,7 +51,7 @@
     if { ![empty_string_p $row(assigned_role_pretty)] || ![empty_string_p $recipient_role_pretty] } {
         append section_name " ("
         if { ![empty_string_p $row(assigned_role_pretty)] } {
-            append section_name $row(assigned_role_pretty)
+            append section_name "$row(assigned_role_pretty))"
         }
         if { ![empty_string_p $recipient_role_pretty] } {
             append section_name "-> $recipient_role_pretty)"
Index: openacs-4/packages/simulation/www/simplay/document-upload.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/document-upload.tcl,v
diff -u -r1.8 -r1.8.2.1
--- openacs-4/packages/simulation/www/simplay/document-upload.tcl	30 Jan 2004 14:33:35 -0000	1.8
+++ openacs-4/packages/simulation/www/simplay/document-upload.tcl	16 Mar 2004 16:16:19 -0000	1.8.2.1
@@ -6,6 +6,7 @@
     case_id:integer
     role_id:integer
     item_id:optional
+    {return_url {[export_vars -base case { case_id role_id }]}}
 }
 
 simulation::case::assert_user_may_play_role -case_id $case_id -role_id $role_id
@@ -22,12 +23,12 @@
 
 set focus "document.document_file"
 
-ad_form -name document -export { case_id role_id workflow_id } -html {enctype multipart/form-data} \
+ad_form -name document -export { case_id role_id workflow_id return_url } -html {enctype multipart/form-data} \
     -form [simulation::ui::forms::document_upload::form_block] \
     -on_submit {
 
         simulation::ui::forms::document_upload::insert_document \
             $case_id $role_id $item_id $document_file $title
 
-        ad_returnredirect [export_vars -base case { case_id role_id }]
+        ad_returnredirect $return_url
     }
Index: openacs-4/packages/simulation/www/simplay/message.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/message.adp,v
diff -u -r1.10 -r1.10.2.1
--- openacs-4/packages/simulation/www/simplay/message.adp	22 Jan 2004 15:47:23 -0000	1.10
+++ openacs-4/packages/simulation/www/simplay/message.adp	16 Mar 2004 16:16:19 -0000	1.10.2.1
@@ -2,5 +2,14 @@
   <property name="title">@page_title;noquote@</property>
   <property name="context">@context;noquote@</property>
   <property name="focus">@focus;noquote@</property>
+
+<if @attachment_options@ nil>
+  <p>
+    <font color="red"><em>NOTE</em></font>: To attach a document to your message you need to <a
+    href="@document_upload_url@">upload a document</a> to your
+    portfolio before writing the message.
+  </p>
+</if>
   
 <formtemplate id="message"></formtemplate>
+
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.26 -r1.26.2.1
--- openacs-4/packages/simulation/www/simplay/message.tcl	11 Mar 2004 15:15:06 -0000	1.26
+++ openacs-4/packages/simulation/www/simplay/message.tcl	16 Mar 2004 16:16:19 -0000	1.26.2.1
@@ -31,6 +31,8 @@
 
 set attachment_options [simulation::case::attachment_options -case_id $case_id -role_id $role_id]
 
+set document_upload_url [export_vars -base document-upload {case_id role_id {return_url {[ad_return_url]}}}]
+
 set action [form::get_action message]
 
 
Index: openacs-4/packages/workflow/workflow.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/workflow.info,v
diff -u -r1.14 -r1.14.2.1
--- openacs-4/packages/workflow/workflow.info	30 Jan 2004 15:59:20 -0000	1.14
+++ openacs-4/packages/workflow/workflow.info	16 Mar 2004 16:17:45 -0000	1.14.2.1
@@ -8,7 +8,7 @@
     <singleton-p>t</singleton-p>
     <auto-mount>workflow</auto-mount>
 
-    <version name="2.0.0b1" url="http://openacs.org/repository/download/apm/workflow-2.0.0b1.apm">
+    <version name="2.0.0b3" url="http://openacs.org/repository/download/apm/workflow-2.0.0b3.apm">
         <owner url="http://pinds.com">Lars Pind</owner>
         <owner url="http://petermarklund.com">Peter Marklund</owner>
         <summary>A Tcl API for creating and managing workflows.</summary>
@@ -23,7 +23,7 @@
 &lt;p&gt;
 For more information, see: &lt;a href=&quot;http://www.collaboraid.biz/developer/workflow-spec&quot;&gt;the workflow specification&lt;/a&gt;.</description>
 
-        <provides url="workflow" version="2.0.0b1"/>
+        <provides url="workflow" version="2.0.0b3"/>
         <requires url="acs-content-repository" version="5.0.0b4"/>
         <requires url="acs-kernel" version="5.0.0b4"/>
         <requires url="acs-tcl" version="5.0.0b4"/>
Index: openacs-4/packages/workflow/tcl/case-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/tcl/case-procs-postgresql.xql,v
diff -u -r1.8 -r1.8.2.1
--- openacs-4/packages/workflow/tcl/case-procs-postgresql.xql	5 Feb 2004 10:37:33 -0000	1.8
+++ openacs-4/packages/workflow/tcl/case-procs-postgresql.xql	16 Mar 2004 16:17:45 -0000	1.8.2.1
@@ -71,8 +71,8 @@
         from   workflow_case_log l join 
                workflow_actions a using (action_id) join 
                cr_items i on (i.item_id = l.entry_id) join 
-               acs_objects io on (io.object_id = i.item_id) join 
-               cc_users iou on (iou.user_id = io.creation_user) join
+               acs_objects io on (io.object_id = i.item_id) left outer join 
+               acs_users_all iou on (iou.user_id = io.creation_user) join
                cr_revisions r on (r.revision_id = i.live_revision) left outer join 
                workflow_case_log_data d using (entry_id)
         where  l.case_id = :case_id
Index: openacs-4/packages/workflow/tcl/case-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/tcl/case-procs.tcl,v
diff -u -r1.29 -r1.29.2.1
--- openacs-4/packages/workflow/tcl/case-procs.tcl	5 Feb 2004 10:37:33 -0000	1.29
+++ openacs-4/packages/workflow/tcl/case-procs.tcl	16 Mar 2004 16:17:45 -0000	1.29.2.1
@@ -1861,7 +1861,11 @@
     @author Lars Pind (lars@collaboraid.biz)
 } {
     if { ![exists_and_not_null user_id] } {
-        set user_id [ad_conn user_id]
+        if { ![ad_conn isconnected] } {
+            set user_id 0
+        } else {
+            set user_id [ad_conn user_id]
+        }
     }
 
     if { [empty_string_p $case_id] || [empty_string_p $action_id] } {
Index: openacs-4/packages/workflow/tcl/workflow-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/workflow/tcl/workflow-procs.tcl,v
diff -u -r1.25 -r1.25.2.1
--- openacs-4/packages/workflow/tcl/workflow-procs.tcl	27 Jan 2004 10:32:34 -0000	1.25
+++ openacs-4/packages/workflow/tcl/workflow-procs.tcl	16 Mar 2004 16:17:45 -0000	1.25.2.1
@@ -545,7 +545,6 @@
         roles workflow::role 
         actions workflow::action
     }}
-    {-deep:boolean}
 } {
     Generate a spec for a workflow in array list style.
     Note that calling this directly with the default arguments will bomb, because workflow::action doesn't implement the required API.
@@ -587,8 +586,6 @@
         }
     }
 
-    set child_workflows [list]
-
     foreach { key namespace } $handlers {
         set subspec [list]
         
@@ -598,45 +595,13 @@
                                 -element short_name]
             set elm_spec [${namespace}::generate_spec -one_id $sub_id -handlers $handlers]
             
-            if { $deep_p } {
-                if { [string equal $key "actions"] } {
-                    array unset elm_array 
-                    array set elm_array $elm_spec
-                    if { [exists_and_not_null elm_array(child_workflow)] } {
-                        # Prefix the child workflow with the short_name of the parent workflow
-                        set new_child_workflow ${short_name}_$elm_array(child_workflow)
-                        
-                        # Change the child_workflow to the prefixed version in the spec
-                        set elm_array(child_workflow) $new_child_workflow
-
-                        # Output the modified spec
-                        set elm_spec [list]
-                        foreach name [lsort [array names elm_array]] {
-                            lappend elm_spec $name $elm_array($name)
-                        }
-
-                        # Remember this child workflow, so we generate the spec for it later
-                        set child_workflow_id [${namespace}::get_element -one_id $sub_id -element child_workflow_id]
-                        lappend child_workflows $child_workflow_id $new_child_workflow
-                    }
-                }
-            }
-
             lappend subspec $sub_short_name $elm_spec 
         }
         lappend spec $key $subspec
     }
 
     set spec [list $short_name $spec]
 
-    foreach { child_workflow_id new_short_name } $child_workflows {
-        set child_spec [${workflow_handler}::generate_spec \
-                                    -workflow_id $child_workflow_id \
-                                    -workflow_handler $workflow_handler \
-                                    -handlers $handlers]
-        set spec [concat $spec $new_short_name [list [lindex $child_spec 1]]]
-    }
-
     return $spec
 }
 
@@ -646,7 +611,6 @@
     {-object_id {}}
     {-array {}}
     {-workflow_handler workflow}
-    {-deep:boolean}
 } {
     Clones an existing FSM workflow. The clone must belong to either a package key or an object id.
 
@@ -672,8 +636,7 @@
 
     set spec [${workflow_handler}::generate_spec \
                   -workflow_id $workflow_id \
-                  -workflow_handler $workflow_handler \
-                  -deep=$deep_p]
+                  -workflow_handler $workflow_handler]
     
     set workflow_id [${workflow_handler}::new_from_spec \
                          -package_key $package_key \
@@ -1140,7 +1103,6 @@
         actions workflow::action::fsm
         states workflow::state::fsm
     }}
-    {-deep:boolean}
 } {
     Generate a spec for a workflow in array list style.
     
@@ -1153,8 +1115,7 @@
     set spec [workflow::generate_spec \
                   -workflow_id $workflow_id \
                   -workflow_handler $workflow_handler \
-                  -handlers $handlers \
-                  -deep=$deep_p]
+                  -handlers $handlers]
 
     return $spec
 }