Index: openacs-4/packages/acs-subsite/www/admin/site-map/package-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/site-map/package-new.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-subsite/www/admin/site-map/package-new.tcl 16 Jan 2003 13:40:07 -0000 1.6 +++ openacs-4/packages/acs-subsite/www/admin/site-map/package-new.tcl 14 Apr 2003 14:02:07 -0000 1.7 @@ -1,14 +1,19 @@ # packages/acs-core-ui/www/admin/site-nodes/package-new.tcl ad_page_contract { + Create a new package and mount it in the site map. If new_node_p is false then + the package will be mounted at node_id. If new_node_p is true then a new node with + name node_name will be created under root_id and the package will be mounted there. @author rhs@mit.edu @creation-date 2000-09-13 @cvs-id $Id$ } { - new_package_id:integer,notnull + {new_package_id:integer ""} node_id:integer,notnull + {new_node_p f} + {node_name ""} {instance_name ""} package_key:notnull {expand:integer,multiple ""} @@ -20,24 +25,40 @@ ad_script_abort } -set context_id [db_string context_id { - select parent.object_id as context_id - from site_nodes parent, site_nodes child - where child.node_id = :node_id - and parent.node_id = child.parent_id -}] - -# If the parent node didn't have anything mounted, use the current package_id as context_id -if { [empty_string_p $context_id] } { - set context_id [ad_conn package_id] -} - if { [empty_string_p $instance_name] } { set instance_name [db_string instance_default_name "select pretty_name from apm_package_types where package_key = :package_key"] } db_transaction { - set package_id [site_node_create_package_instance -package_id $new_package_id $node_id $instance_name $context_id $package_key] + set context_id [db_string context_id { + select parent.object_id as context_id + from site_nodes parent, site_nodes child + where child.node_id = :node_id + and parent.node_id = child.parent_id + }] + # If the parent node didn't have anything mounted, use the current package_id as context_id + if { [empty_string_p $context_id] } { + set context_id [ad_conn package_id] + } + + if { $new_node_p } { + # Create a new node under node_id and mount the package there + set package_id [site_node::instantiate_and_mount -package_id $new_package_id \ + -package_key $package_key \ + -parent_node_id $node_id \ + -package_name $instance_name \ + -context_id $context_id \ + -node_name $node_name] + } else { + # Mount the new package at node_id + set package_id [site_node::instantiate_and_mount -package_id $new_package_id \ + -package_key $package_key \ + -node_id $node_id \ + -package_name $instance_name \ + -context_id $context_id \ + -package_key $package_key] + } + } on_error { if {![db_string package_new_doubleclick_ck {} -default 0]} { ad_return_complaint "Error Creating Package" "The following error was generated