Index: openacs-4/packages/acs-subsite/www/admin/applications/application-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/applications/application-delete.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-subsite/www/admin/applications/application-delete.tcl 22 Dec 2003 22:00:25 -0000 1.4 +++ openacs-4/packages/acs-subsite/www/admin/applications/application-delete.tcl 27 Oct 2014 16:39:48 -0000 1.5 @@ -2,36 +2,72 @@ Delete an application. @author Lars Pind (lars@collaboraid.biz) + @author Gustaf Neumann + @creation-date 2003-05-28 @cvs-id $Id$ } { - node_id:integer,multiple + {node_id:naturalnum,multiple ""} + {package_id:naturalnum,multiple ""} + {return_url .} {confirm_p 0} } +foreach id $package_id { + set id [site_node::get_node_id_from_object_id -object_id $id] + if {$id ne ""} { + lappend node_id $id + set p [lsearch $package_id $id] + set package_id [lreplace $package_id $p $p] + } +} +ns_log notice "package_id <$package_id> node_id <$node_id>" + +set num [expr {[llength $node_id] + [llength $package_id]}] +set page_title "Delete [ad_decode $num 1 "Application" "Applications"]" +set context [list [list "." "Applications"] $page_title] +set yes_url [export_vars -base [ad_conn url] { node_id:multiple package_id:multiple return_url { confirm_p 1 } }] +set no_url $return_url +set listing "" + if { !$confirm_p } { - set num [llength $node_id] if { $num == 0 } { ad_returnredirect . return } - set page_title "Delete [ad_decode $num 1 "Application" "Applications"]" - set context [list [list "." "Applications"] $page_title] - set yes_url [export_vars -base [ad_conn url] { node_id:multiple { confirm_p 1 } }] - set no_url "." + append listing \n + return } # First unmount and delete the site-nodes, then delete the package, in separate transactions, # so even if the package deletion fails, it'll be gone from this subsite. -set package_id [list] +set package_ids $package_id db_transaction { foreach id $node_id { - lappend package_id [site_node::get_object_id -node_id $id] + lappend package_ids [site_node::get_object_id -node_id $id] # Unmount the application site_node::unmount -node_id $id @@ -42,18 +78,23 @@ } db_transaction { - foreach id $package_id { + foreach id $package_ids { # Delete the instance apm_package_instance_delete $id } } on_error { set error_p 1 - global errorInfo - ns_log Error "Error deleting package with package_id $id: $errmsg\n$errorInfo" + ns_log Error "Error deleting package with package_id $id: $errmsg\n$::errorInfo" # Hm. Not sure what to do. For now, let's rethrow the error. - error $errmsg $errorInfo + error $errmsg $::errorInfo } -ad_returnredirect . +ad_returnredirect $return_url +# +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: