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.4 -r1.5 --- openacs-4/packages/simulation/www/simbuild/role-delete.tcl 23 Jan 2004 11:16:15 -0000 1.4 +++ openacs-4/packages/simulation/www/simbuild/role-delete.tcl 30 Nov 2004 21:09:16 -0000 1.5 @@ -10,12 +10,21 @@ } set package_id [ad_conn package_id] -set num_of_tasks [db_string task_count " -select count(*) + +set tasks [db_list tasks " +select action_id from workflow_actions wa where wa.assigned_role = :role_id +union +select task_id as action_id + from sim_task_recipients + where recipient = :role_id " ] + +set num_of_tasks [llength $tasks] + + workflow::role::get -role_id $role_id -array role_array set name $role_array(pretty_name) set workflow_id $role_array(workflow_id) @@ -26,8 +35,21 @@ if { [template::util::is_true $confirm_p] || $num_of_tasks == 0 } { permission::require_write_permission -object_id $workflow_id + + # confirm_p is true and we have tasks + if { $num_of_tasks > 0 } { + foreach task $tasks { + simulation::action::edit -operation delete -action_id $task + } + } + simulation::role::edit -operation "delete" -role_id $role_id - ad_returnredirect $return_url + + # Let's mark this template edited + set sim_type "dev_template" + + ad_returnredirect [export_vars -base "template-sim-type-update" { workflow_id sim_type return_url }] + } workflow::get -workflow_id $workflow_id -array sim_template_array