Index: openacs-4/packages/logger/tcl/entry-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/entry-procs.tcl,v
diff -u -r1.10 -r1.11
--- openacs-4/packages/logger/tcl/entry-procs.tcl 13 Jun 2006 04:35:47 -0000 1.10
+++ openacs-4/packages/logger/tcl/entry-procs.tcl 9 Oct 2006 20:27:24 -0000 1.11
@@ -239,53 +239,40 @@
set user_id [ad_conn user_id]
set peeraddr [ad_conn peeraddr]
+ set package_id [ad_conn package_id]
pm::task::update_percent \
-task_item_id $task_item_id \
-percent_complete $new_percent_complete
# figure out what changed and notify everyone
- set task_item_id_array(1) $task_item_id
- set number 1
- set comments(1) ""
- set comments_mime_type(1) "text/html"
+ # if the old_percent was >= 100 and now less, or
+ # the old_percent was < 100 and is now more, then
+ # we need to send out an email to notify everyone
- pm::task::what_changed \
- -task_item_id_array task_item_id_array \
- -number $number \
- -comments_array comments \
- -comments_mime_type_array comments_mime_type
-
- if {[string length $comments(1)] > 0} {
-
- # add comment to task
- pm::util::general_comment_add \
- -object_id $task_item_id \
- -title [pm::task::name -task_item_id $task_item_id] \
- -comment $comments(1) \
- -mime_type $comments_mime_type(1) \
- -user_id $user_id \
- -peeraddr $peeraddr \
- -type "task" \
- -send_email_p f
-
- # if the old_percent was >= 100 and now less, or
- # the old_percent was < 100 and is now more, then
- # we need to send out an email to notify everyone
-
- if { \
- $old_percent_complete >= 100 && \
- $new_percent_complete < 100 || \
- $old_percent_complete < 100 && \
- $new_percent_complete >= 100} {
-
- # send email notification
- pm::task::email_alert \
- -task_item_id $task_item_id \
- -edit_p t \
- -comment $comments(1) \
- -comment_mime_type $comments_mime_type(1)
- }
+ set old $old_percent_complete
+ set new $new_percent_complete
+
+ set changes [list]
+ if {![string equal $old $new]} {
+ if {$new >= 100 && $old < 100} {
+ lappend changes "Closing task"
+ } elseif {$new < 100 && $old >= 100} {
+ lappend changes "Reopening task"
+ }
}
+
+ if {[llength $changes] > 0 && ![parameter::get -parameter "LogCommentsP" -default "0" -package_id $package_id]} {
+ pm::util::general_comment_add \
+ -object_id $task_item_id \
+ -title [pm::task::name -task_item_id $task_item_id] \
+ -comment "
" \
+ -mime_type text/html \
+ -user_id $user_id \
+ -peeraddr $peeraddr \
+ -type "task" \
+ -send_email_p t \
+ -to_party_ids [db_string assignees "select party_id from pm_task_assignment where task_id =:task_item_id" -default ""]
+ }
}
Index: openacs-4/packages/logger/www/log.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/log.tcl,v
diff -u -r1.40 -r1.41
--- openacs-4/packages/logger/www/log.tcl 12 Sep 2006 21:02:00 -0000 1.40
+++ openacs-4/packages/logger/www/log.tcl 9 Oct 2006 20:27:24 -0000 1.41
@@ -412,7 +412,8 @@
# logging against project manager
if {[exists_and_not_null pm_task_id]} {
- set old_percent_complete $percent_complete
+ set task_rev_id [content::item::get_best_revision -item_id $pm_task_id]
+ set old_percent_complete [db_string get_old_percent "select percent_complete from pm_tasks_revisions tr where tr.task_revision_id = :task_rev_id"]
logger::entry::pm_before_change \
-task_item_id $pm_task_id
@@ -443,7 +444,8 @@
# logging against project manager
if {[exists_and_not_null pm_task_id]} {
- set old_percent_complete $percent_complete
+ set task_rev_id [content::item::get_best_revision -item_id $pm_task_id]
+ set old_percent_complete [db_string get_old_percent "select percent_complete from pm_tasks_revisions tr where tr.task_revision_id = :task_rev_id"]
logger::entry::pm_before_change \
-task_item_id $pm_task_id
@@ -459,7 +461,7 @@
if {[exists_and_not_null pm_task_id]} {
- pm::task::pm_after_change \
+ logger::entry::pm_after_change \
-task_item_id $pm_task_id \
-new_percent_complete $percent_complete \
-old_percent_complete $old_percent_complete
@@ -474,6 +476,34 @@
[category::ad_form::get_categories \
-container_object_id $the_project_id]
}
+
+ if {[exists_and_not_null pm_task_id]} {
+ set log_comment_p [parameter::get -parameter "LogCommentsP" -default "0" -package_id $package_id]
+ if {$log_comment_p} {
+ # add comment to task
+ set title [_ logger.log_comment_title]
+
+ if {![string equal $old_percent_complete $percent_complete]} {
+ if {$percent_complete >= 100 && $old_percent_complete < 100} {
+ append title ". Closing task"
+ } elseif {$percent_complete < 100 && $old_percent_complete >= 100} {
+ append title ". Reopening task"
+ }
+ }
+
+ pm::util::general_comment_add \
+ -object_id $pm_task_id \
+ -title "$title" \
+ -comment $description \
+ -mime_type "text/plain" \
+ -user_id $current_user_id \
+ -peeraddr [ad_conn peeraddr] \
+ -type "task" \
+ -send_email_p t \
+ -to_party_ids [db_string assignees "select party_id from pm_task_assignment where task_id =:pm_task_id" -default ""]
+ }
+ }
+
# Remember this date, as the next entry is likely to be for the same date
ad_set_client_property logger time_stamp $time_stamp
@@ -484,6 +514,8 @@
} else {
ad_returnredirect -message "[_ logger.lt_Log_entry_for_value_v]" [export_vars -base [ad_conn url] { project_id variable_id pm_project_id pm_task_id}]
}
+
+
ad_script_abort
} -edit_data {
@@ -493,7 +525,8 @@
if {[exists_and_not_null pm_task_id]} {
- set old_percent_complete $percent_complete
+ set task_rev_id [content::item::get_best_revision -item_id $pm_task_id]
+ set old_percent_complete [db_string get_old_percent "select percent_complete from pm_tasks_revisions tr where tr.task_revision_id = :task_rev_id"]
logger::entry::pm_before_change \
-task_item_id $pm_task_id
@@ -549,7 +582,6 @@
} -after_submit {
ad_returnredirect -message "[_ logger.Log_entry_modified]" $return_url
-
if {![string equal $pm_task_id -1]} {
pm::project::compute_status $pm_project_id
}