Index: openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql,v diff -u -r1.13 -r1.14 --- openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql 5 Jun 2006 11:57:30 -0000 1.13 +++ openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql 24 Oct 2006 13:18:04 -0000 1.14 @@ -200,6 +200,13 @@ + + + select pm_project__get_root_folder (:package_id, 'f') + + + + update Index: openacs-4/packages/project-manager/tcl/project-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/project-manager/tcl/project-procs.tcl,v diff -u -r1.36 -r1.37 --- openacs-4/packages/project-manager/tcl/project-procs.tcl 11 Aug 2006 14:55:23 -0000 1.36 +++ openacs-4/packages/project-manager/tcl/project-procs.tcl 24 Oct 2006 13:18:04 -0000 1.37 @@ -252,29 +252,63 @@ set planned_end_date "" } - # create a project manager project - set project_revision [db_exec_plsql new_project_item { *SQL }] + # If we do not have a parent_id set the parent_id to the root folder_id + if {$parent_id eq ""} { + set parent_id [pm::project::root_folder -package_id $package_id] - set project_item_id [pm::project::get_project_item_id \ - -project_id $project_revision] + # Set the context_id to the package_id if this is not a subproject. + # Otherwise permission inheritance won't work. + set context_id $package_id + } else { + set context_id $parent_id + } - set project_role [pm::role::default] + # create a project manager project + set item_id [db_string acs "select nextval('t_acs_object_id_seq') from dual"] + set project_item_id [content::item::new \ + -parent_id $parent_id \ + -content_type {pm_project} \ + -name $item_id \ + -package_id $package_id \ + -item_id $item_id \ + -creation_date $creation_date \ + -creation_user $creation_user \ + -context_id $context_id \ + -creation_ip $creation_ip] + set revision_id [content::revision::new \ + -item_id $project_item_id \ + -content_type {pm_project} \ + -title $project_name \ + -description $description \ + -mime_type $mime_type \ + -attributes [list \ + [list project_code $project_code] \ + [list goal $goal] \ + [list planned_start_date $planned_start_date] \ + [list planned_end_date $planned_end_date] \ + [list actual_start_date $actual_start_date] \ + [list actual_end_date $actual_end_date] \ + [list ongoing_p $ongoing_p] \ + [list estimated_finish_date $estimated_finish_date] \ + [list latest_finish_date $latest_finish_date] \ + [list earliest_finish_date $earliest_finish_date] \ + [list actual_hours_completed $actual_hours_completed] \ + [list estimated_hours_total $estimated_hours_total] \ + [list customer_id $customer_id] \ + [list status_id $status_id] \ + [list currency $currency] \ + [list dform $dform] ] ] + + # Assign the user to the project + permission::grant -party_id creation_user -object_id project_item_id -privilege admin + set project_role [pm::role::default] pm::project::assign \ -project_item_id $project_item_id \ -role_id $project_role \ -party_id $creation_user \ -send_email_p "f" - # Set the parent_id to the package_id if this is not a subproject. - # Otherwise permission inheritance won't work. - # Update the context_id - if {[empty_string_p $parent_id]} { - set parent_id $package_id - } - - db_dml update_context_id "update acs_objects set context_id = :parent_id where object_id = :project_item_id" - if {!$no_callback_p} { callback pm::project_new -package_id $package_id -project_id $project_item_id -data [list organization_id $organization_id] } @@ -1553,6 +1587,17 @@ return $project_parent_id } +ad_proc -public pm::project::root_folder { + {-package_id:required} +} { + + Return the root folder of a given project package_id + + @return project_item_id of the root project +} { + set root_folder [db_exec_plsql get_root_folder { }] +} + ad_proc -public pm::project::compute_parent_status {project_item_id} { When a project is updated, or a task updated within a project, we need to