Index: openacs-4/contrib/packages/simulation/tcl/apm-callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/apm-callback-procs.tcl,v
diff -u -r1.13 -r1.14
--- openacs-4/contrib/packages/simulation/tcl/apm-callback-procs.tcl 22 Jan 2004 10:28:03 -0000 1.13
+++ openacs-4/contrib/packages/simulation/tcl/apm-callback-procs.tcl 26 Jan 2004 14:21:02 -0000 1.14
@@ -10,10 +10,12 @@
ad_proc -private simulation::apm::after_install {} {
simulation::notification::xml_map::register
+ simulation::notification::message::register
}
ad_proc -private simulation::apm::before_uninstall {} {
simulation::notification::xml_map::unregister
+ simulation::notification::message::unregister
}
ad_proc -private simulation::apm::after_instantiate {
Index: openacs-4/contrib/packages/simulation/tcl/message-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/message-procs.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/tcl/message-procs.tcl 5 Jan 2004 17:05:07 -0000 1.2
+++ openacs-4/contrib/packages/simulation/tcl/message-procs.tcl 26 Jan 2004 14:21:02 -0000 1.3
@@ -68,6 +68,40 @@
-related_object_id $attachment_id
}
+ # Send notification to receiving users
+ set users_in_receiving_role [list]
+ foreach user_list [workflow::case::role::get_assignees -case_id $case_id -role_id $to_role_id] {
+ array set user $user_list
+ lappend users_in_receiving_role $user(party_id)
+ }
+ workflow::case::get -case_id $case_id -array case
+ workflow::get -workflow_id $case(workflow_id) -array workflow
+ set notif_subject "\[SimPlay\] New message in simulation $workflow(pretty_name): $subject"
+ set package_id [ad_conn package_id]
+ set simplay_url \
+ [export_vars -base "[ad_url][apm_package_url_from_id $package_id]simplay" { workflow_id }]
+ set notif_body "You have just received the following message in simulation $workflow(pretty_name):
+
+-----------------------------------------------------
+subject: $subject
+
+body:
+
+$body
+-----------------------------------------------------
+
+Please visit $simplay_url to continue playing the simulation.
+
+Thank you.
+"
+
+ notification::new \
+ -type_id [notification::type::get_type_id -short_name [simulation::notification::message::type_short_name]] \
+ -object_id $case(workflow_id) \
+ -notif_subject $notif_subject \
+ -notif_text $notif_body \
+ -action_id $item_id \
+ -subset $users_in_receiving_role
}
return $item_id
Index: openacs-4/contrib/packages/simulation/tcl/notification-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/notification-procs.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/tcl/notification-procs.tcl 22 Jan 2004 12:49:45 -0000 1.2
+++ openacs-4/contrib/packages/simulation/tcl/notification-procs.tcl 26 Jan 2004 14:21:02 -0000 1.3
@@ -8,7 +8,14 @@
namespace eval simulation::notification {}
namespace eval simulation::notification::xml_map {}
+namespace eval simulation::notification::message {}
+###############################
+#
+# simulation::notification::xml_map namespace
+#
+###############################
+
ad_proc -private simulation::notification::xml_map::register {} {
db_transaction {
set spec [list \
@@ -74,3 +81,75 @@
} {
# This proc is not needed
}
+
+###############################
+#
+# simulation::notification::message namespace
+#
+###############################
+
+ad_proc -private simulation::notification::message::register {} {
+ db_transaction {
+ set spec [list \
+ contract_name "NotificationType" \
+ name [sc_name] \
+ aliases {
+ GetURL simulation::notification::message::get_url
+ ProcessReply simulation::notification::message::process_reply
+ } \
+ owner [simulation::package_key]]
+ set sc_impl_id [acs_sc::impl::new_from_spec -spec $spec]
+
+ notification::type::new \
+ -all_intervals \
+ -all_delivery_methods \
+ -sc_impl_id $sc_impl_id \
+ -short_name [type_short_name] \
+ -pretty_name [type_pretty_name] \
+ -description [type_description]
+ }
+}
+
+ad_proc -private simulation::notification::message::unregister {} {
+ db_transaction {
+ notification::type::delete -short_name [type_short_name]
+
+ acs_sc::impl::delete \
+ -contract_name "NotificationType" \
+ -impl_name [sc_name]
+ }
+}
+
+ad_proc -private simulation::notification::message::sc_id {} {
+ return [acs_sc::impl::get_id \
+ -owner [simulation::package_key] \
+ -name [sc_name]]
+}
+
+ad_proc -private simulation::notification::message::sc_name {} {
+ return "SimplayMessageNotification"
+}
+
+ad_proc -private simulation::notification::message::type_short_name {} {
+ return "simplay_message"
+}
+
+ad_proc -private simulation::notification::message::type_pretty_name {} {
+ return "Simplay Message"
+}
+
+ad_proc -private simulation::notification::message::type_description {} {
+ return "Notification of received SimPlay messages."
+}
+
+ad_proc -public simulation::notification::message::get_url {
+ object_id
+} {
+ # This proc is not needed
+}
+
+ad_proc -public simulation::notification::message::process_reply {
+ reply_id
+} {
+ # This proc is not needed
+}
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.60 -r1.61
--- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 23 Jan 2004 15:52:58 -0000 1.60
+++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 26 Jan 2004 14:21:02 -0000 1.61
@@ -474,6 +474,67 @@
}
}
+ad_proc -public simulation::template::enroll_user {
+ {-workflow_id:required}
+ {-user_id:required}
+ {-simulation_array ""}
+ {-email ""}
+ {-user_name ""}
+} {
+ 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.
+
+ @author Peter Marklund
+} {
+ if { ![empty_string_p $simulation_array] } {
+ upvar $simulation_array sim_template
+ } else {
+ simulation::template::get -workflow_id $workflow_id -array sim_template
+ }
+
+ if { [empty_string_p $email] } {
+ acs_user::get -user_id $user_id -array user
+
+ set email $user(email)
+ set user_name $user(name)
+ }
+
+ # Not using edit proc here as it deletes currently enrolled users
+ db_dml enroll_user {
+ insert into sim_party_sim_map
+ (simulation_id, party_id, type)
+ values
+ (:workflow_id, :user_id, 'enrolled')
+ }
+
+ if { [string equal $sim_template(casting_type) "open"] || [string equal $sim_template(casting_type) "group"] } {
+ # Notify users that they are enrolled and can do their casting
+
+ set subject "You have been enrolled in simulation $sim_template(pretty_name)"
+ set package_id [ad_conn package_id]
+ set casting_page_url \
+ [export_vars -base "[ad_url][apm_package_url_from_id $package_id]simplay/cast" { workflow_id }]
+ set body "Dear $user_name,
+This is to notify you that you have been enrolled in simulation $sim_template(pretty_name). You may visit the
+casting page at ${casting_page_url} to choose case or role.
+"
+
+ acs_mail_lite::send \
+ -to_addr $email \
+ -from_addr [ad_system_owner] \
+ -subject $subject\
+ -body $body
+ }
+
+ # Sign the user up for immediate email notification for received messages in the simulation
+ notification::request::new \
+ -type_id [notification::type::get_type_id -short_name [simulation::notification::message::type_short_name]] \
+ -user_id $user_id \
+ -object_id $workflow_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 {
{-workflow_id:required}
} {
@@ -482,8 +543,9 @@
@author Peter Marklund
} {
- set simulation_edit(enrolled) [list]
- set enroll_email_list [list]
+ simulation::template::get -workflow_id $workflow_id -array sim_template
+
+ set enroll_user_list [list]
set invite_email_list [list]
db_foreach select_enrolled_and_invited_users {
select distinct pamm.member_id as user_id,
@@ -501,49 +563,31 @@
} {
if { [string equal $type "auto_enroll"] } {
# enroll the user automatically
- lappend simulation_edit(enrolled) $user_id
- lappend enroll_email_list [list $email $user_name]
+ lappend enroll_user_list [list $user_id $email $user_name]
} else {
# Invite the user
lappend invite_email_list [list $email $user_name]
}
}
- simulation::template::edit -workflow_id $workflow_id -array simulation_edit
+ # Enroll users
+ foreach user $enroll_user_list {
+ simulation::template::enroll_user \
+ -workflow_id $workflow_id \
+ -user_id [lindex $user 0] \
+ -simulation_array sim_template \
+ -user_name [lindex $user 2] \
+ -email [lindex $user 1]
+ }
- simulation::template::get -workflow_id $workflow_id -array sim_template
-
- if { [string equal $sim_template(casting_type) "open"] || [string equal $sim_template(casting_type) "group"] } {
- # Notify users that they are enrolled and can do their casting
- foreach user $enroll_email_list {
- set email [lindex $user 0]
- set user_name [lindex $user 1]
-
- set subject "You have been enrolled in simulation $sim_template(pretty_name)"
- set package_id [ad_conn package_id]
- set casting_page_url \
- [export_vars -base "[ad_url][apm_package_url_from_id $package_id]/simplay/cast" { workflow_id }]
- set body "Dear $user_name,
-This is to notify you that you have been enrolled in simulation $sim_template(pretty_name). You may visit the
-casting page at ${casting_page_url} to choose case or role.
-"
-
- acs_mail_lite::send \
- -to_addr $email \
- -from_addr [ad_system_owner] \
- -subject $subject\
- -body $body
- }
- }
-
# Invite users
foreach user $invite_email_list {
set email [lindex $user 0]
set user_name [lindex $user 1]
set package_id [ad_conn package_id]
set enrollment_page_url \
- [export_vars -base "[ad_url][apm_package_url_from_id $package_id]/simplay/enroll" { workflow_id }]
+ [export_vars -base "[ad_url][apm_package_url_from_id $package_id]simplay/enroll" { workflow_id }]
set subject "You have been invited to join simulation $sim_template(pretty_name)"
set body "Dear $user_name,
You have been invited to join simulation $sim_template(pretty_name). Please visit the enrollment page at $enrollment_page_url to accept the invitation. Thank you!"
@@ -672,7 +716,7 @@
set package_id [ad_conn package_id]
set simplay_url \
- [export_vars -base "[ad_url][apm_package_url_from_id $package_id]/simplay/enroll" { workflow_id }]
+ [export_vars -base "[ad_url][apm_package_url_from_id $package_id]simplay/enroll" { workflow_id }]
set subject "Simulation $simulation(pretty_name) has started"
set body "Dear $user_name,
Simulation $simulation(pretty_name) has now started. Please visit $simplay_url to participate. Thank you!"
Index: openacs-4/contrib/packages/simulation/www/simplay/case-admin.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/case-admin.adp,v
diff -u -r1.4 -r1.5
--- openacs-4/contrib/packages/simulation/www/simplay/case-admin.adp 22 Jan 2004 15:47:23 -0000 1.4
+++ openacs-4/contrib/packages/simulation/www/simplay/case-admin.adp 26 Jan 2004 14:21:03 -0000 1.5
@@ -8,7 +8,7 @@
Index: openacs-4/contrib/packages/simulation/www/simplay/enroll.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/enroll.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/contrib/packages/simulation/www/simplay/enroll.tcl 21 Jan 2004 15:55:36 -0000 1.7
+++ openacs-4/contrib/packages/simulation/www/simplay/enroll.tcl 26 Jan 2004 14:21:03 -0000 1.8
@@ -46,14 +46,10 @@
}
}
-# The user is allowed to enroll, so enroll him
-# Not using edit proc here as it deletes currently enrolled users
-db_dml enroll_user {
- insert into sim_party_sim_map
- (simulation_id, party_id, type)
- values
- (:workflow_id, :user_id, 'enrolled')
-}
+# The user is allowed to enroll, so go ahead
+simulation::template::enroll_user \
+ -workflow_id $workflow_id \
+ -user_id $user_id
# If there are casting decisions open to the user, redirect to the casting page (casting_type group or open)
if { [string equal $simulation(casting_type) "auto"] } {
Index: openacs-4/contrib/packages/simulation/www/simplay/tasks.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/tasks.adp,v
diff -u -r1.9 -r1.10
--- openacs-4/contrib/packages/simulation/www/simplay/tasks.adp 16 Jan 2004 10:20:39 -0000 1.9
+++ openacs-4/contrib/packages/simulation/www/simplay/tasks.adp 26 Jan 2004 14:21:03 -0000 1.10
@@ -4,5 +4,5 @@
Index: openacs-4/packages/simulation/www/simplay/enroll.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/enroll.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/simulation/www/simplay/enroll.tcl 21 Jan 2004 15:55:36 -0000 1.7
+++ openacs-4/packages/simulation/www/simplay/enroll.tcl 26 Jan 2004 14:21:03 -0000 1.8
@@ -46,14 +46,10 @@
}
}
-# The user is allowed to enroll, so enroll him
-# Not using edit proc here as it deletes currently enrolled users
-db_dml enroll_user {
- insert into sim_party_sim_map
- (simulation_id, party_id, type)
- values
- (:workflow_id, :user_id, 'enrolled')
-}
+# The user is allowed to enroll, so go ahead
+simulation::template::enroll_user \
+ -workflow_id $workflow_id \
+ -user_id $user_id
# If there are casting decisions open to the user, redirect to the casting page (casting_type group or open)
if { [string equal $simulation(casting_type) "auto"] } {
Index: openacs-4/packages/simulation/www/simplay/tasks.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/tasks.adp,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/simulation/www/simplay/tasks.adp 16 Jan 2004 10:20:39 -0000 1.9
+++ openacs-4/packages/simulation/www/simplay/tasks.adp 26 Jan 2004 14:21:03 -0000 1.10
@@ -4,5 +4,5 @@