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.9 -r1.10 --- openacs-4/contrib/packages/project-manager/www/task-assign-add-edit.tcl 20 Apr 2004 21:12:21 -0000 1.9 +++ openacs-4/contrib/packages/project-manager/www/task-assign-add-edit.tcl 27 Apr 2004 00:49:29 -0000 1.10 @@ -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,17 +18,18 @@ 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 + {return_url ""} } -properties { tasks:multirow num:multirow - context_bar:onevalue + context:onevalue title:onevalue task_term_lower:onevalue project_item_id:onevalue @@ -38,20 +39,39 @@ # --------------------------------------------------------------- # +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 + } +} + # hack to get around lack of multiple hidden support with ad_form set process_task_id [string map {"-" " "} $process_task_id] set revisions [string map {"-" " "} $revisions] set task_id [string map {"-" " "} $task_id] + +# 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] + } +} + 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 } @@ -74,7 +94,7 @@ # permissions 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"] permission::require_permission -party_id $user_id -object_id $package_id -privilege create @@ -96,6 +116,10 @@ {process_task_id:text(hidden) {value $process_task_id_pass}} + {return_url:text(hidden) + {value $return_url} + } + {revisions:text(hidden) {value $revisions_pass}} @@ -113,17 +137,15 @@ } -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 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 @@ -197,6 +219,11 @@ set role_oneline($val) $des } + # 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"] + foreach pl $party_list { regexp {(.*),(.*)} $pl match task_id_v num_value @@ -205,8 +232,12 @@ set r_id $assignment_role($pl) set p_id $assignment_party($pl) - set subject "New Task \#$t_id: $one_lines($t_id)" + 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 +254,7 @@ Description: $one_lines($t_id) Project: $project_name Your role: $role_oneline($r_id) +Link: $task_url --------------- Estimated work: @@ -231,7 +263,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 +273,37 @@ ----------- $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 + db_dml add_assignment { } } } -edit_data { + # I believe this block is never executed. + # do something #role_id #party_id @@ -334,7 +376,11 @@ } -after_submit { - ad_returnredirect "one?project_item_id=$project_item_id" + if {[exists_and_not_null return_url]} { + ad_returnredirect $return_url + } else { + ad_returnredirect "one?project_item_id=$project_item_id" + } ad_script_abort } @@ -359,12 +405,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]