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.3 -r1.3.8.1 --- openacs-4/packages/logger/tcl/entry-procs.tcl 1 May 2003 10:00:24 -0000 1.3 +++ openacs-4/packages/logger/tcl/entry-procs.tcl 17 Sep 2004 21:06:04 -0000 1.3.8.1 @@ -16,6 +16,10 @@ {-value:required} {-time_stamp:required} {-description ""} + {-party_id ""} + {-task_item_id ""} + {-project_item_id ""} + {-update_status:boolean} } {

Create a logger entry. @@ -33,39 +37,136 @@ @param time_stamp The point in time the measurment is tied to. Must be on ANSI format. Can be a date or a date and a time. @param description A short (less than 4000 chars) text describing the entry. + @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 } { logger::util::set_vars_from_ad_conn {creation_user creation_ip} + + if {[exists_and_not_null party_id]} { + set creation_user $party_id + } set entry_id [db_exec_plsql insert_entry {}] # The creator can admin his own entry - permission::grant -party_id [ad_conn user_id] -object_id $entry_id -privilege admin + 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 { @@ -103,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 ""] +}