Index: openacs-4/contrib/packages/project-manager/tcl/task-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/tcl/Attic/task-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/project-manager/tcl/task-procs.tcl 3 May 2004 16:22:59 -0000 1.6 +++ openacs-4/contrib/packages/project-manager/tcl/task-procs.tcl 5 May 2004 19:04:54 -0000 1.7 @@ -1211,3 +1211,217 @@ ns_log Notice "Scheduling daily email notifications for project manager to 5:00 am" ad_schedule_proc -thread t -debug t -schedule_proc ns_schedule_daily "5 0" pm::task::email_status } + + + +ad_proc -public pm::task::email_alert { + -task_item_id:required + {-user_id ""} + {-assignee_id ""} + {-assignee_role_name ""} + {-edit_p "t"} + {-comment ""} + {-description ""} + {-old_description ""} + {-subject ""} + {-work ""} + {-work_min ""} + {-work_max ""} + {-project_name ""} + {-earliest_start ""} + {-earliest_finish ""} + {-latest_start ""} + {-latest_finish ""} + {-url ""} +} { + Sends out an email notification when changes have been made to a task + +
+ + If any of the following are missing, fills in from the database: + subject, work, work_min, work_max, project_name, earliest_start, + earliest_finish, latest_start, latest_finish + + @author Jade Rubick (jader@bread.com) + @creation-date 2004-05-03 + + @param task_item_id + + @param user_id The user making the change + + @param assignee_id The party_id of the user assigned to the task. + + @param assignee_role_name The role name for what the party is + assigned to do + + @param edit_p Is this an edited task, or a new one? t for edited, + f otherwise. + + @param description + + @param old_description + + @param subject The one line description of the task + + @param work Estimated hours work + + @param work_min Estimated minimimum hours work + + @param work_max Estimated maximum hours work + + @param project_name + + @param earliest_start + + @param earliest_finish + + @param latest_start + + @param latest_finish + + @param url Optionally, a URL that the user is directed to + + @return + + @error +} { + + set task_term [parameter::get -parameter "Taskname" -default "Task"] + set task_term_lower [parameter::get -parameter "taskname" -default "task"] + set use_uncertain_completion_times_p [parameter::get -parameter "UseUncertainCompletionTimesP" -default "0"] + + # from address + + if {![exists_and_not_null $user_id]} { + set user_id [ad_conn user_id] + } + + db_1row get_from_address_and_more { + SELECT + p.email as from_address, + p2.first_names || ' ' || p2.last_name as mod_username + FROM + parties p, + persons p2 + WHERE + p.party_id = :user_id and + p.party_id = p2.person_id + } + + # to address + + if {![exists_and_not_null assignee_id]} { + + # bug: we should get the list of assignees here. + ns_log Error "the proc pm::task::email_alert is not complete: assignee" + + } + + set to_address [db_string get_email "select email from parties where party_id = :assignee_id"] + + + # if they left out any of the task info, then we get it from the database + if { \ + ![exists_and_not_null subject] || \ + ![exists_and_not_null work] || \ + ![exists_and_not_null work_min] || \ + ![exists_and_not_null work_max] || \ + ![exists_and_not_null project_name] || \ + ![exists_and_not_null earliest_start] || \ + ![exists_and_not_null earliest_finish] || \ + ![exists_and_not_null latest_start] || \ + ![exists_and_not_null latest_finish] \ + } { + + db_1row get_task_info { + SELECT + t.title as subject, + to_char(t.earliest_start,'MM-DD-YYYY') as earliest_start, + to_char(t.earliest_finish,'MM-DD-YYYY') as earliest_finish, + to_char(t.latest_start,'MM-DD-YYYY') as latest_start, + to_char(t.latest_finish,'MM-DD-YYYY') as latest_finish, + t.estimated_hours_work as work, + t.estimated_hours_work_min as work_min, + t.estimated_hours_work_max as work_max, + t.percent_complete, + p.title as project_name + FROM + pm_tasks_revisionsx t, + cr_items i, + cr_items project, + pm_projectsx p + WHERE + t.item_id = :task_item_id and + t.revision_id = i.live_revision and + t.item_id = i.item_id and + t.parent_id = project.item_id and + project.item_id = p.item_id and + project.live_revision = p.revision_id + } + + } + + + if {[string equal $edit_p "t"]} { + set subject_out "Edited $task_term \#$task_item_id: $subject" + set intro_text "$mod_username edited this $task_term_lower" + } else { + set subject_out "New $task_term \#$task_item_id: $subject" + set intro_text "$mod_username assigned you to a new $task_term_lower" + } + + if {[empty_string_p $comment]} { + set comment_text "" + } else { + set comment_text "--------\nCOMMENT:\n--------\n$comment\n\n" + } + + if {[exists_and_not_null url]} { + set task_url $url + } else { + set task_url "unavailable" + } + + + + if {![string equal $description $old_description] && [string equal $edit_p t]} { + set description_out "$description \n\n-------\nOld description:\n-------\n\n[ad_html_to_text $old_description]" + + append intro_text "\nSee below to see the changes in the description" + + } else { + set description_out [ad_html_to_text $description] + } + + if {[string equal $use_uncertain_completion_times_p 1]} { + set estimated_work "\nHrs work (min): $work_min" + append estimated_work "\nHrs work (max): $work_max" + } else { + set estimated_work "\nHrs work: $work" + } + + set notification_text "$intro_text\n\n$comment_text-------------" + append notification_text "\nTask overview\n-------------" + append notification_text "\nTask ID: \#$task_item_id" + append notification_text "\nSubject: $subject" + append notification_text "\nProject: $project_name" + append notification_text "\nYour role: $assignee_role_name" + append notification_text "\nLink: $task_url" + append notification_text "\n\n\n\n---------------" + append notification_text "\nEstimated work:\n---------------$estimated_work" + append notification_text "\n\n------\nDates:" + append notification_text "\n------\nEarliest start: $earliest_start" + append notification_text "\nEarliest finish: $earliest_finish" + append notification_text "\nLatest start: $latest_start" + append notification_text "\nLatest finish *$latest_finish" + append notification_text "\n\n-----------\nDescription\n-----------" + append notification_text "\n$description_out" + + acs_mail_lite::send \ + -to_addr $to_address \ + -from_addr $from_address \ + -subject $subject_out \ + -body $notification_text + + +} Index: openacs-4/contrib/packages/project-manager/www/one.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/one.tcl,v diff -u -r1.31 -r1.32 --- openacs-4/contrib/packages/project-manager/www/one.tcl 27 Apr 2004 00:49:29 -0000 1.31 +++ openacs-4/contrib/packages/project-manager/www/one.tcl 5 May 2004 19:04:55 -0000 1.32 @@ -76,7 +76,7 @@ set original_project_id $project_id # for edits of tasks. We want to come back to here. -set return_url "[ad_conn url]?[ad_conn query]" +set return_url [ad_return_url -qualified] # --------------------------------------------------------------- # 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.11 -r1.12 --- openacs-4/contrib/packages/project-manager/www/task-assign-add-edit.tcl 30 Apr 2004 01:42:58 -0000 1.11 +++ openacs-4/contrib/packages/project-manager/www/task-assign-add-edit.tcl 5 May 2004 19:04:55 -0000 1.12 @@ -268,18 +268,6 @@ # ideally, we want to replace this with notifications, but I never # got it working correctly, so I use acs_mail_lite - db_1row get_from_address_and_more { - SELECT - p.email as from_address, - p2.first_names || ' ' || p2.last_name as mod_username - FROM - parties p, - persons p2 - WHERE - p.party_id = :user_id and - p.party_id = p2.person_id - } - foreach pl $party_list { regexp {(.*),(.*)} $pl match task_id_v num_value @@ -288,84 +276,31 @@ set r_id $assignment_role($pl) set p_id $assignment_party($pl) - set to_address [db_string get_email "select email from parties where party_id = :p_id"] - - if {[string equal $edit_p "t"]} { - set subject "Edited $task_term \#$t_id: $one_lines($t_id)" - set intro_text "$mod_username edited this $task_term_lower" - } else { - set subject "New $task_term \#$t_id: $one_lines($t_id)" - set intro_text "$mod_username assigned you to a new $task_term_lower" - } - # 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) - if {[empty_string_p $my_comment]} { - set comment_text "" - } else { - set comment_text "--------\nCOMMENT:\n--------\n$my_comment\n\n" - } + 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_name \ + -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 $return_url - 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 $descriptions($t_id) $my_old_description] && [string equal $edit_p t]} { - set description_out "$descriptions($t_id) \n\n-------\nCHANGES:\n-------\n\n[ad_html_to_text [pm::util::word_diff -old [ad_html_to_text $my_old_description] -new [ad_html_to_text $descriptions($t_id)] -split_by " " -start_new "" -end_new ""]]" - - append intro_text "\nSee below to see the changes in the description" - append description_out "\n\n\nkey: _deleted_ *new* text\n" - } else { - set description_out [ad_html_to_text $descriptions($t_id)] - } - - if {[string equal $use_uncertain_completion_times_p 1]} { - set estimated_work " -Hrs work (min): $est_hours_work_min($t_id) -Hrs work (max): $est_hours_work_max($t_id)" - } else { - set estimated_work " -Hrs work: $est_hours_work($t_id)" - -} - - - set notification_text "$intro_text\n\n$comment_text------------- -Task overview -------------- -Task ID: \#$t_id -Subject: $one_lines($t_id) -Project: $project_name -Your role: $role_oneline($r_id) -Link: $task_url - - - ---------------- -Estimated work: ----------------$estimated_work - ------- -Dates: ------- -Earliest start: $earliest_starts($item_id) -Earliest finish: $earliest_finishes($item_id) -Latest start: $latest_starts($item_id) -Latest finish $latest_finishes($item_id) - ------------ -Description ------------ -$description_out" - - - 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]" \ Index: openacs-4/contrib/packages/project-manager/www/task-one-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/task-one-postgresql.xql,v diff -u -r1.21 -r1.22 --- openacs-4/contrib/packages/project-manager/www/task-one-postgresql.xql 30 Apr 2004 21:32:33 -0000 1.21 +++ openacs-4/contrib/packages/project-manager/www/task-one-postgresql.xql 5 May 2004 19:04:55 -0000 1.22 @@ -94,7 +94,7 @@ r.role_id from pm_task_assignment a, - cc_users u, + acs_users_all u, pm_roles r where a.task_id = :task_id and Index: openacs-4/contrib/packages/project-manager/www/task-one.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/task-one.tcl,v diff -u -r1.27 -r1.28 --- openacs-4/contrib/packages/project-manager/www/task-one.tcl 30 Apr 2004 21:32:33 -0000 1.27 +++ openacs-4/contrib/packages/project-manager/www/task-one.tcl 5 May 2004 19:04:55 -0000 1.28 @@ -126,7 +126,7 @@ # how to get back here -set return_url "[ad_conn url]?[ad_conn query]" +set return_url [ad_return_url -qualified] set task_edit_url "task-add-edit?my_key=1&task_id=$task_id&project_item_id=$project_item_id&return_url=$return_url"