Index: openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/simulation-procs.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 28 Nov 2003 16:55:52 -0000 1.13 +++ openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 16 Dec 2003 11:34:33 -0000 1.14 @@ -134,6 +134,33 @@ }] } +ad_proc simulation::groups_eligible_for_casting {} { + Return a list of groups eligible for enrollment and invitation + for the current simulation package. + + @return A list of lists, with label-id pairs, suitable to be passed + as the options attribute of a form builder select widget. + + @author Peter Marklund +} { + # lookup package_id of the nearest subsite + subsite::get -array closest_subsite + + # Lookup the application group of the subsite + set subsite_group_id [application_group::group_id_from_package_id \ + -package_id $closest_subsite(package_id)] + + # Get all groups related to (children of) the subsite group (only one level down) + return [db_list_of_lists subsite_group_options { + select g.group_name, + g.group_id + from acs_rels ar, + groups g + where ar.object_id_one = :subsite_group_id + and ar.object_id_two = g.group_id + }] +} + ad_proc -public simulation::cast { {-workflow_id:required} {-pretty_name:required} 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.13 -r1.14 --- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 15 Dec 2003 14:50:12 -0000 1.13 +++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 16 Dec 2003 11:34:33 -0000 1.14 @@ -167,22 +167,29 @@ # Update sim_party_sim_map table - if { [info exists edit_array(parties)] } { + if { [info exists edit_array(enroll_groups)] } { # Clear out old mappings first db_dml clear_old_mappings { delete from sim_party_sim_map where simulation_id = :workflow_id + and type = 'auto-enroll' } - foreach party_id $edit_array(parties) { + # Map each group as auto-enrolled + foreach party_id $edit_array(enroll_groups) { db_dml map_party_to_template { insert into sim_party_sim_map - (simulation_id, party_id) - values (:workflow_id, :party_id) + (simulation_id, party_id, type) + values (:workflow_id, :party_id, 'auto-enroll') } + + # TODO: Do we need to map each user in the group as enrolled? + # use party_approved_member_map } } + + # TODO: invite_groups } } @@ -254,12 +261,36 @@ @param workflow_id ID of simulation template. @param array name of array in which the info will be returned Array will contain keys from the tables workflows and sim_simulations. + + @see simulation::template::get_parties } { upvar $array row db_1row select_template {} -column_array row } +ad_proc -public simulation::template::get_parties { + {-workflow_id:required} + {-rel_type "auto-enroll"} +} { + Return a list of parties related to the given simulation. + + @param rel_type The type of relationship of the party to the + simulation template. Permissible values are + enrolled, invited, and auto-enroll + + @return A list of party_id:s +} { + ad_assert_arg_value_in_list rel_type {enrolled invited auto-enroll} + + return [db_list template_parties { + select party_id + from sim_party_sim_map + where simulation_id = :workflow_id + and type = :rel_type + }] +} + ad_proc -public simulation::template::ready_for_casting_p { {-workflow_id ""} {-role_empty_count ""} Index: openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/simulation-casting-2.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-2.tcl 15 Dec 2003 14:50:12 -0000 1.5 +++ openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-2.tcl 16 Dec 2003 11:34:33 -0000 1.6 @@ -10,12 +10,9 @@ set context [list [list "." "SimInst"] $page_title] set package_id [ad_conn package_id] +subsite::get -array closest_subsite +set group_admin_url "${closest_subsite(url)}admin/group-types/one?group_type=group" -# TODO: only one aplication group per package - need different solution -set group_id [application_group::group_id_from_package_id -package_id $package_id] -set group_name [group::get_element -group_id $group_id -element group_name] -set group_options [list [list $group_name $group_id]] - # TODO: provide more sensible default dates? # Notification send could be start date minus some parameter set in_a_month_date [clock format [expr [clock seconds] + 3600*24*31] -format "%Y %m %d"] @@ -47,20 +44,28 @@ } {enroll_type:text(radio) {label "Enrollment type"} - {options {{Invite invite} {Open open}}} + {options {{"By invitation only" closed} {Open open}}} {value $sim_template(enroll_type)} } {casting_type:text(radio) {label "Casting type"} {options {{Automatic auto} {Group group} {Open open}}} {value $sim_template(casting_type)} } - {user_group:integer(checkbox),multiple,optional + {enroll_groups:integer(checkbox),multiple,optional + {label "Enroll all users in these groups"} + {options {[simulation::groups_eligible_for_casting]}} + {help_text {Use Group Administration to add groups}} + } + {invite_groups:integer(checkbox),multiple,optional {label "Invite all users in these groups"} - {options $group_options} - #TODO: this link should use a function to find the subsite path - {help_text {Use Group Administration to add groups}} + {options {[simulation::groups_eligible_for_casting]}} + {help_text {Use Group Administration to add groups}} } +} -on_request { + + set enroll_groups [simulation::template::get_parties -workflow_id $workflow_id -rel_type auto-enroll] + } -on_submit { # Convert dates to ANSI format foreach var_name {enroll_start enroll_end notification_date case_start case_end} { @@ -75,7 +80,8 @@ set sim_template(case_end) $case_end_ansi set sim_template(enroll_type) $enroll_type set sim_template(casting_type) $casting_type - set sim_template(parties $user_group + set sim_template(enroll_groups) $enroll_groups + set sim_template(invite_gropus) $invite_groups simulation::template::edit \ -workflow_id $workflow_id \ Index: openacs-4/packages/simulation/tcl/simulation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/simulation-procs.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/packages/simulation/tcl/simulation-procs.tcl 28 Nov 2003 16:55:52 -0000 1.13 +++ openacs-4/packages/simulation/tcl/simulation-procs.tcl 16 Dec 2003 11:34:33 -0000 1.14 @@ -134,6 +134,33 @@ }] } +ad_proc simulation::groups_eligible_for_casting {} { + Return a list of groups eligible for enrollment and invitation + for the current simulation package. + + @return A list of lists, with label-id pairs, suitable to be passed + as the options attribute of a form builder select widget. + + @author Peter Marklund +} { + # lookup package_id of the nearest subsite + subsite::get -array closest_subsite + + # Lookup the application group of the subsite + set subsite_group_id [application_group::group_id_from_package_id \ + -package_id $closest_subsite(package_id)] + + # Get all groups related to (children of) the subsite group (only one level down) + return [db_list_of_lists subsite_group_options { + select g.group_name, + g.group_id + from acs_rels ar, + groups g + where ar.object_id_one = :subsite_group_id + and ar.object_id_two = g.group_id + }] +} + ad_proc -public simulation::cast { {-workflow_id:required} {-pretty_name:required} 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.13 -r1.14 --- openacs-4/packages/simulation/tcl/template-procs.tcl 15 Dec 2003 14:50:12 -0000 1.13 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 16 Dec 2003 11:34:33 -0000 1.14 @@ -167,22 +167,29 @@ # Update sim_party_sim_map table - if { [info exists edit_array(parties)] } { + if { [info exists edit_array(enroll_groups)] } { # Clear out old mappings first db_dml clear_old_mappings { delete from sim_party_sim_map where simulation_id = :workflow_id + and type = 'auto-enroll' } - foreach party_id $edit_array(parties) { + # Map each group as auto-enrolled + foreach party_id $edit_array(enroll_groups) { db_dml map_party_to_template { insert into sim_party_sim_map - (simulation_id, party_id) - values (:workflow_id, :party_id) + (simulation_id, party_id, type) + values (:workflow_id, :party_id, 'auto-enroll') } + + # TODO: Do we need to map each user in the group as enrolled? + # use party_approved_member_map } } + + # TODO: invite_groups } } @@ -254,12 +261,36 @@ @param workflow_id ID of simulation template. @param array name of array in which the info will be returned Array will contain keys from the tables workflows and sim_simulations. + + @see simulation::template::get_parties } { upvar $array row db_1row select_template {} -column_array row } +ad_proc -public simulation::template::get_parties { + {-workflow_id:required} + {-rel_type "auto-enroll"} +} { + Return a list of parties related to the given simulation. + + @param rel_type The type of relationship of the party to the + simulation template. Permissible values are + enrolled, invited, and auto-enroll + + @return A list of party_id:s +} { + ad_assert_arg_value_in_list rel_type {enrolled invited auto-enroll} + + return [db_list template_parties { + select party_id + from sim_party_sim_map + where simulation_id = :workflow_id + and type = :rel_type + }] +} + ad_proc -public simulation::template::ready_for_casting_p { {-workflow_id ""} {-role_empty_count ""} Index: openacs-4/packages/simulation/www/siminst/simulation-casting-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/Attic/simulation-casting-2.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/simulation/www/siminst/simulation-casting-2.tcl 15 Dec 2003 14:50:12 -0000 1.5 +++ openacs-4/packages/simulation/www/siminst/simulation-casting-2.tcl 16 Dec 2003 11:34:33 -0000 1.6 @@ -10,12 +10,9 @@ set context [list [list "." "SimInst"] $page_title] set package_id [ad_conn package_id] +subsite::get -array closest_subsite +set group_admin_url "${closest_subsite(url)}admin/group-types/one?group_type=group" -# TODO: only one aplication group per package - need different solution -set group_id [application_group::group_id_from_package_id -package_id $package_id] -set group_name [group::get_element -group_id $group_id -element group_name] -set group_options [list [list $group_name $group_id]] - # TODO: provide more sensible default dates? # Notification send could be start date minus some parameter set in_a_month_date [clock format [expr [clock seconds] + 3600*24*31] -format "%Y %m %d"] @@ -47,20 +44,28 @@ } {enroll_type:text(radio) {label "Enrollment type"} - {options {{Invite invite} {Open open}}} + {options {{"By invitation only" closed} {Open open}}} {value $sim_template(enroll_type)} } {casting_type:text(radio) {label "Casting type"} {options {{Automatic auto} {Group group} {Open open}}} {value $sim_template(casting_type)} } - {user_group:integer(checkbox),multiple,optional + {enroll_groups:integer(checkbox),multiple,optional + {label "Enroll all users in these groups"} + {options {[simulation::groups_eligible_for_casting]}} + {help_text {Use Group Administration to add groups}} + } + {invite_groups:integer(checkbox),multiple,optional {label "Invite all users in these groups"} - {options $group_options} - #TODO: this link should use a function to find the subsite path - {help_text {Use Group Administration to add groups}} + {options {[simulation::groups_eligible_for_casting]}} + {help_text {Use Group Administration to add groups}} } +} -on_request { + + set enroll_groups [simulation::template::get_parties -workflow_id $workflow_id -rel_type auto-enroll] + } -on_submit { # Convert dates to ANSI format foreach var_name {enroll_start enroll_end notification_date case_start case_end} { @@ -75,7 +80,8 @@ set sim_template(case_end) $case_end_ansi set sim_template(enroll_type) $enroll_type set sim_template(casting_type) $casting_type - set sim_template(parties $user_group + set sim_template(enroll_groups) $enroll_groups + set sim_template(invite_gropus) $invite_groups simulation::template::edit \ -workflow_id $workflow_id \