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.4 -r1.5 --- openacs-4/packages/logger/tcl/entry-procs.tcl 27 Mar 2004 01:08:20 -0000 1.4 +++ openacs-4/packages/logger/tcl/entry-procs.tcl 3 Jun 2004 21:08:24 -0000 1.5 @@ -17,6 +17,9 @@ {-time_stamp:required} {-description ""} {-party_id ""} + {-task_item_id ""} + {-project_item_id ""} + {-update_status_p:boolean} } {
Create a logger entry. @@ -37,6 +40,16 @@ @param party_id The party that is entering the logged entry. Defaults to ad_conn user_id if nothing is passed in + @param task_item_id If passed in, the project-manager task + to log time against + + @param project_item_id If passed in, the project-manager project + + @param update_status_p If set, updates the project manager project + status, using pm::project::compute_status + + @see pm::project::compute_status + @return The entry_id of the created project. @author Peter Marklund @@ -52,27 +65,108 @@ # The creator can admin his own entry permission::grant -party_id $creation_user -object_id $entry_id -privilege admin + # if we have a task_id, then we need to note that this + # entry is logged to a particular task. + if {[exists_and_not_null task_item_id]} { + db_dml delete_logger_map { + DELETE FROM + pm_task_logger_proj_map + WHERE + logger_entry = :entry_id + } + + db_dml add_logger_map " + INSERT INTO + pm_task_logger_proj_map + (task_item_id, + logger_entry) + VALUES + (:task_item_id, + :entry_id) + " + + pm::task::update_hours \ + -task_item_id $task_item_id \ + -update_tasks_p t + + if { $update_status_p } { + pm::project::compute_status $project_item_id + } + } + + return $entry_id } ad_proc -public logger::entry::edit { {-entry_id:required} {-value:required} {-time_stamp:required} - {-description ""} + {-description ""} + {-task_item_id ""} + {-project_item_id ""} + {-update_status:boolean} } { Edit a entry. @param entry_id The id of the entry to edit @param value The new value of the entry @param time_stamp The new time stamp of the entry @param description The new description of the entry + @param task_item_id If passed in, the project-manager task + to log time against + @param project_item_id If passed in, the project-manager project + + @param update_status If set, updates the project manager project + status, using pm::project::compute_status + + @see pm::project::compute_status + @return The return value from db_dml @author Peter Marklund } { db_dml update_entry {} + + # all ignored if project-manager isn't installed and linked + + if {[logger::util::project_manager_linked_p]} { + + # delete any linked in tasks (an entry could be linked to a + # task, and the user could decide to log against the project only) + db_dml delete_logger_map { + DELETE FROM + pm_task_logger_proj_map + WHERE + logger_entry = :entry_id + } + + # if we have a task_id, then we need to note that this + # entry is logged to a particular task. + if {[exists_and_not_null task_item_id]} { + + db_dml add_logger_map " + INSERT INTO + pm_task_logger_proj_map + (task_item_id, + logger_entry) + VALUES + (:task_item_id, + :entry_id) + " + + pm::task::update_hours \ + -task_item_id $task_item_id \ + -update_tasks_p t + + } + + if { $update_status_p } { + pm::project::compute_status $project_item_id + } + + } } ad_proc -public logger::entry::delete { @@ -110,3 +204,23 @@ db_1row select_entry {} -column_array entry_array } + + +ad_proc -public logger::entry::task_id { + -entry_id:required +} { + Returns the task_id corresponding to an entry if one exists + + This should only be called if project manager is installed. + + @author Jade Rubick (jader@bread.com) + @creation-date 2004-05-28 + + @param entry_id + + @return empty string if no task corresponds to this entry + + @error +} { + return [db_string task_id { } -default ""] +}