Index: openacs-4/contrib/packages/project-manager/tcl/project-manager-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/tcl/Attic/project-manager-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/contrib/packages/project-manager/tcl/project-manager-procs.tcl 3 Jun 2004 21:32:01 -0000 1.5 +++ openacs-4/contrib/packages/project-manager/tcl/project-manager-procs.tcl 10 Jun 2004 20:23:11 -0000 1.6 @@ -202,3 +202,203 @@ return $return_val } + + +ad_proc -public pm::util::general_comment_add { + {-object_id:required} + {-title:required} + {-comment ""} + {-mime_type:required} + {-user_id ""} + {-peeraddr ""} + {-type "task"} + {-send_email_p "f"} +} { + Adds a general comment to a task or project + + @author Jade Rubick (jader@bread.com) + @creation-date 2004-06-10 + + @param object_id The item_id for the task or project + + @param title The title for the comment + + @param comment The body of the comment + + @param mime_type The mime_type for the comment + + @param user_id Optional, the user_id making the comment. If left + empty, set to the ad_conn user_id + + @param peeraddr The IP address of the user making the comment. + If empty, set to the ad_conn peeraddr + + @param type Either task or project. + + @param send_email_p Whether or not to send out an email + notification t or f + + @return + + @error -1 if there is an error +} { + if {[empty_string_p $user_id]} { + set user_id [ad_conn user_id] + } + + if {[empty_string_p $peeraddr]} { + set peeraddr [ad_conn peeraddr] + } + + if {![string equal $type task] && ![string equal $type project]} { + return -1 + } + + # insert the comment into the database + set is_live [ad_parameter AutoApproveCommentsP {general-comments} {t}] + + set comment_id [db_nextval acs_object_id_seq] + + db_transaction { + db_exec_plsql insert_comment { + select acs_message__new ( + :comment_id, -- 1 p_message_id + NULL, -- 2 p_reply_to + current_timestamp, -- 3 p_sent_date + NULL, -- 4 p_sender + NULL, -- 5 p_rfc822_id + :title, -- 6 p_title + NULL, -- 7 p_description + :mime_type, -- 8 p_mime_type + NULL, -- 9 p_text + NULL, -- empty_blob() -- 10 p_data + 0, -- 11 p_parent_id + :object_id, -- 12 p_context_id + :user_id, -- 13 p_creation_user + :peeraddr, -- 14 p_creation_ip + 'acs_message', -- 15 p_object_type + :is_live -- 16 p_is_live + ) + } + + db_dml add_entry { + insert into general_comments + (comment_id, + object_id, + category) + values + (:comment_id, + :object_id, + null) + } + + db_1row get_revision { + select content_item__get_latest_revision(:comment_id) as revision_id + } + + db_dml set_content { + update cr_revisions + set content = :comment + where revision_id = :revision_id + } + + db_exec_plsql grant_permission { + begin + perform acs_permission__grant_permission ( + /* object_id => */ :comment_id, + /* grantee_id => */ :user_id, + /* privilege => */ 'read' + ); + + perform acs_permission__grant_permission ( + /* object_id => */ :comment_id, + /* grantee_id => */ :user_id, + /* privilege => */ 'write' + ); + return 0; + end; + } + } + + # now send out email + + if {[string equal $send_email_p t]} { + + # task + + if {[string equal $type task]} { + + set assignees [pm::task::assignee_email_list -task_item_id $object_id] + + if {[llength $assignees] > 0} { + + set to_address [join $assignees ", "] + + set from_address [db_string get_from_email "select email from parties where party_id = :user_id" -default "nobody@nowhere.com"] + + set task_url "[parameter::get_from_package_key -package_key acs-kernel -parameter SystemURL][ad_conn package_url]task-one?task_id=$object_id" + + set subject "Task comment: $title" + + set content "$task_url\n\n$comment" + + pm::util::email \ + -to_addr $to_address \ + -from_addr $from_address \ + -subject $subject \ + -body $content \ + -mime_type $mime_type + } + + } + + # project + if {[string equal $type project]} { + + # send out email + ns_log Notice "send project email" + + } + } + + + return 1 +} + + +ad_proc -public pm::util::email { + {-to_addr:required} + {-from_addr:required} + {-subject:required} + {-body ""} + {-mime_type "text/plain"} +} { + Wrapper to send out email, also converts body to text/plain format + + @author Jade Rubick (jader@bread.com) + @creation-date 2004-06-10 + + @param to_addr + + @param from_addr + + @param subject + + @param body + + @param mime_type + + @return + + @error +} { + + set nice_text [ad_html_text_convert -from $mime_type -to "text/plain" $body] + + acs_mail_lite::send \ + -to_addr "$to_addr" \ + -from_addr "$from_addr" \ + -subject "$subject" \ + -body "$nice_text" + +} 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.9 -r1.10 --- openacs-4/contrib/packages/project-manager/tcl/task-procs.tcl 3 Jun 2004 21:32:02 -0000 1.9 +++ openacs-4/contrib/packages/project-manager/tcl/task-procs.tcl 10 Jun 2004 20:23:11 -0000 1.10 @@ -106,7 +106,10 @@ set dependency_options_full "{\"--None--\" \"\"} " - if {!$edit_p} { + if {[string equal $edit_p t] || [string equal $edit_p 1]} { + # Do nothing + } else { + # now set up dependency options for {set j 1} {$j <= $number} {incr j} { @@ -119,7 +122,7 @@ # for editing tasks, we skip ourselves (because depending on # ourselves just sometimes isn't an option) - if {[string equal $edit_p t]} { + if {[string equal $edit_p t] || [string equal $edit_p 1]} { foreach key $keys { # make sure we're not dependent on ourselves @@ -834,6 +837,7 @@ to_char(r.latest_start, 'YYYY-MM-DD HH24:MI:SS') as latest_start_ansi, to_char(r.latest_finish, 'YYYY-MM-DD HH24:MI:SS') as latest_finish_ansi, r.description as task_description, + r.mime_type, project_revision.title as project_name FROM pm_tasks t, @@ -877,16 +881,7 @@ set latest_start [lc_time_fmt $latest_start_ansi "%x"] set latest_finish [lc_time_fmt $latest_finish_ansi "%x"] - set assignees [db_list get_assignees " - select - email - FROM - pm_task_assignment a, - parties p - WHERE - task_id = :task_item_id and - a.party_id = p.party_id - "] + set assignees [pm::task::assignee_email_list -task_item_id $task_item_id] if {[llength $assignees] > 0} { @@ -909,10 +904,12 @@ set notification_text "Task reopened, was $status_description\n\n" + set task_description [ad_html_text_convert -from $mime_type -to "text/plain" $task_description] + append notification_text " ------------- Task ID: \#$task_item_id -Description: $task_title +Subject: $task_title Project: $project_name Link: $task_url @@ -937,11 +934,11 @@ append notification_text "\n" - acs_mail_lite::send \ + pm::util::email \ -to_addr $to_address \ -from_addr $from_address \ -subject $subject \ - -body $notification_text + -body $notification_text } return @@ -978,6 +975,7 @@ to_char(r.latest_start, 'YYYY-MM-DD HH24:MI:SS') as latest_start_ansi, to_char(r.latest_finish, 'YYYY-MM-DD HH24:MI:SS') as latest_finish_ansi, r.description as task_description, + r.mime_type, project_revision.title as project_name FROM pm_tasks t, @@ -1022,16 +1020,7 @@ set latest_finish [lc_time_fmt $latest_finish_ansi "%x"] - set assignees [db_list get_assignees " - select - email - FROM - pm_task_assignment a, - parties p - WHERE - task_id = :task_item_id and - a.party_id = p.party_id - "] + set assignees [pm::task::assignee_email_list -task_item_id $task_item_id] if {[llength $assignees] > 0} { @@ -1072,7 +1061,7 @@ if {![string equal $time_stamp_pretty $last_time_stamp]} { append work_log "* $time_stamp_pretty\n\n" } - append work_log "[pm::util::string_truncate_and_pad -length 25 -string "$user_name:"] $description ($value hrs)\n" + append work_log "[pm::util::string_truncate_and_pad -length 15 -string "$user_name:"] $description ($value hrs)\n" set last_time_stamp $time_stamp_pretty } @@ -1090,6 +1079,8 @@ set notification_text "Task closed, was $status_description\n\n" + set task_description [ad_html_text_convert -from $mime_type -to "text/plain" $task_description] + append notification_text " ------------- Task ID: \#$task_item_id @@ -1119,7 +1110,7 @@ $task_description" - acs_mail_lite::send \ + pm::util::email \ -to_addr $to_address \ -from_addr $from_address \ -subject $subject \ @@ -1248,7 +1239,7 @@ set which_pile overdue } elseif {$slack_arr($task) < $PRESSING_THRESHOLD} { set which_pile pressing - } elseif {$slack_arr($task) < $PRESSING_THRESHOLD} { + } elseif {$slack_arr($task) < $LONGTERM_THRESHOLD} { set which_pile longterm } else { set which_pile "" @@ -1327,7 +1318,7 @@ lappend description $longterm_item } - acs_mail_lite::send \ + pm::util::send \ -to_addr $address \ -from_addr $address \ -subject $subject \ @@ -1367,7 +1358,9 @@ {-edit_p "t"} {-comment ""} {-description ""} + {-description_mime_type "text/plain"} {-old_description ""} + {-old_description_mime_type "text/plain"} {-subject ""} {-work ""} {-work_min ""} @@ -1528,14 +1521,16 @@ } + set description [ad_html_text_convert -from $description_mime_type -to "text/plain" $description] + set old_description [ad_html_text_convert -from $old_description_mime_type -to "text/plain" $old_description] 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]" + set description_out "$description \n\n-------\nOld description:\n-------\n\n$old_description" append intro_text "\nSee below to see the changes in the description" } else { - set description_out [ad_html_to_text $description] + set description_out $description } if {[string equal $use_uncertain_completion_times_p 1]} { @@ -1562,7 +1557,7 @@ append notification_text "\n\n-----------\nDescription\n-----------" append notification_text "\n$description_out" - acs_mail_lite::send \ + pm::util::email \ -to_addr $to_address \ -from_addr $from_address \ -subject $subject_out \ @@ -1647,3 +1642,32 @@ return $display_value } + + +ad_proc -public pm::task::assignee_email_list { + -task_item_id:required +} { + Returns a list of assignee email addresses + + @author Jade Rubick (jader@bread.com) + @creation-date 2004-06-10 + + @param task_item_id + + @return + + @error +} { + + return [db_list get_addresses { + SELECT + p.email + FROM + parties p, + pm_task_assignment a + WHERE + a.task_id = :task_item_id and + a.party_id = p.party_id + }] + +} Index: openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/task-add-edit.tcl,v diff -u -r1.36 -r1.37 --- openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 4 Jun 2004 16:19:45 -0000 1.36 +++ openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 10 Jun 2004 20:23:12 -0000 1.37 @@ -1016,9 +1016,6 @@ SELECT to_char(current_date, 'YYYY-MM-DD')"] - # insert the comment into the database - set is_live [ad_parameter AutoApproveCommentsP {general-comments} {t}] - # -------------------------------------------------------------- # each task we edit returns a task_revision_id # -------------------------------------------------------------- @@ -1124,68 +1121,16 @@ # add in general comments for the task if {![empty_string_p $p_comment]} { + + pm::util::general_comment_add \ + -object_id $p_task_item_id \ + -title "$p_task_title" \ + -comment "$p_comment" \ + -mime_type "$p_comment_type" \ + -user_id $user_id \ + -peeraddr $peeraddr \ + -send_email_p "f" - set comment_id [db_nextval acs_object_id_seq] - - db_transaction { - db_exec_plsql insert_comment { - select acs_message__new ( - :comment_id, -- 1 p_message_id - NULL, -- 2 p_reply_to - current_timestamp, -- 3 p_sent_date - NULL, -- 4 p_sender - NULL, -- 5 p_rfc822_id - :p_task_title, -- 6 p_title - NULL, -- 7 p_description - :p_comment_type, -- 8 p_mime_type - NULL, -- 9 p_text - NULL, -- empty_blob(), -- 10 p_data - 0, -- 11 p_parent_id - :p_task_item_id, -- 12 p_context_id - :user_id, -- 13 p_creation_user - :peeraddr, -- 14 p_creation_ip - 'acs_message', -- 15 p_object_type - :is_live -- 16 p_is_live - ) - } - - db_dml add_entry { - insert into general_comments - (comment_id, - object_id, - category) - values - (:comment_id, - :p_task_item_id, - null) - } - - db_1row get_revision { - select content_item__get_latest_revision(:comment_id) as revision_id - } - - db_dml set_content { - update cr_revisions - set content = :p_comment - where revision_id = :revision_id - } - - db_exec_plsql grant_permission { - begin - perform acs_permission__grant_permission ( - /* object_id => */ :comment_id, - /* grantee_id => */ :user_id, - /* privilege => */ 'read' - ); - perform acs_permission__grant_permission ( - /* object_id => */ :comment_id, - /* grantee_id => */ :user_id, - /* privilege => */ 'write' - ); - return 0; - end; - } - } } } 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.31 -r1.32 --- openacs-4/contrib/packages/project-manager/www/task-one.tcl 3 Jun 2004 21:32:13 -0000 1.31 +++ openacs-4/contrib/packages/project-manager/www/task-one.tcl 10 Jun 2004 20:23:12 -0000 1.32 @@ -135,7 +135,7 @@ set comments [general_comments_get_comments -print_content_p 1 -print_attachments_p 1 $task_id "[ad_conn url]?task_id=$task_id"] -set comments_link [general_comments_create_link -object_name "$task_term: $task_info(task_title)" -link_text "Add a comment" -context_id $package_id $task_id "[ad_conn url]?task_id=$task_id"] +set comments_link "Add comment" set print_link "task-print?&task_id=$task_id&project_item_id=$task_info(project_item_id)"