Index: openacs-4/contrib/packages/project-manager/www/task-assign-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/task-assign-add-edit.tcl,v diff -u -r1.8.2.1 -r1.8.2.2 --- openacs-4/contrib/packages/project-manager/www/task-assign-add-edit.tcl 12 Mar 2004 19:28:03 -0000 1.8.2.1 +++ openacs-4/contrib/packages/project-manager/www/task-assign-add-edit.tcl 20 May 2004 17:30:05 -0000 1.8.2.2 @@ -6,7 +6,7 @@ @creation-date 2003-09-10 @cvs-id $Id$ - @return context_bar Context bar. + @return context Context bar. @return title Page title. @return num a multirow that contains the number of assignments @return tasks a multirow that contains the ticket info @@ -18,40 +18,118 @@ my_key:integer,optional {process_task_id:multiple,optional ""} - task_id:multiple,optional + {task_id:multiple,optional ""} revisions:multiple - {project_item_id:integer ""} role_id:array,optional party_id:array,optional +<<<<<<< task-assign-add-edit.tcl + {return_url ""} +======= + {return_url ""} + {edit_p "t"} + {comment_list ""} + {old_description:html ""} +>>>>>>> 1.15 } -properties { tasks:multirow num:multirow - context_bar:onevalue + context:onevalue title:onevalue task_term_lower:onevalue - project_item_id:onevalue } + # --------------------------------------------------------------- # +<<<<<<< task-assign-add-edit.tcl +if {[string equal [llength task_id] 1] && [exists_and_not_null return_url]} { + + # if the task is closed, then we don't need to reassign things + if {[string equal 0 [pm::task::open_p -task_item_id $task_id]]} { + ad_returnredirect $return_url + } +} + +======= +>>>>>>> 1.15 # hack to get around lack of multiple hidden support with ad_form +set old_description [string map {"-" " "} $old_description] +set comment_list [string map {"-" " "} $comment_list] set process_task_id [string map {"-" " "} $process_task_id] set revisions [string map {"-" " "} $revisions] set task_id [string map {"-" " "} $task_id] +<<<<<<< task-assign-add-edit.tcl + +# The number of assignments is set to 9, or the number of assignees + +# 2 if there are more than 5 assignees +set NUMBER_OF_ASSIGNMENTS 9 + +# find out the maximum number of assignees +db_foreach get_count "select count(task_id) as my_count from pm_task_assignment where task_id in ([join $task_id ", "]) group by task_id" { + if {$my_count > $NUMBER_OF_ASSIGNMENTS} { + set NUMBER_OF_ASSIGNMENTS [expr $my_count + 2] + } +} + +======= + +# We have passed in a list of comments and old_description. We will +# key them by task number + +set index 0 +foreach t_id $task_id { + set comment_value($t_id) [lindex $comment_list $index] + set old_description_value($t_id) [lindex $old_description $index] + incr index +} + + + + +if {[string equal [llength task_id] 1] && [exists_and_not_null return_url]} { + + set open_p 0 + foreach t_id $task_id { + + # if the task is closed, then we don't need to reassign things + if {[string equal 1 [pm::task::open_p -task_item_id $t_id]]} { + set open_p 1 + } + } + + if {[string equal $open_p 0]} { + ad_returnredirect $return_url + } + +} + + + +# The number of assignments is set to 9, or the number of assignees + +# 2 if there are more than 5 assignees +set NUMBER_OF_ASSIGNMENTS 9 + +# find out the maximum number of assignees +db_foreach get_count "select count(task_id) as my_count from pm_task_assignment where task_id in ([join $task_id ", "]) group by task_id" { + if {$my_count > $NUMBER_OF_ASSIGNMENTS} { + set NUMBER_OF_ASSIGNMENTS [expr $my_count + 2] + } +} + +>>>>>>> 1.15 db_multirow tasks get_task_info { } # create a multirow we can use to iterate template::multirow create num number -# currently hardcoded the number of assignments -for {set i 0} {$i <= 5} {incr i} { +for {set i 0} {$i <= $NUMBER_OF_ASSIGNMENTS} {incr i} { template::multirow append num $i } @@ -73,8 +151,19 @@ # permissions +<<<<<<< task-assign-add-edit.tcl set title "Add $task_term_lower assignments" -set context_bar [ad_context_bar [list "one?project_item_id=$project_item_id" "One $project_term"] "New $task_term dependency"] +set context [list [list "one?project_item_id=$project_item_id" "One $project_term"] "New $task_term dependency"] +======= +if {[string equal $edit_p "t"]} { + set title "Edit $task_term_lower assignments" + set context [list "Edit $task_term assignments"] +} else { + set title "Add $task_term_lower assignments" + set context [list "Add $task_term assignments"] +} + +>>>>>>> 1.15 permission::require_permission -party_id $user_id -object_id $package_id -privilege create @@ -87,6 +176,8 @@ set process_task_id_pass [string map {" " "-"} $process_task_id] set revisions_pass [string map {" " "-"} $revisions] +set comment_pass [string map {" " "-"} $comment_list] +set old_description_pass [string map {" " "-"} $old_description] set task_id_pass [string map {" " "-"} $task_id] ad_form -name add_edit -form { @@ -96,34 +187,42 @@ {process_task_id:text(hidden) {value $process_task_id_pass}} + {return_url:text(hidden) + {value $return_url} + } + {revisions:text(hidden) {value $revisions_pass}} {task_id:text(hidden) {value $task_id_pass}} - {project_item_id:text(hidden) - {value $project_item_id}} - - + {comment_list:text(hidden) + {value $comment_pass}} + + {old_description:text(hidden) + {value $old_description_pass}} + + {edit_p:text(hidden) + {value $edit_p}} + } -on_submit { set user_id [ad_conn user_id] set peeraddr [ad_conn peeraddr] } -new_data { - #role_id - #party_id - + # we have to decode these items back into lists set process_task_id [string map {"-" " "} $process_task_id] set revisions [string map {"-" " "} $revisions] set task_id [string map {"-" " "} $task_id] + # we get more information about the tasks, for notification purposes db_foreach get_more_task_info {} { + set project_names($item_id) $project_name set one_lines($item_id) $one_line set descriptions($item_id) $description - set end_dates_pretty($item_id) [lc_time_fmt $end_date_ansi "%x"] set est_hours_work($item_id) $estimated_hours_work set est_hours_work_min($item_id) $estimated_hours_work_min set est_hours_work_max($item_id) $estimated_hours_work_max @@ -188,15 +287,24 @@ db_dml delete_assignments { } - set project_name [db_string get_project_name { } -default "N/A"] - # set up role names foreach r [db_list_of_lists get_roles { }] { set des [lindex $r 0] set val [lindex $r 1] set role_oneline($val) $des } +<<<<<<< task-assign-add-edit.tcl + # ideally, we want to replace this with notifications, but I never + # got it working correctly, so I use acs_mail_lite + + set from_address [db_string get_email "select email from parties where party_id = :user_id"] + +======= + # ideally, we want to replace this with notifications, but I never + # got it working correctly, so I use acs_mail_lite + +>>>>>>> 1.15 foreach pl $party_list { regexp {(.*),(.*)} $pl match task_id_v num_value @@ -205,8 +313,13 @@ set r_id $assignment_role($pl) set p_id $assignment_party($pl) - set subject "New Task \#$t_id: $one_lines($t_id)" +<<<<<<< task-assign-add-edit.tcl + set to_address [db_string get_email "select email from parties where party_id = :p_id"] + set subject "Task \#$t_id: $one_lines($t_id)" + + set task_url "[parameter::get_from_package_key -package_key acs-kernel -parameter SystemURL][ad_conn package_url]task-one?task_id=$t_id" + if {[string equal $use_uncertain_completion_times_p 1]} { set estimated_work " Hrs work (min): $est_hours_work_min($t_id) @@ -223,6 +336,7 @@ Description: $one_lines($t_id) Project: $project_name Your role: $role_oneline($r_id) +Link: $task_url --------------- Estimated work: @@ -231,7 +345,6 @@ ------ Dates: ------ -Deadline: [ad_decode $end_dates_pretty($t_id) "" "None" $end_dates_pretty($t_id)] Earliest start: $earliest_starts($item_id) Earliest finish: $earliest_finishes($item_id) Latest start: $latest_starts($item_id) @@ -242,26 +355,79 @@ ----------- $descriptions($t_id)" - #notification::request::new \ - # -type_id "[notification::type::get_type_id -short_name pm_task_notif]" \ - # -object_id $t_id \ - # -user_id $p_id \ - # -interval_id [notification::interval::get_id_from_name -name instant] \ - # -delivery_method_id [notification::delivery::get_id -short_name email] - notification::new \ - -type_id [notification::type::get_type_id -short_name pm_task_notif] \ - -object_id $t_id \ - -response_id $t_id \ - -notif_subject $subject \ - -notif_text $notification_text + acs_mail_lite::send \ + -to_addr $to_address \ + -from_addr $from_address \ + -subject $subject \ + -body $notification_text + # we only want to do this for new people + # notification::request::new \ + # -type_id "[notification::type::get_type_id -short_name pm_task_notif]" \ + # -object_id $t_id \ + # -user_id $p_id \ + # -interval_id [notification::interval::get_id_from_name -name instant] \ + # -delivery_method_id [notification::delivery::get_id -short_name email] + + # send out notifications + # notification::new \ + # -type_id [notification::type::get_type_id -short_name pm_task_notif] \ + # -object_id $t_id \ + # -response_id $t_id \ + # -notif_subject $subject \ + # -notif_text $notification_text +======= + # If there is a comment for this task, then display it + # prominently in the email + set my_comment $comment_value($t_id) + set my_old_description $old_description_value($t_id) + + pm::task::email_alert \ + -task_item_id $t_id \ + -user_id $user_id \ + -assignee_id $p_id \ + -assignee_role_name $role_oneline($r_id) \ + -edit_p $edit_p \ + -comment $my_comment \ + -description $descriptions($t_id) \ + -old_description $my_old_description \ + -subject $one_lines($t_id) \ + -work_min $est_hours_work_min($t_id) \ + -work_max $est_hours_work_max($t_id) \ + -work $est_hours_work($t_id) \ + -project_name $project_names($t_id) \ + -earliest_start $earliest_starts($item_id) \ + -earliest_finish $earliest_finishes($item_id) \ + -latest_start $latest_starts($item_id) \ + -latest_finish $latest_finishes($item_id) \ + -url "[parameter::get_from_package_key -package_key acs-kernel -parameter SystemURL][ad_conn package_url]task-one?task_id=$t_id" + + # we only want to do this for new people + # notification::request::new \ + # -type_id "[notification::type::get_type_id -short_name pm_task_notif]" \ + # -object_id $t_id \ + # -user_id $p_id \ + # -interval_id [notification::interval::get_id_from_name -name instant] \ + # -delivery_method_id [notification::delivery::get_id -short_name email] + + # send out notifications + # notification::new \ + # -type_id [notification::type::get_type_id -short_name pm_task_notif] \ + # -object_id $t_id \ + # -response_id $t_id \ + # -notif_subject $subject \ + # -notif_text $notification_text +>>>>>>> 1.15 + db_dml add_assignment { } } } -edit_data { + # I believe this block is never executed. + # do something #role_id #party_id @@ -334,7 +500,24 @@ } -after_submit { - ad_returnredirect "one?project_item_id=$project_item_id" +<<<<<<< task-assign-add-edit.tcl + if {[exists_and_not_null return_url]} { + ad_returnredirect $return_url + } else { + ad_returnredirect "one?project_item_id=$project_item_id" + } +======= + if {[exists_and_not_null return_url]} { + ad_returnredirect $return_url + } else { + + if {[llength $task_id] > 1} { + ad_returnredirect "tasks" + } else { + ad_returnredirect "task-one?task_id=$task_id" + } + } +>>>>>>> 1.15 ad_script_abort } @@ -359,12 +542,19 @@ lappend users_values $pid } + } + + # if nobody is assigned to this task yet, we want to, by default, + # add in the person entering the task (as a watcher) + if {[llength $users_values] < 1} { + lappend users_values [ad_conn user_id] + lappend roles_values [db_string get_watcher "select role_id from pm_roles where is_observer_p = 't' limit 1"] } set users_length [string length $users_values] set roles_length [string length $roles_values] - for {set i 0} {$i <= 5} {incr i} { + for {set i 0} {$i <= $NUMBER_OF_ASSIGNMENTS} {incr i} { if {$i < $users_length && $i < $roles_length} { set uv [lindex $users_values $i]