Index: openacs-4/contrib/obsolete-packages/acs-workflow/www/admin/task-edit-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/www/admin/task-edit-2.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/obsolete-packages/acs-workflow/www/admin/task-edit-2.tcl 13 Mar 2001 22:59:27 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/acs-workflow/www/admin/task-edit-2.tcl 19 Nov 2001 18:29:29 -0000 1.2 @@ -1,40 +1,78 @@ ad_page_contract { Edit task. } { - workflow_key - transition_key - transition_name - trigger_type + workflow_key:notnull + transition_key:notnull + transition_name:notnull + trigger_type:notnull + role_key:allhtml,optional + role_name:optional estimated_minutes:integer,optional - {return_url "define?[export_url_vars workflow_key transition_key]"} + instructions:optional + {return_url "define?[export_vars -url {workflow_key transition_key}]"} + cancel:optional + {context_key "default"} } -db_dml transition_update { - update wf_transitions - set transition_name = :transition_name, - trigger_type = :trigger_type - where workflow_key = :workflow_key - and transition_key = :transition_key +if { [info exists cancel] && ![empty_string_p $cancel] } { + # User hit cancel + ad_returnredirect $return_url + return } -if { [info exists estimated_minutes] } { - set num_rows [db_string num_rows "select count(*) from wf_context_transition_info where workflow_key = :workflow_key and transition_key = :transition_key and context_key = 'default'"] - - if { $num_rows == 0 } { - db_dml insert_estimated_minmutes { - insert into wf_context_transition_info - (workflow_key, transition_key, context_key, estimated_minutes) - values (:workflow_key, :transition_key, 'default', :estimated_minutes) +db_transaction { + if { ![info exists role_key] } { + set role_key [wf_add_role -workflow_key $workflow_key -role_name $role_name] + } + + if { ![string equal $role_key ""] } { + db_dml transition_update { + update wf_transitions + set transition_name = :transition_name, + trigger_type = :trigger_type, + role_key = :role_key + where workflow_key = :workflow_key + and transition_key = :transition_key } } else { - db_dml update_estimated_minutes { - update wf_context_transition_info set estimated_minutes = :estimated_minutes - where workflow_key = :workflow_key and transition_key = :transition_key and context_key = 'default' + db_dml transition_update { + update wf_transitions + set transition_name = :transition_name, + trigger_type = :trigger_type + where workflow_key = :workflow_key + and transition_key = :transition_key } } + + if { [info exists estimated_minutes] || [info exists instructions] } { + set num_rows [db_string num_rows "select count(*) from wf_context_transition_info where workflow_key = :workflow_key and transition_key = :transition_key and context_key = 'default'"] + + if { $num_rows == 0 } { + db_dml insert_estimated_minmutes { + insert into wf_context_transition_info + (workflow_key, transition_key, context_key, estimated_minutes, instructions) + values (:workflow_key, :transition_key, 'default', :estimated_minutes, :instructions) + } + } else { + db_dml update_estimated_minutes { + update wf_context_transition_info + set estimated_minutes = :estimated_minutes, + instructions = :instructions + where workflow_key = :workflow_key + and transition_key = :transition_key + and context_key = 'default' + } + } + } } wf_workflow_changed $workflow_key +if { [string equal $role_key ""] } { + set return_url "task-edit?[export_vars -url {workflow_key transition_key context_key return_url {new_role_p 1}}]" +} + + + ad_returnredirect $return_url